GEOS  3.13.0dev
TaggedLineStringSimplifier.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2006 Refractions Research Inc.
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************
14  *
15  * Last port: simplify/TaggedLineStringSimplifier.java r536 (JTS-1.12+)
16  *
17  **********************************************************************
18  *
19  * NOTES: This class can be optimized to work with vector<Coordinate*>
20  * rather then with CoordinateSequence
21  *
22  **********************************************************************/
23 
24 #pragma once
25 
26 #include <geos/export.h>
27 #include <cstddef>
28 #include <vector>
29 #include <memory>
30 
31 #ifdef _MSC_VER
32 #pragma warning(push)
33 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
34 #endif
35 
36 // Forward declarations
37 namespace geos {
38 namespace algorithm {
39 class LineIntersector;
40 }
41 namespace geom {
42 class CoordinateSequence;
43 class Coordinate;
44 class LineSegment;
45 }
46 namespace simplify {
47 class TaggedLineSegment;
48 class TaggedLineString;
49 class LineSegmentIndex;
50 class ComponentJumpChecker;
51 }
52 }
53 
57 
58 
59 namespace geos {
60 namespace simplify { // geos::simplify
61 
62 
70 
71 public:
72 
73  TaggedLineStringSimplifier(LineSegmentIndex* inputIndex,
74  LineSegmentIndex* outputIndex,
75  const ComponentJumpChecker* jumpChecker);
76 
84  void simplify(TaggedLineString* line, double distanceTolerance);
85 
86 
87 private:
88 
89  // externally owned
90  LineSegmentIndex* inputIndex;
91 
92  // externally owned
93  LineSegmentIndex* outputIndex;
94 
95  const ComponentJumpChecker* jumpChecker;
96 
97  std::unique_ptr<algorithm::LineIntersector> li;
98 
100  TaggedLineString* line;
101 
102  const CoordinateSequence* linePts;
103 
104  void simplifySection(std::size_t i, std::size_t j, std::size_t depth, double distanceTolerance);
105 
106  void simplifyRingEndpoint(double distanceTolerance);
107 
108  static std::size_t findFurthestPoint(
109  const CoordinateSequence* pts,
110  std::size_t i, std::size_t j,
111  double& maxDistance);
112 
113  bool isTopologyValid(
114  const TaggedLineString* lineIn,
115  std::size_t sectionStart, std::size_t sectionEnd,
116  const LineSegment& flatSeg);
117 
118  bool isTopologyValid(
119  const TaggedLineString* lineIn,
120  const LineSegment* seg1, const LineSegment* seg2,
121  const LineSegment& flatSeg);
122 
123  bool hasInputIntersection(const LineSegment& flatSeg);
124 
125  bool hasInputIntersection(
126  const TaggedLineString* lineIn,
127  std::size_t excludeStart, std::size_t excludeEnd,
128  const LineSegment& flatSeg);
129 
130  bool isCollinear(const Coordinate& pt, const LineSegment& seg) const;
131 
132  bool hasOutputIntersection(const LineSegment& flatSeg);
133 
134  bool hasInvalidIntersection(
135  const LineSegment& seg0,
136  const LineSegment& seg1) const;
137 
138 
139  std::unique_ptr<TaggedLineSegment> flatten(
140  std::size_t start, std::size_t end);
141 
154  static bool isInLineSection(
155  const TaggedLineString* line,
156  const std::size_t excludeStart, const std::size_t excludeEnd,
157  const TaggedLineSegment* seg);
158 
166  void remove(const TaggedLineString* line,
167  std::size_t start,
168  std::size_t end);
169 
170 };
171 
172 
173 } // namespace geos::simplify
174 } // namespace geos
175 
176 #ifdef _MSC_VER
177 #pragma warning(pop)
178 #endif
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:56
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:216
Definition: LineSegment.h:61
A geom::LineSegment which is tagged with its location in a geom::Geometry.
Definition: TaggedLineSegment.h:53
Simplifies a TaggedLineString, preserving topology (in the sense that no new intersections are introd...
Definition: TaggedLineStringSimplifier.h:69
void simplify(TaggedLineString *line, double distanceTolerance)
Contains and owns a list of TaggedLineSegments.
Definition: TaggedLineString.h:60
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25