GEOS 3.13.1
geos::operation::overlayng::OverlayNG Class Reference

#include <OverlayNG.h>

Public Member Functions

 OverlayNG (const geom::Geometry *geom0, const geom::Geometry *geom1, const geom::GeometryFactory *p_geomFact, int p_opCode)
 OverlayNG (const geom::Geometry *geom0, const geom::Geometry *geom1, const geom::PrecisionModel *p_pm, int p_opCode)
 OverlayNG (const geom::Geometry *geom0, const geom::Geometry *geom1, int p_opCode)
 OverlayNG (const geom::Geometry *geom0, const geom::PrecisionModel *p_pm)
void setOptimized (bool p_isOptimized)
void setStrictMode (bool p_isStrictMode)
void setAreaResultOnly (bool p_areaResultOnly)
void setOutputEdges (bool p_isOutputEdges)
void setOutputResultEdges (bool p_isOutputResultEdges)
void setNoder (noding::Noder *p_noder)
void setOutputNodedEdges (bool p_isOutputNodedEdges)
std::unique_ptr< GeometrygetResult ()

Static Public Member Functions

static bool isResultOfOpPoint (const OverlayLabel *label, int opCode)
static bool isResultOfOp (int overlayOpCode, Location loc0, Location loc1)
static std::unique_ptr< Geometryoverlay (const Geometry *geom0, const Geometry *geom1, int opCode, const PrecisionModel *pm)
static std::unique_ptr< Geometryoverlay (const Geometry *geom0, const Geometry *geom1, int opCode, const PrecisionModel *pm, noding::Noder *noder)
static std::unique_ptr< Geometryoverlay (const Geometry *geom0, const Geometry *geom1, int opCode, noding::Noder *noder)
static std::unique_ptr< Geometryoverlay (const Geometry *geom0, const Geometry *geom1, int opCode)
static std::unique_ptr< Geometrygeomunion (const Geometry *geom, const PrecisionModel *pm)
static std::unique_ptr< Geometrygeomunion (const Geometry *geom, const PrecisionModel *pm, noding::Noder *noder)

Static Public Attributes

static constexpr bool STRICT_MODE_DEFAULT = false
static constexpr int INTERSECTION = 1
static constexpr int UNION = 2
static constexpr int DIFFERENCE = 3
static constexpr int SYMDIFFERENCE = 4

Detailed Description

Computes the geometric overlay of two geom::Geometrys, using an explicit precision model to allow robust computation. The overlay can be used to determine any of the following set-theoretic operations (boolean combinations) of the geometries:

  • INTERSECTION - all points which lie in both geometries
  • UNION - all points which lie in at least one geometry
  • DIFFERENCE - all points which lie in the first geometry but not the second
  • SYMDIFFERENCE - all points which lie in one geometry but not both

The requirements for overlay input are:

  • Input collections must be homogeneous (all elements must have the same dimension).
  • Inputs may be simple link GeometryCollections. A GeometryCollection is simple if it can be flattened into a valid Multi-geometry; i.e. it is homogeneous and does not contain any overlapping Polygons.
  • In general, inputs must be valid geometries. However, polygonal inputs may contain the following two kinds of "mild" invalid topology: (i) rings which self-touch at discrete points (sometimes called inverted shells and exverted holes). (ii) rings which touch along line segments (i.e. topology collapse).

The precision model used for the computation can be supplied independent of the precision model of the input geometry. The main use for this is to allow using a fixed precision for geometry with a floating precision model. This does two things: ensures robust computation; and forces the output to be validly rounded to the precision model.

For fixed precision models noding is performed using a noding::snapround::SnapRoundingNoder. This provides robust computation (as long as precision is limited to around 13 decimal digits).

For floating precision an noding::MCIndexNoder is used. This is not fully robust, so can sometimes result in util::TopologyExceptions being thrown. For robust full-precision overlay see OverlayNGRobust.

Note: If a noding::snap::SnappingNoder is used it is best to specify a fairly small snap tolerance, since the intersection clipping optimization can interact with the snapping to alter the result.

