GEOS  3.9.1dev
Public Member Functions | Private Member Functions | Private Attributes | List of all members
geos::operation::geounion::OverlapUnion Class Reference

Unions MultiPolygons efficiently by using full topological union only for polygons which may overlap by virtue of intersecting the common area of the inputs. More...

#include <OverlapUnion.h>

Collaboration diagram for geos::operation::geounion::OverlapUnion:
[legend]

Public Member Functions

 OverlapUnion (const geom::Geometry *p_g0, const geom::Geometry *p_g1, geounion::UnionStrategy *unionFun)
 
 OverlapUnion (const geom::Geometry *p_g0, const geom::Geometry *p_g1)
 
std::unique_ptr< geom::GeometrydoUnion ()
 

Private Member Functions

geom::Envelope overlapEnvelope (const geom::Geometry *geom0, const geom::Geometry *geom1)
 
std::unique_ptr< geom::GeometryextractByEnvelope (const geom::Envelope &env, const geom::Geometry *geom, std::vector< std::unique_ptr< geom::Geometry >> &disjointGeoms)
 
std::unique_ptr< geom::Geometrycombine (std::unique_ptr< geom::Geometry > &unionGeom, std::vector< std::unique_ptr< geom::Geometry >> &disjointPolys)
 
std::unique_ptr< geom::GeometryunionFull (const geom::Geometry *geom0, const geom::Geometry *geom1)
 
std::unique_ptr< geom::GeometryunionBuffer (const geom::Geometry *geom0, const geom::Geometry *geom1)
 
bool isBorderSegmentsSame (const geom::Geometry *result, const geom::Envelope &env)
 
bool isEqual (std::vector< geom::LineSegment > &segs0, std::vector< geom::LineSegment > &segs1)
 
std::vector< geom::LineSegmentextractBorderSegments (const geom::Geometry *geom0, const geom::Geometry *geom1, const geom::Envelope &env)
 
void extractBorderSegments (const geom::Geometry *geom, const geom::Envelope &penv, std::vector< geom::LineSegment > &psegs)
 

Private Attributes

const geom::Geometryg0
 
const geom::Geometryg1
 
geounion::UnionStrategyunionFunction
 
const geom::GeometryFactorygeomFactory
 
bool isUnionSafe
 
geounion::ClassicUnionStrategy defaultUnionFunction
 

Detailed Description

Unions MultiPolygons efficiently by using full topological union only for polygons which may overlap by virtue of intersecting the common area of the inputs.

Other polygons are simply combined with the union result, which is much more performant.

This situation is likely to occur during cascaded polygon union, since the partitioning of polygons is done heuristically and thus may group disjoint polygons which can lie far apart. It may also occur in real world data which contains many disjoint polygons (e.g. polygons representing parcels on different street blocks).

Algorithm

The overlap region is determined as the common envelope of intersection. The input polygons are partitioned into two sets:

The Overlapping set is fully unioned, and then combined with the Disjoint set. Performing a simple combine works because the disjoint polygons do not interact with each other (since the inputs are valid MultiPolygons). They also do not interact with the Overlapping polygons, since they are outside their envelope.

Verification

In the general case the Overlapping set of polygons will extend beyond the overlap envelope. This means that the union result will extend beyond the overlap region. There is a small chance that the topological union of the overlap region will shift the result linework enough that the result geometry intersects one of the Disjoint geometries. This case is detected and if it occurs is remedied by falling back to performing a full union of the original inputs. Detection is done by a fairly efficient comparison of edge segments which extend beyond the overlap region. If any segments have changed then there is a risk of introduced intersections, and full union is performed.

This situation has not been observed in JTS using floating precision, but it could happen due to snapping. It has been observed in other APIs (e.g. GEOS) due to more aggressive snapping. And it will be more likely to happen if a snap-rounding overlay is used.

DEPRECATED: This optimization has been removed, since it impairs performance.

Author
mbdavis

Definition at line 97 of file OverlapUnion.h.

Constructor & Destructor Documentation

geos::operation::geounion::OverlapUnion::OverlapUnion ( const geom::Geometry p_g0,
const geom::Geometry p_g1,
geounion::UnionStrategy unionFun 
)
inline

Definition at line 101 of file OverlapUnion.h.

geos::operation::geounion::OverlapUnion::OverlapUnion ( const geom::Geometry p_g0,
const geom::Geometry p_g1 
)
inline

Definition at line 109 of file OverlapUnion.h.

Member Function Documentation

std::unique_ptr<geom::Geometry> geos::operation::geounion::OverlapUnion::combine ( std::unique_ptr< geom::Geometry > &  unionGeom,
std::vector< std::unique_ptr< geom::Geometry >> &  disjointPolys 
)
private
std::unique_ptr<geom::Geometry> geos::operation::geounion::OverlapUnion::doUnion ( )
std::vector<geom::LineSegment> geos::operation::geounion::OverlapUnion::extractBorderSegments ( const geom::Geometry geom0,
const geom::Geometry geom1,
const geom::Envelope env 
)
private
void geos::operation::geounion::OverlapUnion::extractBorderSegments ( const geom::Geometry geom,
const geom::Envelope penv,
std::vector< geom::LineSegment > &  psegs 
)
private
std::unique_ptr<geom::Geometry> geos::operation::geounion::OverlapUnion::extractByEnvelope ( const geom::Envelope env,
const geom::Geometry geom,
std::vector< std::unique_ptr< geom::Geometry >> &  disjointGeoms 
)
private
bool geos::operation::geounion::OverlapUnion::isBorderSegmentsSame ( const geom::Geometry result,
const geom::Envelope env 
)
private
bool geos::operation::geounion::OverlapUnion::isEqual ( std::vector< geom::LineSegment > &  segs0,
std::vector< geom::LineSegment > &  segs1 
)
private
geom::Envelope geos::operation::geounion::OverlapUnion::overlapEnvelope ( const geom::Geometry geom0,
const geom::Geometry geom1 
)
private
std::unique_ptr<geom::Geometry> geos::operation::geounion::OverlapUnion::unionBuffer ( const geom::Geometry geom0,
const geom::Geometry geom1 
)
private
std::unique_ptr<geom::Geometry> geos::operation::geounion::OverlapUnion::unionFull ( const geom::Geometry geom0,
const geom::Geometry geom1 
)
private

Member Data Documentation

geounion::ClassicUnionStrategy geos::operation::geounion::OverlapUnion::defaultUnionFunction
private

Definition at line 124 of file OverlapUnion.h.

const geom::Geometry* geos::operation::geounion::OverlapUnion::g0
private

Definition at line 118 of file OverlapUnion.h.

const geom::Geometry* geos::operation::geounion::OverlapUnion::g1
private

Definition at line 119 of file OverlapUnion.h.

const geom::GeometryFactory* geos::operation::geounion::OverlapUnion::geomFactory
private

Definition at line 121 of file OverlapUnion.h.

bool geos::operation::geounion::OverlapUnion::isUnionSafe
private

Definition at line 122 of file OverlapUnion.h.

geounion::UnionStrategy* geos::operation::geounion::OverlapUnion::unionFunction
private

Definition at line 120 of file OverlapUnion.h.


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