GEOS  3.8.0dev
BufferOp.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) 2005-2007 Refractions Research Inc.
8  * Copyright (C) 2001-2002 Vivid Solutions Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU Lesser General Public Licence as published
12  * by the Free Software Foundation.
13  * See the COPYING file for more information.
14  *
15  **********************************************************************
16  *
17  * Last port: operation/buffer/BufferOp.java r378 (JTS-1.12)
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_OP_BUFFER_BUFFEROP_H
22 #define GEOS_OP_BUFFER_BUFFEROP_H
23 
24 #include <geos/export.h>
25 #include <geos/operation/buffer/BufferParameters.h> // for enum values
26 
27 #include <geos/util/TopologyException.h> // for composition
28 
29 #ifdef _MSC_VER
30 #pragma warning(push)
31 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
32 #endif
33 
34 // Forward declarations
35 namespace geos {
36 namespace geom {
37 class PrecisionModel;
38 class Geometry;
39 }
40 }
41 
42 namespace geos {
43 namespace operation { // geos.operation
44 namespace buffer { // geos.operation.buffer
45 
78 class GEOS_DLL BufferOp {
79 
80 
81 private:
82 
89  static const int MAX_PRECISION_DIGITS = 12;
90 
107  static double precisionScaleFactor(const geom::Geometry* g,
108  double distance, int maxPrecisionDigits);
109 
110  const geom::Geometry* argGeom;
111 
112  util::TopologyException saveException;
113 
114  double distance;
115 
116  //int quadrantSegments;
117  //int endCapStyle;
118  BufferParameters bufParams;
119 
120  geom::Geometry* resultGeometry;
121 
122  void computeGeometry();
123 
124  void bufferOriginalPrecision();
125 
126  void bufferReducedPrecision(int precisionDigits);
127 
128  void bufferReducedPrecision();
129 
130  void bufferFixedPrecision(const geom::PrecisionModel& fixedPM);
131 
132 public:
133 
134  enum {
138 
142 
146  };
147 
160  static geom::Geometry* bufferOp(const geom::Geometry* g,
161  double distance,
162  int quadrantSegments =
164  int endCapStyle = BufferParameters::CAP_ROUND);
165 
172  :
173  argGeom(g),
174  bufParams(),
175  resultGeometry(nullptr)
176  {
177  }
178 
187  BufferOp(const geom::Geometry* g, const BufferParameters& params)
188  :
189  argGeom(g),
190  bufParams(params),
191  resultGeometry(nullptr)
192  {
193  }
194 
203  inline void setEndCapStyle(int nEndCapStyle);
204 
210  inline void setQuadrantSegments(int nQuadrantSegments);
211 
232  inline void setSingleSided(bool isSingleSided);
233 
241  geom::Geometry* getResultGeometry(double nDistance);
242 
243 };
244 
245 // BufferOp inlines
246 void
248 {
249  bufParams.setQuadrantSegments(q);
250 }
251 
252 void
254 {
256 }
257 
258 void
259 BufferOp::setSingleSided(bool isSingleSided)
260 {
261  bufParams.setSingleSided(isSingleSided);
262 }
263 
264 } // namespace geos::operation::buffer
265 } // namespace geos::operation
266 } // namespace geos
267 
268 #ifdef _MSC_VER
269 #pragma warning(pop)
270 #endif
271 
272 #endif // ndef GEOS_OP_BUFFER_BUFFEROP_H
273 
EndCapStyle
End cap styles.
Definition: BufferParameters.h:62
BufferOp(const geom::Geometry *g)
Initializes a buffer computation for the given geometry.
Definition: BufferOp.h:171
void setSingleSided(bool p_isSingleSided)
Definition: BufferParameters.h:281
void setQuadrantSegments(int quadSegs)
Sets the number of line segments used to approximate an angle fillet.
void setQuadrantSegments(int nQuadrantSegments)
Sets the number of segments used to approximate a angle fillet.
Definition: BufferOp.h:247
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Specifies a round line buffer end cap style.
Definition: BufferParameters.h:65
void setEndCapStyle(int nEndCapStyle)
Specifies the end cap style of the generated buffer.
Definition: BufferOp.h:253
void setEndCapStyle(EndCapStyle style)
Specifies the end cap style of the generated buffer.
Definition: BufferParameters.h:204
Specifies a flat line buffer end cap style.
Definition: BufferParameters.h:68
BufferOp(const geom::Geometry *g, const BufferParameters &params)
Initializes a buffer computation for the given geometry with the given set of parameters.
Definition: BufferOp.h:187
Specifies a square line buffer end cap style.
Definition: BufferParameters.h:71
Computes the buffer of a geometry, for both positive and negative buffer distances.
Definition: BufferOp.h:78
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Contains the parameters which describe how a buffer should be constructed.
Definition: BufferParameters.h:57
static const int DEFAULT_QUADRANT_SEGMENTS
The default number of facets into which to divide a fillet of 90 degrees.
Definition: BufferParameters.h:95
Indicates an invalid or inconsistent topological situation encountered during processing.
Definition: TopologyException.h:35
void setSingleSided(bool isSingleSided)
Sets whether the computed buffer should be single-sided.
Definition: BufferOp.h:259