GEOS 3.11.1
BufferCurveSetBuilder.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
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 Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************
15 *
16 * Last port: operation/buffer/BufferCurveSetBuilder.java r378 (JTS-1.12)
17 *
18 **********************************************************************/
19
20#pragma once
21
22#include <geos/export.h>
23#include <geos/geom/Location.h>
24#include <geos/operation/buffer/OffsetCurveBuilder.h>
25
26#include <vector>
27
28#ifdef _MSC_VER
29#pragma warning(push)
30#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
31#endif
32
33// Forward declarations
34namespace geos {
35namespace geom {
36class Geometry;
37class CoordinateSequence;
38class PrecisionModel;
39class GeometryCollection;
40class Point;
41class LineString;
42class LinearRing;
43class Polygon;
44}
45namespace geomgraph {
46class Label;
47}
48namespace noding {
49class SegmentString;
50}
51namespace operation {
52namespace buffer {
53class BufferParameters;
54}
55}
56}
57
58namespace geos {
59namespace operation { // geos.operation
60namespace buffer { // geos.operation.buffer
61
72class GEOS_DLL BufferCurveSetBuilder {
73
74private:
75
76 static constexpr int MAX_INVERTED_RING_SIZE = 9;
77 static constexpr int INVERTED_CURVE_VERTEX_FACTOR = 4;
78 static constexpr double NEARNESS_FACTOR = 0.99;
79
80 // To keep track of newly-created Labels.
81 // Labels will be released by object dtor
82 std::vector<geomgraph::Label*> newLabels;
83 const geom::Geometry& inputGeom;
84 double distance;
85 OffsetCurveBuilder curveBuilder;
86
90 std::vector<noding::SegmentString*> curveList;
91 bool isInvertOrientation = false;
92
105 void addCurve(geom::CoordinateSequence* coord, geom::Location leftLoc,
106 geom::Location rightLoc);
107
108 void add(const geom::Geometry& g);
109
110 void addCollection(const geom::GeometryCollection* gc);
111
115 void addPoint(const geom::Point* p);
116
117 void addLineString(const geom::LineString* line);
118
119 void addPolygon(const geom::Polygon* p);
120
121 void addRingBothSides(const geom::CoordinateSequence* coord, double p_distance);
122
141 void addRingSide(const geom::CoordinateSequence* coord,
142 double offsetDistance, int side, geom::Location cwLeftLoc,
143 geom::Location cwRightLoc);
144
167 static bool isRingCurveInverted(
168 const geom::CoordinateSequence* inputPts, double dist,
169 const geom::CoordinateSequence* curvePts);
170
178 static double maxDistance(
179 const geom::CoordinateSequence* pts, const geom::CoordinateSequence* line);
180
190 bool isErodedCompletely(const geom::LinearRing* ringCoord,
191 double bufferDistance);
192
211 bool isTriangleErodedCompletely(const geom::CoordinateSequence* triCoords,
212 double bufferDistance);
213
214 // Declare type as noncopyable
215 BufferCurveSetBuilder(const BufferCurveSetBuilder& other) = delete;
216 BufferCurveSetBuilder& operator=(const BufferCurveSetBuilder& rhs) = delete;
217
231 bool isRingCCW(const geom::CoordinateSequence* coords) const;
232
233public:
234
237 const geom::Geometry& newInputGeom,
238 double newDistance,
239 const geom::PrecisionModel* newPm,
240 const BufferParameters& newBufParams)
241 : inputGeom(newInputGeom)
242 , distance(newDistance)
243 , curveBuilder(newPm, newBufParams)
244 , curveList()
245 , isInvertOrientation(false)
246 {};
247
250
259 std::vector<noding::SegmentString*>& getCurves();
260
268 void addCurves(const std::vector<geom::CoordinateSequence*>& lineList,
269 geom::Location leftLoc, geom::Location rightLoc);
270
279 void setInvertOrientation(bool p_isInvertOrientation) {
280 isInvertOrientation = p_isInvertOrientation;
281 }
282
283};
284
285} // namespace geos::operation::buffer
286} // namespace geos::operation
287} // namespace geos
288
289#ifdef _MSC_VER
290#pragma warning(pop)
291#endif
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:44
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:52
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Definition: LineString.h:66
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition: LinearRing.h:55
Definition: Point.h:63
Represents a linear polygon, which may include holes.
Definition: Polygon.h:61
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:90
Creates all the raw offset curves for a buffer of a Geometry.
Definition: BufferCurveSetBuilder.h:72
BufferCurveSetBuilder(const geom::Geometry &newInputGeom, double newDistance, const geom::PrecisionModel *newPm, const BufferParameters &newBufParams)
Constructor.
Definition: BufferCurveSetBuilder.h:236
std::vector< noding::SegmentString * > & getCurves()
Computes the set of raw offset curves for the buffer.
void addCurves(const std::vector< geom::CoordinateSequence * > &lineList, geom::Location leftLoc, geom::Location rightLoc)
Add raw curves for a set of CoordinateSequences.
void setInvertOrientation(bool p_isInvertOrientation)
Definition: BufferCurveSetBuilder.h:279
Contains the parameters which describe how a buffer should be constructed.
Definition: BufferParameters.h:56
Computes the raw offset curve for a single Geometry component (ring, line or point).
Definition: OffsetCurveBuilder.h:61
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:32
Basic namespace for all GEOS functionalities.
Definition: geos.h:39