GEOS  3.14.0dev
OffsetCurveBuilder.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2009-2011 Sandro Santilli <strk@kbt.io>
7  * Copyright (C) 2006-2007 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/OffsetCurveBuilder.java r378 (JTS-1.12)
17  *
18  **********************************************************************/
19 
20 #pragma once
21 
22 #include <geos/export.h>
23 
24 #include <geos/operation/buffer/BufferParameters.h> // for composition
25 #include <geos/operation/buffer/OffsetSegmentGenerator.h>
26 
27 #include <vector>
28 #include <memory> // for unique_ptr
29 
30 #ifdef _MSC_VER
31 #pragma warning(push)
32 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
33 #endif
34 
35 // Forward declarations
36 namespace geos {
37 namespace geom {
38 class CoordinateSequence;
39 class PrecisionModel;
40 }
41 }
42 
43 namespace geos {
44 namespace operation { // geos.operation
45 namespace buffer { // geos.operation.buffer
46 
65 class GEOS_DLL OffsetCurveBuilder {
68 
69 public:
70 
71  /*
72  * @param nBufParams buffer parameters, this object will
73  * keep a reference to the passed parameters
74  * so caller must make sure the object is
75  * kept alive for the whole lifetime of
76  * the buffer builder.
77  */
79  const PrecisionModel* newPrecisionModel,
80  const BufferParameters& nBufParams)
81  : distance(0.0)
82  , precisionModel(newPrecisionModel)
83  , bufParams(nBufParams)
84  {}
85 
91  const BufferParameters&
93  {
94  return bufParams;
95  }
96 
108  bool isLineOffsetEmpty(double distance);
109 
122  void getLineCurve(const CoordinateSequence* inputPts,
123  double distance,
124  std::vector<CoordinateSequence*>& lineList);
125 
137  std::unique_ptr<CoordinateSequence> getLineCurve(
138  const CoordinateSequence* inputPts, double pDistance);
139 
159  double distance, std::vector<CoordinateSequence*>& lineList,
160  bool leftSide, bool rightSide) ;
161 
172  void getRingCurve(const CoordinateSequence* inputPts, int side,
173  double distance,
174  std::vector<CoordinateSequence*>& lineList);
175 
186  std::unique_ptr<CoordinateSequence> getRingCurve(
187  const CoordinateSequence* inputPts,
188  int side, double pDistance);
189 
190  void getOffsetCurve(const CoordinateSequence* inputPts,
191  double p_distance,
192  std::vector<CoordinateSequence*>& lineList);
193 
194  std::unique_ptr<CoordinateSequence> getOffsetCurve(
195  const CoordinateSequence* inputPts,
196  double pDistance);
197 
198 
199 private:
200 
201  double distance;
202 
203  const PrecisionModel* precisionModel;
204 
205  const BufferParameters& bufParams;
206 
214  static const double SIMPLIFY_FACTOR; // 100.0;
215 
223  double simplifyTolerance(double bufDistance);
224 
225  void computeLineBufferCurve(const CoordinateSequence& inputPts,
226  OffsetSegmentGenerator& segGen);
227 
228  void computeSingleSidedBufferCurve(const CoordinateSequence& inputPts,
229  bool isRightSide,
230  OffsetSegmentGenerator& segGen);
231 
232  void computeRingBufferCurve(const CoordinateSequence& inputPts,
233  int side, OffsetSegmentGenerator& segGen);
234 
235  void computePointCurve(const geom::Coordinate& pt,
236  OffsetSegmentGenerator& segGen);
237 
238  void computeOffsetCurve(
239  const CoordinateSequence* inputPts,
240  bool isRightSide,
241  OffsetSegmentGenerator& segGen);
242 
243 
244 
245  // Declare type as noncopyable
246  OffsetCurveBuilder(const OffsetCurveBuilder& other) = delete;
247  OffsetCurveBuilder& operator=(const OffsetCurveBuilder& rhs) = delete;
248 };
249 
250 } // namespace geos::operation::buffer
251 } // namespace geos::operation
252 } // namespace geos
253 
254 #ifdef _MSC_VER
255 #pragma warning(pop)
256 #endif
257 
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:56
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:217
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:88
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
std::unique_ptr< CoordinateSequence > getLineCurve(const CoordinateSequence *inputPts, double pDistance)
void getLineCurve(const CoordinateSequence *inputPts, double distance, std::vector< CoordinateSequence * > &lineList)
This method handles single points as well as lines.
const BufferParameters & getBufferParameters() const
Gets the buffer parameters being used to generate the curve.
Definition: OffsetCurveBuilder.h:92
std::unique_ptr< CoordinateSequence > getRingCurve(const CoordinateSequence *inputPts, int side, double pDistance)
void getSingleSidedLineCurve(const CoordinateSequence *inputPts, double distance, std::vector< CoordinateSequence * > &lineList, bool leftSide, bool rightSide)
This method handles single points as well as lines.
void getRingCurve(const CoordinateSequence *inputPts, int side, double distance, std::vector< CoordinateSequence * > &lineList)
This method handles the degenerate cases of single points and lines, as well as rings.
Definition: OffsetSegmentGenerator.h:60
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25