GEOS 3.9.1
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
35namespace geos {
36namespace geom {
37class PrecisionModel;
38class Geometry;
39}
40}
41
42namespace geos {
43namespace operation { // geos.operation
44namespace buffer { // geos.operation.buffer
45
78class GEOS_DLL BufferOp {
79
80
81private:
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
132public:
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
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
242
243};
244
245// BufferOp inlines
246void
248{
249 bufParams.setQuadrantSegments(q);
250}
251
252void
254{
256}
257
258void
259BufferOp::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
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
Computes the buffer of a geometry, for both positive and negative buffer distances.
Definition: BufferOp.h:78
void setQuadrantSegments(int nQuadrantSegments)
Sets the number of segments used to approximate a angle fillet.
Definition: BufferOp.h:247
static geom::Geometry * bufferOp(const geom::Geometry *g, double distance, int quadrantSegments=BufferParameters::DEFAULT_QUADRANT_SEGMENTS, int endCapStyle=BufferParameters::CAP_ROUND)
Computes the buffer for a geometry for a given buffer distance and accuracy of approximation.
void setEndCapStyle(int nEndCapStyle)
Specifies the end cap style of the generated buffer.
Definition: BufferOp.h:253
void setSingleSided(bool isSingleSided)
Sets whether the computed buffer should be single-sided.
Definition: BufferOp.h:259
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
BufferOp(const geom::Geometry *g)
Initializes a buffer computation for the given geometry.
Definition: BufferOp.h:171
geom::Geometry * getResultGeometry(double nDistance)
Returns the buffer computed for a geometry for a given buffer distance.
Contains the parameters which describe how a buffer should be constructed.
Definition: BufferParameters.h:57
void setEndCapStyle(EndCapStyle style)
Definition: BufferParameters.h:202
EndCapStyle
End cap styles.
Definition: BufferParameters.h:62
void setQuadrantSegments(int quadSegs)
Sets the number of line segments used to approximate an angle fillet.
void setSingleSided(bool p_isSingleSided)
Definition: BufferParameters.h:279
Indicates an invalid or inconsistent topological situation encountered during processing.
Definition: TopologyException.h:35
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26