GEOS  3.9.1dev
BufferOp.h
Go to the documentation of this file.
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 
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 
111 
113 
114  double distance;
115 
116  //int quadrantSegments;
117  //int endCapStyle;
119 
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 {
137  CAP_ROUND = BufferParameters::CAP_ROUND,
138 
141  CAP_BUTT = BufferParameters::CAP_FLAT,
142 
145  CAP_SQUARE = BufferParameters::CAP_SQUARE
146  };
147 
160  static geom::Geometry* bufferOp(const geom::Geometry* g,
161  double distance,
162  int quadrantSegments =
163  BufferParameters::DEFAULT_QUADRANT_SEGMENTS,
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
247 BufferOp::setQuadrantSegments(int q)
248 {
249  bufParams.setQuadrantSegments(q);
250 }
251 
252 void
253 BufferOp::setEndCapStyle(int s)
254 {
255  bufParams.setEndCapStyle((BufferParameters::EndCapStyle)s);
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 
BufferOp(const geom::Geometry *g)
Initializes a buffer computation for the given geometry.
Definition: BufferOp.h:171
#define GEOS_DLL
Definition: export.h:28
Specifies the precision model of the Coordinate in a Geometry.
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
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
Computes the buffer of a geometry, for both positive and negative buffer distances.
Definition: BufferOp.h:78
const geom::Geometry * argGeom
Definition: BufferOp.h:110
Basic namespace for all GEOS functionalities.
Contains the parameters which describe how a buffer should be constructed.
geom::Geometry * resultGeometry
Definition: BufferOp.h:120
Indicates an invalid or inconsistent topological situation encountered during processing.
util::TopologyException saveException
Definition: BufferOp.h:112