GEOS 3.6.2
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
38namespace geos {
39 namespace algorithm {
40 class LineIntersector;
41 }
42 namespace geom {
44 class LineSegment;
45 }
46 namespace simplify {
48 class TaggedLineString;
49 class LineSegmentIndex;
50 }
51}
52
53namespace geos {
54namespace simplify { // geos::simplify
55
56
63class GEOS_DLL TaggedLineStringSimplifier {
64
65public:
66
67 TaggedLineStringSimplifier(LineSegmentIndex* inputIndex,
68 LineSegmentIndex* outputIndex);
69
78 void setDistanceTolerance(double d);
79
87
88
89private:
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
157inline void
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
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition LineIntersector.h:49
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:59
Definition LineSegment.h:57
A geom::LineSegment which is tagged with its location in a geom::Geometry.
Definition TaggedLineSegment.h:55
void simplify(TaggedLineString *line)
void setDistanceTolerance(double d)
Sets the distance tolerance for the simplification.
Definition TaggedLineStringSimplifier.h:158
Contains and owns a list of TaggedLineSegments.
Definition TaggedLineString.h:60
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:33
Contains the Geometry interface hierarchy and supporting classes.
Definition IndexedNestedRingTester.h:26
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:25