Optionally the overlay computation can process using strict mode (via setStrictMode(boolean). In strict mode result semantics are:

  • Lines and Points resulting from topology collapses are not included in the result
  • Result geometry is homogeneous for the INTERSECTION and DIFFERENCE operations.
  • Result geometry is homogeneous for the UNION and SYMDIFFERENCE operations if the inputs have the same dimension.

Strict mode has the following benefits:

  • Results are simpler
  • Overlay operations are chainable without needing to remove lower-dimension elements

The original JTS overlay semantics correspond to non-strict mode.

If a robustness error occurs, a TopologyException is thrown. These are usually caused by numerical rounding causing the noding output to not be fully noded. For robust computation with full-precision OverlayNGRobust can be used.

Author
mdavis
See also
OverlayNGRobust

Constructor & Destructor Documentation

◆ OverlayNG() [1/3]

geos::operation::overlayng::OverlayNG::OverlayNG ( const geom::Geometry * geom0,
const geom::Geometry * geom1,
const geom::GeometryFactory * p_geomFact,
int p_opCode )
inline

Creates an overlay operation on the given geometries, with a defined precision model. The noding strategy is determined by the precision model.

References STRICT_MODE_DEFAULT.

Referenced by OverlayNG().

◆ OverlayNG() [2/3]

geos::operation::overlayng::OverlayNG::OverlayNG ( const geom::Geometry * geom0,
const geom::Geometry * geom1,
const geom::PrecisionModel * p_pm,
int p_opCode )
inline

Creates an overlay operation on the given geometries, with a defined precision model. The noding strategy is determined by the precision model.

References STRICT_MODE_DEFAULT.

◆ OverlayNG() [3/3]

geos::operation::overlayng::OverlayNG::OverlayNG ( const geom::Geometry * geom0,
const geom::Geometry * geom1,
int p_opCode )
inline

Creates an overlay operation on the given geometries using the precision model of the geometries.

The noder is chosen according to the precision model specified.

References OverlayNG().

Member Function Documentation

◆ geomunion() [1/2]

std::unique_ptr< Geometry > geos::operation::overlayng::OverlayNG::geomunion ( const Geometry * geom,
const PrecisionModel * pm )
static

Computes a union operation on the given geometry, with the supplied precision model. The primary use for this is to perform precision reduction (round the geometry to the supplied precision).

The input must be a valid geometry. Collections must be homogeneous. IMPORTANT: You probably want OverlayNGUnaryUnion, not this.

Parameters
geomthe geometry
pmthe precision model to use
Returns
the result of the union operation
See also
OverlayMixedPoints
PrecisionReducer
UnaryUnionNG
CoverageUnion

◆ geomunion() [2/2]

std::unique_ptr< Geometry > geos::operation::overlayng::OverlayNG::geomunion ( const Geometry * geom,
const PrecisionModel * pm,
noding::Noder * noder )
static

Computes a union of a single geometry using a custom noder.

The primary use of this is to support coverage union.

The input must be a valid geometry. Collections must be homogeneous. IMPORTANT: You probably want OverlayNGUnaryUnion, not this.

Parameters
geomthe geometry to union
pmthe precision model to use (maybe be null)
noderthe noder to use
Returns
the result geometry
See also
CoverageUnion

◆ getResult()

std::unique_ptr< Geometry > geos::operation::overlayng::OverlayNG::getResult ( )

Gets the result of the overlay operation.

Returns
the result of the overlay operation.
Exceptions
IllegalArgumentExceptionif the input is not supported (e.g. a mixed-dimension geometry)
TopologyExceptionif a robustness error occurs

◆ isResultOfOp()

bool geos::operation::overlayng::OverlayNG::isResultOfOp ( int overlayOpCode,
Location loc0,
Location loc1 )
static

Tests whether a point with given geom::Locations relative to two geometries would be contained in the result of overlaying the geometries using a given overlay operation. This is used to determine whether components computed during the overlay process should be included in the result geometry.

The method handles arguments of geom::Location::NONE correctly.

◆ isResultOfOpPoint()

bool geos::operation::overlayng::OverlayNG::isResultOfOpPoint ( const OverlayLabel * label,
int opCode )
static

Tests whether a point with a given topological OverlayLabel relative to two geometries is contained in the result of overlaying the geometries using a given overlay operation.

The method handles arguments of geom::Location::NONE correctly

◆ overlay() [1/4]

std::unique_ptr< Geometry > geos::operation::overlayng::OverlayNG::overlay ( const Geometry * geom0,
const Geometry * geom1,
int opCode )
static

Computes an overlay operation on the given geometry operands, using the precision model of the geometry. and an appropriate noder.

The noder is chosen according to the precision model specified.

Parameters
geom0the first argument geometry
geom1the second argument geometry
opCodethe code for the desired overlay operation
Returns
the result of the overlay operation

◆ overlay() [2/4]

std::unique_ptr< Geometry > geos::operation::overlayng::OverlayNG::overlay ( const Geometry * geom0,
const Geometry * geom1,
int opCode,
const PrecisionModel * pm )
static

Computes an overlay operation for the given geometry operands, with the noding strategy determined by the precision model.

Parameters
geom0the first geometry argument
geom1the second geometry argument
opCodethe code for the desired overlay operation
pmthe precision model to use
Returns
the result of the overlay operation

Referenced by geos::operation::overlayng::UnaryUnionNG::NGUnionStrategy::Union().

◆ overlay() [3/4]

std::unique_ptr< Geometry > geos::operation::overlayng::OverlayNG::overlay ( const Geometry * geom0,
const Geometry * geom1,
int opCode,
const PrecisionModel * pm,
noding::Noder * noder )
static

Computes an overlay operation on the given geometry operands, using a supplied noding::Noder.

Parameters
geom0the first geometry argument
geom1the second geometry argument
opCodethe code for the desired overlay operation
pmthe precision model to use (which may be null if the noder does not use one)
noderthe noder to use
Returns
the result of the overlay operation

◆ overlay() [4/4]

std::unique_ptr< Geometry > geos::operation::overlayng::OverlayNG::overlay ( const Geometry * geom0,
const Geometry * geom1,
int opCode,
noding::Noder * noder )
static

Computes an overlay operation on the given geometry operands, using a supplied noding::Noder.

Parameters
geom0the first geometry argument
geom1the second geometry argument
opCodethe code for the desired overlay operation
noderthe noder to use
Returns
the result of the overlay operation

◆ setOptimized()

void geos::operation::overlayng::OverlayNG::setOptimized ( bool p_isOptimized)
inline

Sets whether overlay processing optimizations are enabled. It may be useful to disable optimizations for testing purposes. Default is TRUE (optimization enabled).

Parameters
p_isOptimizedwhether to optimize processing

Member Data Documentation

◆ STRICT_MODE_DEFAULT

bool geos::operation::overlayng::OverlayNG::STRICT_MODE_DEFAULT = false
staticconstexpr

The default setting for Strict Mode.

The original JTS overlay semantics used non-strict result semantics, including;

  • An Intersection result can be mixed-dimension, due to inclusion of intersection components of all dimensions
  • Results can include lines caused by Area topology collapse

Referenced by OverlayNG(), and OverlayNG().


The documentation for this class was generated from the following file: