GEOS  3.9.1dev
TaggedLineStringSimplifier.h
Go to the documentation of this file.
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 #ifndef GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H
25 #define GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H
26 
27 #include <geos/export.h>
28 #include <cstddef>
29 #include <vector>
30 #include <memory>
31 
32 #ifdef _MSC_VER
33 #pragma warning(push)
34 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
35 #endif
36 
37 // Forward declarations
38 namespace geos {
39 namespace algorithm {
40 class LineIntersector;
41 }
42 namespace geom {
43 class CoordinateSequence;
44 class LineSegment;
45 }
46 namespace simplify {
47 class TaggedLineSegment;
48 class TaggedLineString;
49 class LineSegmentIndex;
50 }
51 }
52 
53 namespace geos {
54 namespace simplify { // geos::simplify
55 
56 
64 
65 public:
66 
68  LineSegmentIndex* outputIndex);
69 
78  void setDistanceTolerance(double d);
79 
86  void simplify(TaggedLineString* line);
87 
88 
89 private:
90 
91  // externally owned
93 
94  // externally owned
96 
97  std::unique_ptr<algorithm::LineIntersector> li;
98 
101 
103 
105 
106  void simplifySection(std::size_t i, std::size_t j,
107  std::size_t depth);
108 
109  static std::size_t findFurthestPoint(
110  const geom::CoordinateSequence* pts,
111  std::size_t i, std::size_t j,
112  double& maxDistance);
113 
114  bool hasBadIntersection(const TaggedLineString* parentLine,
115  const std::pair<std::size_t, std::size_t>& sectionIndex,
116  const geom::LineSegment& candidateSeg);
117 
118  bool hasBadInputIntersection(const TaggedLineString* parentLine,
119  const std::pair<std::size_t, std::size_t>& sectionIndex,
120  const geom::LineSegment& candidateSeg);
121 
122  bool hasBadOutputIntersection(const geom::LineSegment& candidateSeg);
123 
124  bool hasInteriorIntersection(const geom::LineSegment& seg0,
125  const geom::LineSegment& seg1) const;
126 
127  std::unique_ptr<TaggedLineSegment> flatten(
128  std::size_t start, std::size_t end);
129 
138  static bool isInLineSection(
139  const TaggedLineString* parentLine,
140  const std::pair<std::size_t, std::size_t>& sectionIndex,
141  const TaggedLineSegment* seg);
142 
150  void remove(const TaggedLineString* line,
151  std::size_t start,
152  std::size_t end);
153 
154 };
155 
156 inline void
157 TaggedLineStringSimplifier::setDistanceTolerance(double d)
158 {
159  distanceTolerance = d;
160 }
161 
162 } // namespace geos::simplify
163 } // namespace geos
164 
165 #ifdef _MSC_VER
166 #pragma warning(pop)
167 #endif
168 
169 #endif // GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H
170 
#define GEOS_DLL
Definition: export.h:28
Simplifies a TaggedLineString, preserving topology (in the sense that no new intersections are introd...
std::unique_ptr< algorithm::LineIntersector > li
A geom::LineSegment which is tagged with its location in a geom::Geometry.
Basic namespace for all GEOS functionalities.
Contains and owns a list of TaggedLineSegments.
TaggedLineString * line
non-const as segments are possibly added to it
The internal representation of a list of coordinates inside a Geometry.