BufferCurveSetBuilder.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
* Copyright (C) 2006 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: operation/buffer/BufferCurveSetBuilder.java 4c343e79f (JTS-1.19)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/geom/Location.h>
#include <geos/operation/buffer/OffsetCurveBuilder.h>
#include <vector>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
// Forward declarations
namespace geos {
namespace geom {
class Geometry;
class CoordinateSequence;
class PrecisionModel;
class GeometryCollection;
class Point;
class LineString;
class LinearRing;
class Polygon;
}
namespace geomgraph {
class Label;
}
namespace noding {
class SegmentString;
}
namespace operation {
namespace buffer {
class BufferParameters;
}
}
}
namespace geos {
namespace operation { // geos.operation
namespace buffer { // geos.operation.buffer
class GEOS_DLL BufferCurveSetBuilder {
using CoordinateSequence = geos::geom::CoordinateSequence;
using Envelope = geos::geom::Envelope;
private:
static constexpr int MAX_INVERTED_RING_SIZE = 9;
static constexpr int INVERTED_CURVE_VERTEX_FACTOR = 4;
static constexpr double NEARNESS_FACTOR = 0.99;
// To keep track of newly-created Labels.
// Labels will be released by object dtor
std::vector<geomgraph::Label*> newLabels;
const geom::Geometry& inputGeom;
double distance;
OffsetCurveBuilder curveBuilder;
std::vector<noding::SegmentString*> curveList;
bool isInvertOrientation = false;
void addCurve(geom::CoordinateSequence* coord, geom::Location leftLoc,
geom::Location rightLoc);
void add(const geom::Geometry& g);
void addCollection(const geom::GeometryCollection* gc);
void addPoint(const geom::Point* p);
void addLineString(const geom::LineString* line);
void addPolygon(const geom::Polygon* p);
void addLinearRingSides(const geom::CoordinateSequence* coord, double p_distance);
void addPolygonRingSide(const geom::CoordinateSequence* coord,
double offsetDistance, int side, geom::Location cwLeftLoc,
geom::Location cwRightLoc);
void addRingSide(const geom::CoordinateSequence* coord,
double offsetDistance, int side, geom::Location leftLoc,
geom::Location rightLoc);
static bool isRingCurveInverted(
const geom::CoordinateSequence* inputPts, double dist,
const geom::CoordinateSequence* curvePts);
static bool hasPointOnBuffer(
const CoordinateSequence* inputRing, double dist,
const CoordinateSequence* curveRing);
bool isRingFullyEroded(const geom::LinearRing* ring, bool isHole,
double bufferDistance);
bool isRingFullyEroded(const CoordinateSequence* ringCoord, const Envelope* env, bool isHole,
double bufferDistance);
bool isTriangleErodedCompletely(const geom::CoordinateSequence* triCoords,
double bufferDistance);
// Declare type as noncopyable
BufferCurveSetBuilder(const BufferCurveSetBuilder& other) = delete;
BufferCurveSetBuilder& operator=(const BufferCurveSetBuilder& rhs) = delete;
bool isRingCCW(const geom::CoordinateSequence* coords) const;
public:
BufferCurveSetBuilder(
const geom::Geometry& newInputGeom,
double newDistance,
const geom::PrecisionModel* newPm,
const BufferParameters& newBufParams)
: inputGeom(newInputGeom)
, distance(newDistance)
, curveBuilder(newPm, newBufParams)
, curveList()
, isInvertOrientation(false)
{};
~BufferCurveSetBuilder();
std::vector<noding::SegmentString*>& getCurves();
void addCurves(const std::vector<geom::CoordinateSequence*>& lineList,
geom::Location leftLoc, geom::Location rightLoc);
void setInvertOrientation(bool p_isInvertOrientation) {
isInvertOrientation = p_isInvertOrientation;
}
};
} // namespace geos::operation::buffer
} // namespace geos::operation
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::geom::GeometryCollection
Represents a collection of heterogeneous Geometry objects.
Definition GeometryCollection.h:51
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom::LineString
Definition LineString.h:66
geos::geom::LinearRing
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition LinearRing.h:54
geos::geom::Point
Definition Point.h:61
geos::geom::Polygon
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
geos::geom::PrecisionModel
Specifies the precision model of the Coordinate in a Geometry.
Definition PrecisionModel.h:87
geos::geomgraph::Label
A Label indicates the topological relationship of a component of a topology graph to a given Geometry...
Definition Label.h:57
geos::noding::SegmentString
An interface for classes which represent a sequence of contiguous line segments.
Definition SegmentString.h:47
geos::operation::buffer::BufferCurveSetBuilder::BufferCurveSetBuilder
BufferCurveSetBuilder(const geom::Geometry &newInputGeom, double newDistance, const geom::PrecisionModel *newPm, const BufferParameters &newBufParams)
Constructor.
Definition BufferCurveSetBuilder.h:250
geos::operation::buffer::BufferCurveSetBuilder::getCurves
std::vector< noding::SegmentString * > & getCurves()
Computes the set of raw offset curves for the buffer.
geos::operation::buffer::BufferCurveSetBuilder::~BufferCurveSetBuilder
~BufferCurveSetBuilder()
Destructor.
geos::operation::buffer::BufferCurveSetBuilder::addCurves
void addCurves(const std::vector< geom::CoordinateSequence * > &lineList, geom::Location leftLoc, geom::Location rightLoc)
Add raw curves for a set of CoordinateSequences.
geos::operation::buffer::BufferCurveSetBuilder::setInvertOrientation
void setInvertOrientation(bool p_isInvertOrientation)
Definition BufferCurveSetBuilder.h:293
geos::operation::buffer::BufferParameters
Contains the parameters which describe how a buffer should be constructed.
Definition BufferParameters.h:56
geos::operation::buffer::OffsetCurveBuilder
Computes the raw offset curve for a single Geometry component (ring, line or point).
Definition OffsetCurveBuilder.h:65
geos::geom
Definition Angle.h:26
geos::geom::Location
Location
Constants representing the location of a point relative to a geometry.
Definition Location.h:32
geos::geomgraph
Contains classes that implement topology graphs.
Definition Depth.h:31
geos::noding
Classes to compute nodings for arrangements of line segments and line segment sequences.
Definition CoverageCleaner.h:42
geos::operation::buffer
Provides classes for computing buffers of geometries.
Definition namespaces.h:182
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38