GEOS  3.11.0beta2
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 
61 class GEOS_DLL OffsetCurveBuilder {
62 public:
63 
64  /*
65  * @param nBufParams buffer parameters, this object will
66  * keep a reference to the passed parameters
67  * so caller must make sure the object is
68  * kept alive for the whole lifetime of
69  * the buffer builder.
70  */
71  OffsetCurveBuilder(const geom::PrecisionModel* newPrecisionModel,
72  const BufferParameters& nBufParams)
73  :
74  distance(0.0),
75  precisionModel(newPrecisionModel),
76  bufParams(nBufParams)
77  {}
78 
84  const BufferParameters&
86  {
87  return bufParams;
88  }
89 
102  bool isLineOffsetEmpty(double distance);
103 
117  double distance,
118  std::vector<geom::CoordinateSequence*>& lineList);
119 
139  double distance, std::vector<geom::CoordinateSequence*>& lineList,
140  bool leftSide, bool rightSide) ;
141 
152  void getRingCurve(const geom::CoordinateSequence* inputPts, int side,
153  double distance,
154  std::vector<geom::CoordinateSequence*>& lineList);
155 
156  void getOffsetCurve(const geom::CoordinateSequence* inputPts,
157  double p_distance,
158  std::vector<geom::CoordinateSequence*>& lineList);
159 
160 private:
161 
162  double distance;
163 
164  const geom::PrecisionModel* precisionModel;
165 
166  const BufferParameters& bufParams;
167 
175  static const double SIMPLIFY_FACTOR; // 100.0;
176 
184  double simplifyTolerance(double bufDistance);
185 
186  void computeLineBufferCurve(const geom::CoordinateSequence& inputPts,
187  OffsetSegmentGenerator& segGen);
188 
189  void computeSingleSidedBufferCurve(const geom::CoordinateSequence& inputPts,
190  bool isRightSide,
191  OffsetSegmentGenerator& segGen);
192 
193  void computeRingBufferCurve(const geom::CoordinateSequence& inputPts,
194  int side, OffsetSegmentGenerator& segGen);
195 
196  std::unique_ptr<OffsetSegmentGenerator> getSegGen(double dist);
197 
198  void computePointCurve(const geom::Coordinate& pt,
199  OffsetSegmentGenerator& segGen);
200 
201 
202 
203  // Declare type as noncopyable
204  OffsetCurveBuilder(const OffsetCurveBuilder& other) = delete;
205  OffsetCurveBuilder& operator=(const OffsetCurveBuilder& rhs) = delete;
206 };
207 
208 } // namespace geos::operation::buffer
209 } // namespace geos::operation
210 } // namespace geos
211 
212 #ifdef _MSC_VER
213 #pragma warning(pop)
214 #endif
215 
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:44
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:90
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:61
void getLineCurve(const geom::CoordinateSequence *inputPts, double distance, std::vector< geom::CoordinateSequence * > &lineList)
This method handles single points as well as lines.
void getRingCurve(const geom::CoordinateSequence *inputPts, int side, double distance, std::vector< geom::CoordinateSequence * > &lineList)
This method handles the degenerate cases of single points and lines, as well as rings.
const BufferParameters & getBufferParameters() const
Gets the buffer parameters being used to generate the curve.
Definition: OffsetCurveBuilder.h:85
void getSingleSidedLineCurve(const geom::CoordinateSequence *inputPts, double distance, std::vector< geom::CoordinateSequence * > &lineList, bool leftSide, bool rightSide)
This method handles single points as well as lines.
Definition: OffsetSegmentGenerator.h:60
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25