GEOS  3.13.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 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 {
75 
76 private:
77 
78  static constexpr int MAX_INVERTED_RING_SIZE = 9;
79  static constexpr int INVERTED_CURVE_VERTEX_FACTOR = 4;
80  static constexpr double NEARNESS_FACTOR = 0.99;
81 
82  // To keep track of newly-created Labels.
83  // Labels will be released by object dtor
84  std::vector<geomgraph::Label*> newLabels;
85  const geom::Geometry& inputGeom;
86  double distance;
87  OffsetCurveBuilder curveBuilder;
88 
92  std::vector<noding::SegmentString*> curveList;
93  bool isInvertOrientation = false;
94 
107  void addCurve(geom::CoordinateSequence* coord, geom::Location leftLoc,
108  geom::Location rightLoc);
109 
110  void add(const geom::Geometry& g);
111 
112  void addCollection(const geom::GeometryCollection* gc);
113 
117  void addPoint(const geom::Point* p);
118 
119  void addLineString(const geom::LineString* line);
120 
121  void addPolygon(const geom::Polygon* p);
122 
123  void addLinearRingSides(const geom::CoordinateSequence* coord, double p_distance);
124 
143  void addPolygonRingSide(const geom::CoordinateSequence* coord,
144  double offsetDistance, int side, geom::Location cwLeftLoc,
145  geom::Location cwRightLoc);
146 
147  void addRingSide(const geom::CoordinateSequence* coord,
148  double offsetDistance, int side, geom::Location leftLoc,
149  geom::Location rightLoc);
150 
173  static bool isRingCurveInverted(
174  const geom::CoordinateSequence* inputPts, double dist,
175  const geom::CoordinateSequence* curvePts);
176 
188  static bool hasPointOnBuffer(
189  const CoordinateSequence* inputRing, double dist,
190  const CoordinateSequence* curveRing);
191 
201  bool isRingFullyEroded(const geom::LinearRing* ring, bool isHole,
202  double bufferDistance);
203 
204  bool isRingFullyEroded(const CoordinateSequence* ringCoord, const Envelope* env, bool isHole,
205  double bufferDistance);
206 
225  bool isTriangleErodedCompletely(const geom::CoordinateSequence* triCoords,
226  double bufferDistance);
227 
228  // Declare type as noncopyable
229  BufferCurveSetBuilder(const BufferCurveSetBuilder& other) = delete;
230  BufferCurveSetBuilder& operator=(const BufferCurveSetBuilder& rhs) = delete;
231 
245  bool isRingCCW(const geom::CoordinateSequence* coords) const;
246 
247 public:
248 
251  const geom::Geometry& newInputGeom,
252  double newDistance,
253  const geom::PrecisionModel* newPm,
254  const BufferParameters& newBufParams)
255  : inputGeom(newInputGeom)
256  , distance(newDistance)
257  , curveBuilder(newPm, newBufParams)
258  , curveList()
259  , isInvertOrientation(false)
260  {};
261 
264 
273  std::vector<noding::SegmentString*>& getCurves();
274 
282  void addCurves(const std::vector<geom::CoordinateSequence*>& lineList,
283  geom::Location leftLoc, geom::Location rightLoc);
284 
293  void setInvertOrientation(bool p_isInvertOrientation) {
294  isInvertOrientation = p_isInvertOrientation;
295  }
296 
297 };
298 
299 } // namespace geos::operation::buffer
300 } // namespace geos::operation
301 } // namespace geos
302 
303 #ifdef _MSC_VER
304 #pragma warning(pop)
305 #endif
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:56
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:59
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:250
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:293
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