GEOS 3.12.0
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
37namespace geos {
38namespace algorithm {
39class LineIntersector;
40}
41namespace geom {
42class CoordinateSequence;
43class LineSegment;
44}
45namespace simplify {
46class TaggedLineSegment;
47class TaggedLineString;
48class LineSegmentIndex;
49}
50}
51
52namespace geos {
53namespace simplify { // geos::simplify
54
55
63
64public:
65
66 TaggedLineStringSimplifier(LineSegmentIndex* inputIndex,
67 LineSegmentIndex* outputIndex);
68
77 void setDistanceTolerance(double d);
78
86
87
88private:
89
90 // externally owned
91 LineSegmentIndex* inputIndex;
92
93 // externally owned
94 LineSegmentIndex* outputIndex;
95
96 std::unique_ptr<algorithm::LineIntersector> li;
97
99 TaggedLineString* line;
100
101 const geom::CoordinateSequence* linePts;
102
103 double distanceTolerance;
104
105 void simplifySection(std::size_t i, std::size_t j,
106 std::size_t depth);
107
108 void simplifyRingEndpoint();
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::pair<std::size_t, std::size_t>& sectionIndex,
117 const geom::LineSegment& candidateSeg);
118
119 bool hasBadInputIntersection(const TaggedLineString* parentLine,
120 const std::pair<std::size_t, 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::unique_ptr<TaggedLineSegment> flatten(
129 std::size_t start, std::size_t end);
130
139 static bool isInLineSection(
140 const TaggedLineString* line,
141 const std::pair<std::size_t, std::size_t>& sectionIndex,
142 const TaggedLineSegment* seg);
143
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
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
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:62
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:57
Basic namespace for all GEOS functionalities.
Definition geos.h:39