GEOS  3.9.1dev
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
geos::operation::overlay::PolygonBuilder Class Reference

Forms Polygon out of a graph of geomgraph::DirectedEdge. More...

#include <PolygonBuilder.h>

Collaboration diagram for geos::operation::overlay::PolygonBuilder:
[legend]

Classes

struct  FastPIPRing
 

Public Member Functions

 PolygonBuilder (const geom::GeometryFactory *newGeometryFactory)
 
 ~PolygonBuilder ()
 
void add (geomgraph::PlanarGraph *graph)
 
void add (const std::vector< geomgraph::DirectedEdge * > *dirEdges, const std::vector< geomgraph::Node * > *nodes)
 
std::vector< geom::Geometry * > * getPolygons ()
 

Private Member Functions

void buildMaximalEdgeRings (const std::vector< geomgraph::DirectedEdge * > *dirEdges, std::vector< MaximalEdgeRing * > &maxEdgeRings)
 
void buildMinimalEdgeRings (std::vector< MaximalEdgeRing * > &maxEdgeRings, std::vector< geomgraph::EdgeRing * > &newShellList, std::vector< geomgraph::EdgeRing * > &freeHoleList, std::vector< MaximalEdgeRing * > &edgeRings)
 
geomgraph::EdgeRingfindShell (std::vector< MinimalEdgeRing * > *minEdgeRings)
 
void placePolygonHoles (geomgraph::EdgeRing *shell, std::vector< MinimalEdgeRing * > *minEdgeRings)
 
void sortShellsAndHoles (std::vector< MaximalEdgeRing * > &edgeRings, std::vector< geomgraph::EdgeRing * > &newShellList, std::vector< geomgraph::EdgeRing * > &freeHoleList)
 
void placeFreeHoles (std::vector< FastPIPRing > &newShellList, std::vector< geomgraph::EdgeRing * > &freeHoleList)
 This method determines finds a containing shell for all holes which have not yet been assigned to a shell. More...
 
geomgraph::EdgeRingfindEdgeRingContaining (geomgraph::EdgeRing *testEr, std::vector< FastPIPRing > &newShellList)
 Find the innermost enclosing shell geomgraph::EdgeRing containing the argument geomgraph::EdgeRing, if any. More...
 
std::vector< geom::Geometry * > * computePolygons (std::vector< geomgraph::EdgeRing * > &newShellList)
 

Private Attributes

const geom::GeometryFactorygeometryFactory
 
std::vector< geomgraph::EdgeRing * > shellList
 

Detailed Description

Forms Polygon out of a graph of geomgraph::DirectedEdge.

The edges to use are marked as being in the result Area.

Definition at line 62 of file PolygonBuilder.h.

Constructor & Destructor Documentation

geos::operation::overlay::PolygonBuilder::PolygonBuilder ( const geom::GeometryFactory newGeometryFactory)
geos::operation::overlay::PolygonBuilder::~PolygonBuilder ( )

Member Function Documentation

void geos::operation::overlay::PolygonBuilder::add ( geomgraph::PlanarGraph graph)

Add a complete graph. The graph is assumed to contain one or more polygons, possibly with holes.

void geos::operation::overlay::PolygonBuilder::add ( const std::vector< geomgraph::DirectedEdge * > *  dirEdges,
const std::vector< geomgraph::Node * > *  nodes 
)

Add a set of edges and nodes, which form a graph. The graph is assumed to contain one or more polygons, possibly with holes.

void geos::operation::overlay::PolygonBuilder::buildMaximalEdgeRings ( const std::vector< geomgraph::DirectedEdge * > *  dirEdges,
std::vector< MaximalEdgeRing * > &  maxEdgeRings 
)
private

For all DirectedEdges in result, form them into MaximalEdgeRings

