GEOS: TaggedLineStringSimplifier.h Source File

GEOS 3.5.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

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 #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
63 class GEOS_DLL TaggedLineStringSimplifier {
64
65 public:
66
67 TaggedLineStringSimplifier(LineSegmentIndex* inputIndex,
68 LineSegmentIndex* outputIndex);
69
78 void setDistanceTolerance(double d);
79
86 void simplify(TaggedLineString* line);
87
88
89 private:
90
91 // externally owned
92 LineSegmentIndex* inputIndex;
93
94 // externally owned
95 LineSegmentIndex* outputIndex;
96
97 std::auto_ptr<algorithm::LineIntersector> li;
98
100 TaggedLineString* line;
101
102 const geom::CoordinateSequence* linePts;
103
104 double distanceTolerance;
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::vector<std::size_t>& sectionIndex,
116 const geom::LineSegment& candidateSeg);
117
118 bool hasBadInputIntersection(const TaggedLineString* parentLine,
119 const std::vector<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::auto_ptr<TaggedLineSegment> flatten(
128 std::size_t start, std::size_t end);
129
138 static bool isInLineSection(
139 const TaggedLineString* parentLine,
140 const std::vector<std::size_t>& sectionIndex,
141 const TaggedLineSegment* seg);
142
151 void remove(const TaggedLineString* line,
152 std::size_t start,
153 std::size_t end);
154
155 };
156
157 inline void
158 TaggedLineStringSimplifier::setDistanceTolerance(double d)
159 {
160 distanceTolerance = d;
161 }
162
163 } // namespace geos::simplify
164 } // namespace geos
165
166 #ifdef _MSC_VER
167 #pragma warning(pop)
168 #endif
169
170 #endif // GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H
171
geos::geom::LineSegment
Definition: LineSegment.h:57
geos::simplify::TaggedLineStringSimplifier
Simplifies a TaggedLineString, preserving topology (in the sense that no new intersections are introd...
Definition: TaggedLineStringSimplifier.h:63
geos::simplify::TaggedLineSegment
A geom::LineSegment which is tagged with its location in a geom::Geometry.
Definition: TaggedLineSegment.h:54
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::simplify::TaggedLineString
Contains and owns a list of TaggedLineSegments.
Definition: TaggedLineString.h:60
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:59