GEOS  3.14.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 
54 namespace geos {
55 namespace simplify { // geos::simplify
56 
57 
68 
69 public:
70 
71  TaggedLineStringSimplifier(LineSegmentIndex* inputIndex,
72  LineSegmentIndex* outputIndex,
73  const ComponentJumpChecker* jumpChecker);
74 
82  void simplify(TaggedLineString* line, double distanceTolerance);
83 
84 
85 private:
86 
87  // externally owned
88  LineSegmentIndex* inputIndex;
89 
90  // externally owned
91  LineSegmentIndex* outputIndex;
92 
93  const ComponentJumpChecker* jumpChecker;
94 
95  std::unique_ptr<algorithm::LineIntersector> li;
96 
98  TaggedLineString* line;
99 
100  const CoordinateSequence* linePts;
101 
102  void simplifySection(std::size_t i, std::size_t j, std::size_t depth, double distanceTolerance);
103 
104  void simplifyRingEndpoint(double distanceTolerance);
105 
106  static std::size_t findFurthestPoint(
107  const CoordinateSequence* pts,
108  std::size_t i, std::size_t j,
109  double& maxDistance);
110 
111  bool isTopologyValid(
112  const TaggedLineString* lineIn,
113  std::size_t sectionStart, std::size_t sectionEnd,
114  const LineSegment& flatSeg);
115 
116  bool isTopologyValid(
117  const TaggedLineString* lineIn,
118  const LineSegment* seg1, const LineSegment* seg2,
119  const LineSegment& flatSeg);
120 
121  bool hasInputIntersection(const LineSegment& flatSeg);
122 
123  bool hasInputIntersection(
124  const TaggedLineString* lineIn,
125  std::size_t excludeStart, std::size_t excludeEnd,
126  const LineSegment& flatSeg);
127 
128  bool isCollinear(const Coordinate& pt, const LineSegment& seg) const;
129 
130  bool hasOutputIntersection(const LineSegment& flatSeg);
131 
132  bool hasInvalidIntersection(
133  const LineSegment& seg0,
134  const LineSegment& seg1) const;
135 
136 
137  std::unique_ptr<TaggedLineSegment> flatten(
138  std::size_t start, std::size_t end);
139 
152  static bool isInLineSection(
153  const TaggedLineString* line,
154  const std::size_t excludeStart, const std::size_t excludeEnd,
155  const TaggedLineSegment* seg);
156 
164  void remove(const TaggedLineString* line,
165  std::size_t start,
166  std::size_t end);
167 
168 };
169 
170 
171 } // namespace geos::simplify
172 } // namespace geos
173 
174 #ifdef _MSC_VER
175 #pragma warning(pop)
176 #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:217
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:64
void simplify(TaggedLineString *line, double distanceTolerance)
Contains and owns a list of TaggedLineSegments.
Definition: TaggedLineString.h:57
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25