Parameters
maxEdgeRingsFormed MaximalEdgeRings will be pushed to this vector. Ownership of the elements is transferred to caller.
void geos::operation::overlay::PolygonBuilder::buildMinimalEdgeRings ( std::vector< MaximalEdgeRing * > &  maxEdgeRings,
std::vector< geomgraph::EdgeRing * > &  newShellList,
std::vector< geomgraph::EdgeRing * > &  freeHoleList,
std::vector< MaximalEdgeRing * > &  edgeRings 
)
private
std::vector<geom::Geometry*>* geos::operation::overlay::PolygonBuilder::computePolygons ( std::vector< geomgraph::EdgeRing * > &  newShellList)
private
geomgraph::EdgeRing* geos::operation::overlay::PolygonBuilder::findEdgeRingContaining ( geomgraph::EdgeRing testEr,
std::vector< FastPIPRing > &  newShellList 
)
private

Find the innermost enclosing shell geomgraph::EdgeRing containing the argument geomgraph::EdgeRing, if any.

The innermost enclosing ring is the smallest enclosing ring. The algorithm used depends on the fact that:

ring A contains ring B iff envelope(ring A) contains envelope(ring B)

This routine is only safe to use if the chosen point of the hole is known to be properly contained in a shell (which is guaranteed to be the case if the hole does not touch its shell)

Returns
containing geomgraph::EdgeRing, if there is one
NULL if no containing geomgraph::EdgeRing is found
geomgraph::EdgeRing* geos::operation::overlay::PolygonBuilder::findShell ( std::vector< MinimalEdgeRing * > *  minEdgeRings)
private

This method takes a list of MinimalEdgeRings derived from a MaximalEdgeRing, and tests whether they form a Polygon. This is the case if there is a single shell in the list. In this case the shell is returned. The other possibility is that they are a series of connected holes, in which case no shell is returned.

Returns
the shell geomgraph::EdgeRing, if there is one
NULL, if all the rings are holes
std::vector<geom::Geometry*>* geos::operation::overlay::PolygonBuilder::getPolygons ( )
void geos::operation::overlay::PolygonBuilder::placeFreeHoles ( std::vector< FastPIPRing > &  newShellList,
std::vector< geomgraph::EdgeRing * > &  freeHoleList 
)
private

This method determines finds a containing shell for all holes which have not yet been assigned to a shell.

These "free" holes should all be properly contained in their parent shells, so it is safe to use the findEdgeRingContaining method. This is the case because any holes which are NOT properly contained (i.e. are connected to their parent shell) would have formed part of a MaximalEdgeRing and been handled in a previous step.

Exceptions
TopologyExceptionif a hole cannot be assigned to a shell
void geos::operation::overlay::PolygonBuilder::placePolygonHoles ( geomgraph::EdgeRing shell,
std::vector< MinimalEdgeRing * > *  minEdgeRings 
)
private

This method assigns the holes for a Polygon (formed from a list of MinimalEdgeRings) to its shell. Determining the holes for a MinimalEdgeRing polygon serves two purposes:

  • it is faster than using a point-in-polygon check later on.
  • it ensures correctness, since if the PIP test was used the point chosen might lie on the shell, which might return an incorrect result from the PIP test
void geos::operation::overlay::PolygonBuilder::sortShellsAndHoles ( std::vector< MaximalEdgeRing * > &  edgeRings,
std::vector< geomgraph::EdgeRing * > &  newShellList,
std::vector< geomgraph::EdgeRing * > &  freeHoleList 
)
private

For all rings in the input list, determine whether the ring is a shell or a hole and add it to the appropriate list. Due to the way the DirectedEdges were linked, a ring is a shell if it is oriented CW, a hole otherwise.

Member Data Documentation

const geom::GeometryFactory* geos::operation::overlay::PolygonBuilder::geometryFactory
private

Definition at line 90 of file PolygonBuilder.h.

std::vector<geomgraph::EdgeRing*> geos::operation::overlay::PolygonBuilder::shellList
private

Definition at line 92 of file PolygonBuilder.h.


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