GEOS  3.10.3
OffsetCurveSetBuilder.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/OffsetCurveSetBuilder.java r378 (JTS-1.12)
17  *
18  **********************************************************************/
19 
20 #ifndef GEOS_OP_BUFFER_OFFSETCURVESETBUILDER_H
21 #define GEOS_OP_BUFFER_OFFSETCURVESETBUILDER_H
22 
23 #include <geos/export.h>
24 #include <geos/geom/Location.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 GeometryCollection;
39 class Point;
40 class LineString;
41 class LinearRing;
42 class Polygon;
43 }
44 namespace geomgraph {
45 class Label;
46 }
47 namespace noding {
48 class SegmentString;
49 }
50 namespace operation {
51 namespace buffer {
52 class OffsetCurveBuilder;
53 }
54 }
55 }
56 
57 namespace geos {
58 namespace operation { // geos.operation
59 namespace buffer { // geos.operation.buffer
60 
71 class GEOS_DLL OffsetCurveSetBuilder {
72 
73 private:
74 
75  static constexpr int MAX_INVERTED_RING_SIZE = 9;
76  static constexpr int INVERTED_CURVE_VERTEX_FACTOR = 4;
77  static constexpr double NEARNESS_FACTOR = 0.99;
78 
79  // To keep track of newly-created Labels.
80  // Labels will be released by object dtor
81  std::vector<geomgraph::Label*> newLabels;
82  const geom::Geometry& inputGeom;
83  double distance;
84  OffsetCurveBuilder& curveBuilder;
85 
89  std::vector<noding::SegmentString*> curveList;
90  bool isInvertOrientation = false;
91 
104  void addCurve(geom::CoordinateSequence* coord, geom::Location leftLoc,
105  geom::Location rightLoc);
106 
107  void add(const geom::Geometry& g);
108 
109  void addCollection(const geom::GeometryCollection* gc);
110 
114  void addPoint(const geom::Point* p);
115 
116  void addLineString(const geom::LineString* line);
117 
118  void addPolygon(const geom::Polygon* p);
119 
120  void addRingBothSides(const geom::CoordinateSequence* coord, double p_distance);
121 
140  void addRingSide(const geom::CoordinateSequence* coord,
141  double offsetDistance, int side, geom::Location cwLeftLoc,
142  geom::Location cwRightLoc);
143 
166  static bool isRingCurveInverted(
167  const geom::CoordinateSequence* inputPts, double dist,
168  const geom::CoordinateSequence* curvePts);
169 
177  static double maxDistance(
178  const geom::CoordinateSequence* pts, const geom::CoordinateSequence* line);
179 
189  bool isErodedCompletely(const geom::LinearRing* ringCoord,
190  double bufferDistance);
191 
210  bool isTriangleErodedCompletely(const geom::CoordinateSequence* triCoords,
211  double bufferDistance);
212 
213  // Declare type as noncopyable
214  OffsetCurveSetBuilder(const OffsetCurveSetBuilder& other) = delete;
215  OffsetCurveSetBuilder& operator=(const OffsetCurveSetBuilder& rhs) = delete;
216 
230  bool isRingCCW(const geom::CoordinateSequence* coords) const;
231 
232 public:
233 
236  double newDistance, OffsetCurveBuilder& newCurveBuilder);
237 
240 
249  std::vector<noding::SegmentString*>& getCurves();
250 
258  void addCurves(const std::vector<geom::CoordinateSequence*>& lineList,
259  geom::Location leftLoc, geom::Location rightLoc);
260 
269  void setInvertOrientation(bool p_isInvertOrientation) {
270  isInvertOrientation = p_isInvertOrientation;
271  }
272 
273 };
274 
275 } // namespace geos::operation::buffer
276 } // namespace geos::operation
277 } // namespace geos
278 
279 #ifdef _MSC_VER
280 #pragma warning(pop)
281 #endif
282 
283 #endif // ndef GEOS_OP_BUFFER_OFFSETCURVESETBUILDER_H
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:55
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Definition: LineString.h:68
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition: LinearRing.h:57
Definition: Point.h:66
Represents a linear polygon, which may include holes.
Definition: Polygon.h:64
Computes the raw offset curve for a single Geometry component (ring, line or point).
Definition: OffsetCurveBuilder.h:62
Creates all the raw offset curves for a buffer of a Geometry.
Definition: OffsetCurveSetBuilder.h:71
OffsetCurveSetBuilder(const geom::Geometry &newInputGeom, double newDistance, OffsetCurveBuilder &newCurveBuilder)
Constructor.
void addCurves(const std::vector< geom::CoordinateSequence * > &lineList, geom::Location leftLoc, geom::Location rightLoc)
Add raw curves for a set of CoordinateSequences.
std::vector< noding::SegmentString * > & getCurves()
Computes the set of raw offset curves for the buffer.
void setInvertOrientation(bool p_isInvertOrientation)
Definition: OffsetCurveSetBuilder.h:269
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:34
Basic namespace for all GEOS functionalities.
Definition: Angle.h:26