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 
159  static geom::Geometry* bufferOp(const geom::Geometry* g,
160  double distance,
161  int quadrantSegments =
163  int endCapStyle = BufferParameters::CAP_ROUND);
164 
171  :
172  argGeom(g),
173  bufParams(),
174  resultGeometry(nullptr)
175  {
176  }
177 
186  BufferOp(const geom::Geometry* g, const BufferParameters& params)
187  :
188  argGeom(g),
189  bufParams(params),
190  resultGeometry(nullptr)
191  {
192  }
193 
201  inline void setEndCapStyle(int nEndCapStyle);
202 
210  inline void setQuadrantSegments(int nQuadrantSegments);
211 
232  inline void setSingleSided(bool isSingleSided);
233 
242  geom::Geometry* getResultGeometry(double nDistance);
243 
244 };
245 
246 // BufferOp inlines
247 void
249 {
250  bufParams.setQuadrantSegments(q);
251 }
252 
253 void
255 {
257 }
258 
259 void
260 BufferOp::setSingleSided(bool isSingleSided)
261 {
262  bufParams.setSingleSided(isSingleSided);
263 }
264 
265 } // namespace geos::operation::buffer
266 } // namespace geos::operation
267 } // namespace geos
268 
269 #ifdef _MSC_VER
270 #pragma warning(pop)
271 #endif
272 
273 #endif // ndef GEOS_OP_BUFFER_BUFFEROP_H
274 
EndCapStyle
End cap styles.
Definition: BufferParameters.h:62
BufferOp(const geom::Geometry *g)
Definition: BufferOp.h:170
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)
Definition: BufferOp.h:248
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:187
Specifies a round line buffer end cap style.
Definition: BufferParameters.h:65
void setEndCapStyle(int nEndCapStyle)
Definition: BufferOp.h:254
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)
Definition: BufferOp.h:186
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)
Definition: BufferOp.h:260