GEOS: TaggedLineStringSimplifier.h Source File

GEOS 3.3.8

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

- File List

TaggedLineStringSimplifier.h
1 /**********************************************************************
2 * $Id: TaggedLineStringSimplifier.h 3626 2012-05-09 18:02:09Z strk $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2006 Refractions Research Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************
15 *
16 * Last port: simplify/TaggedLineStringSimplifier.java r536 (JTS-1.12+)
17 *
18 **********************************************************************
19 *
20 * NOTES: This class can be optimized to work with vector<Coordinate*>
21 * rather then with CoordinateSequence
22 *
23 **********************************************************************/
24
25 #ifndef GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H
26 #define GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H
27
28 #include <geos/export.h>
29 #include <cstddef>
30 #include <vector>
31 #include <memory>
32
33 #ifdef _MSC_VER
34 #pragma warning(push)
35 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
36 #endif
37
38 // Forward declarations
39 namespace geos {
40 namespace algorithm {
41 class LineIntersector;
42 }
43 namespace geom {
44 class CoordinateSequence;
45 class LineSegment;
46 }
47 namespace simplify {
48 class TaggedLineSegment;
49 class TaggedLineString;
50 class LineSegmentIndex;
51 }
52 }
53
54 namespace geos {
55 namespace simplify { // geos::simplify
56
57
64 class GEOS_DLL TaggedLineStringSimplifier {
65
66 public:
67
68 TaggedLineStringSimplifier(LineSegmentIndex* inputIndex,
69 LineSegmentIndex* outputIndex);
70
79 void setDistanceTolerance(double d);
80
87 void simplify(TaggedLineString* line);
88
89
90 private:
91
92 // externally owned
93 LineSegmentIndex* inputIndex;
94
95 // externally owned
96 LineSegmentIndex* outputIndex;
97
98 std::auto_ptr<algorithm::LineIntersector> li;
99
101 TaggedLineString* line;
102
103 const geom::CoordinateSequence* linePts;
104
105 double distanceTolerance;
106
107 void simplifySection(std::size_t i, std::size_t j,
108 std::size_t depth);
109
110 static std::size_t findFurthestPoint(
111 const geom::CoordinateSequence* pts,
112 std::size_t i, std::size_t j,
113 double& maxDistance);
114
115 bool hasBadIntersection(const TaggedLineString* parentLine,
116 const std::vector<std::size_t>& sectionIndex,
117 const geom::LineSegment& candidateSeg);
118
119 bool hasBadInputIntersection(const TaggedLineString* parentLine,
120 const std::vector<std::size_t>& sectionIndex,
121 const geom::LineSegment& candidateSeg);
122
123 bool hasBadOutputIntersection(const geom::LineSegment& candidateSeg);
124
125 bool hasInteriorIntersection(const geom::LineSegment& seg0,
126 const geom::LineSegment& seg1) const;
127
128 std::auto_ptr<TaggedLineSegment> flatten(
129 std::size_t start, std::size_t end);
130
139 static bool isInLineSection(
140 const TaggedLineString* parentLine,
141 const std::vector<std::size_t>& sectionIndex,
142 const TaggedLineSegment* seg);
143
152 void remove(const TaggedLineString* line,
153 std::size_t start,
154 std::size_t end);
155
156 };
157
158 inline void
159 TaggedLineStringSimplifier::setDistanceTolerance(double d)
160 {
161 distanceTolerance = d;
162 }
163
164 } // namespace geos::simplify
165 } // namespace geos
166
167 #ifdef _MSC_VER
168 #pragma warning(pop)
169 #endif
170
171 #endif // GEOS_SIMPLIFY_TAGGEDLINESTRINGSIMPLIFIER_H
172