GEOS  3.13.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 {
73 
74 private:
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 
182  static bool hasPointOnBuffer(
183  const CoordinateSequence* inputRing, double dist,
184  const CoordinateSequence* curveRing);
185 
195  bool isErodedCompletely(const geom::LinearRing* ringCoord,
196  double bufferDistance);
197 
216  bool isTriangleErodedCompletely(const geom::CoordinateSequence* triCoords,
217  double bufferDistance);
218 
219  // Declare type as noncopyable
220  BufferCurveSetBuilder(const BufferCurveSetBuilder& other) = delete;
221  BufferCurveSetBuilder& operator=(const BufferCurveSetBuilder& rhs) = delete;
222 
236  bool isRingCCW(const geom::CoordinateSequence* coords) const;
237 
238 public:
239 
242  const geom::Geometry& newInputGeom,
243  double newDistance,
244  const geom::PrecisionModel* newPm,
245  const BufferParameters& newBufParams)
246  : inputGeom(newInputGeom)
247  , distance(newDistance)
248  , curveBuilder(newPm, newBufParams)
249  , curveList()
250  , isInvertOrientation(false)
251  {};
252 
255 
264  std::vector<noding::SegmentString*>& getCurves();
265 
273  void addCurves(const std::vector<geom::CoordinateSequence*>& lineList,
274  geom::Location leftLoc, geom::Location rightLoc);
275 
284  void setInvertOrientation(bool p_isInvertOrientation) {
285  isInvertOrientation = p_isInvertOrientation;
286  }
287 
288 };
289 
290 } // namespace geos::operation::buffer
291 } // namespace geos::operation
292 } // namespace geos
293 
294 #ifdef _MSC_VER
295 #pragma warning(pop)
296 #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:186
Definition: LineString.h:65
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:60
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:241
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:284
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:68
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