GEOS 3.9.1
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 {
39namespace algorithm {
40class LineIntersector;
41}
42namespace geom {
43class CoordinateSequence;
44class LineSegment;
45}
46namespace simplify {
47class TaggedLineSegment;
48class TaggedLineString;
49class LineSegmentIndex;
50}
51}
52
53namespace geos {
54namespace simplify { // geos::simplify
55
56
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::unique_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::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
156inline void
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
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Definition: LineSegment.h:59
A geom::LineSegment which is tagged with its location in a geom::Geometry.
Definition: TaggedLineSegment.h:54
Simplifies a TaggedLineString, preserving topology (in the sense that no new intersections are introd...
Definition: TaggedLineStringSimplifier.h:63
void simplify(TaggedLineString *line)
void setDistanceTolerance(double d)
Sets the distance tolerance for the simplification.
Definition: TaggedLineStringSimplifier.h:157
Contains and owns a list of TaggedLineSegments.
Definition: TaggedLineString.h:58
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26