GEOS  3.14.0dev
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 4c343e79f (JTS-1.19)
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
34 namespace geos {
35 namespace geom {
36 class Geometry;
37 class CoordinateSequence;
38 class PrecisionModel;
39 class GeometryCollection;
40 class Point;
41 class LineString;
42 class LinearRing;
43 class Polygon;
44 }
45 namespace geomgraph {
46 class Label;
47 }
48 namespace noding {
49 class SegmentString;
50 }
51 namespace operation {
52 namespace buffer {
53 class BufferParameters;
54 }
55 }
56 }
57 
58 namespace geos {
59 namespace operation { // geos.operation
60 namespace buffer { // geos.operation.buffer
61 
72 class GEOS_DLL BufferCurveSetBuilder {
74 
75 private:
76 
77  static constexpr int MAX_INVERTED_RING_SIZE = 9;
78  static constexpr int INVERTED_CURVE_VERTEX_FACTOR = 4;
79  static constexpr double NEARNESS_FACTOR = 0.99;
80 
81  // To keep track of newly-created Labels.
82  // Labels will be released by object dtor
83  std::vector<geomgraph::Label*> newLabels;
84  const geom::Geometry& inputGeom;
85  double distance;
86  OffsetCurveBuilder curveBuilder;
87 
91  std::vector<noding::SegmentString*> curveList;
92  bool isInvertOrientation = false;
93 
106  void addCurve(geom::CoordinateSequence* coord, geom::Location leftLoc,
107  geom::Location rightLoc);
108 
109  void add(const geom::Geometry& g);
110 
111  void addCollection(const geom::GeometryCollection* gc);
112 
116  void addPoint(const geom::Point* p);
117 
118  void addLineString(const geom::LineString* line);
119 
120  void addPolygon(const geom::Polygon* p);
121 
122  void addRingBothSides(const geom::CoordinateSequence* coord, double p_distance);
123 
142  void addRingSide(const geom::CoordinateSequence* coord,
143  double offsetDistance, int side, geom::Location cwLeftLoc,
144  geom::Location cwRightLoc);
145 
168  static bool isRingCurveInverted(
169  const geom::CoordinateSequence* inputPts, double dist,
170  const geom::CoordinateSequence* curvePts);
171 
183  static bool hasPointOnBuffer(
184  const CoordinateSequence* inputRing, double dist,
185  const CoordinateSequence* curveRing);
186 
196  bool isErodedCompletely(const geom::LinearRing* ringCoord,
197  double bufferDistance);
198 
217  bool isTriangleErodedCompletely(const geom::CoordinateSequence* triCoords,
218  double bufferDistance);
219 
220  // Declare type as noncopyable
221  BufferCurveSetBuilder(const BufferCurveSetBuilder& other) = delete;
222  BufferCurveSetBuilder& operator=(const BufferCurveSetBuilder& rhs) = delete;
223 
237  bool isRingCCW(const geom::CoordinateSequence* coords) const;
238 
239 public:
240 
243  const geom::Geometry& newInputGeom,
244  double newDistance,
245  const geom::PrecisionModel* newPm,
246  const BufferParameters& newBufParams)
247  : inputGeom(newInputGeom)
248  , distance(newDistance)
249  , curveBuilder(newPm, newBufParams)
250  , curveList()
251  , isInvertOrientation(false)
252  {};
253 
256 
265  std::vector<noding::SegmentString*>& getCurves();
266 
274  void addCurves(const std::vector<geom::CoordinateSequence*>& lineList,
275  geom::Location leftLoc, geom::Location rightLoc);
276 
285  void setInvertOrientation(bool p_isInvertOrientation) {
286  isInvertOrientation = p_isInvertOrientation;
287  }
288 
289 };
290 
291 } // namespace geos::operation::buffer
292 } // namespace geos::operation
293 } // namespace geos
294 
295 #ifdef _MSC_VER
296 #pragma warning(pop)
297 #endif
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:56
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:51
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:197
Definition: LineString.h:66
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition: LinearRing.h:54
Definition: Point.h:61
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:88
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:242
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:285
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:65
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:32
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25