GEOS  3.9.1dev
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
geos::operation::intersection::RectangleIntersectionBuilder Class Reference

Rebuild geometries from subpaths left by clipping with a rectangle. More...

#include <RectangleIntersectionBuilder.h>

Collaboration diagram for geos::operation::intersection::RectangleIntersectionBuilder:
[legend]

Public Member Functions

 ~RectangleIntersectionBuilder ()
 

Private Member Functions

std::unique_ptr< geom::Geometrybuild ()
 Build the result geometry from partial results and clean up. More...
 
void reconnectPolygons (const Rectangle &rect)
 Build polygons from parts left by clipping one. More...
 
void reconnect ()
 
void reverseLines ()
 
void release (RectangleIntersectionBuilder &parts)
 
void add (geom::Polygon *g)
 
void add (geom::LineString *g)
 
void add (geom::Point *g)
 
bool empty () const
 
void clear ()
 
void close_boundary (const Rectangle &rect, std::vector< geom::Coordinate > *ring, double x1, double y1, double x2, double y2)
 Close a ring clockwise along rectangle edges. More...
 
void close_ring (const Rectangle &rect, std::vector< geom::Coordinate > *ring)
 
 RectangleIntersectionBuilder (const geom::GeometryFactory &f)
 

Private Attributes

std::list< geom::Polygon * > polygons
 
std::list< geom::LineString * > lines
 
std::list< geom::Point * > points
 
const geom::GeometryFactory_gf
 

Friends

class RectangleIntersection
 

Detailed Description

Rebuild geometries from subpaths left by clipping with a rectangle.

The RectangleIntersectionBuilder is used to maintain lists of polygons, linestrings and points left from clipping a geom::Geometry with a Rectangle. Once all clipping has been done, the class builds a valid geom::Geometry from the components.

Note
This is a utility class needed by RectangleIntersection, and is not intended for public use.

Definition at line 63 of file RectangleIntersectionBuilder.h.

Constructor & Destructor Documentation

geos::operation::intersection::RectangleIntersectionBuilder::~RectangleIntersectionBuilder ( )
geos::operation::intersection::RectangleIntersectionBuilder::RectangleIntersectionBuilder ( const geom::GeometryFactory f)
inlineprivate

Definition at line 149 of file RectangleIntersectionBuilder.h.

Member Function Documentation

void geos::operation::intersection::RectangleIntersectionBuilder::add ( geom::Polygon g)
private
void geos::operation::intersection::RectangleIntersectionBuilder::add ( geom::LineString g)
private
void geos::operation::intersection::RectangleIntersectionBuilder::add ( geom::Point g)
private
std::unique_ptr<geom::Geometry> geos::operation::intersection::RectangleIntersectionBuilder::build ( )
private

Build the result geometry from partial results and clean up.

void geos::operation::intersection::RectangleIntersectionBuilder::clear ( )
private
void geos::operation::intersection::RectangleIntersectionBuilder::close_boundary ( const Rectangle rect,
std::vector< geom::Coordinate > *  ring,
double  x1,
double  y1,
double  x2,
double  y2 
)
private

Close a ring clockwise along rectangle edges.

Only the 4 corners and x1,y1 need to be considered. The possible cases are:

x1,y1 corner1 x1,y1 corner1 corner2 x1,y1 corner1 corner2 corner3 x1,y1 corner1 corner2 corner3 corner4 x1,y1

void geos::operation::intersection::RectangleIntersectionBuilder::close_ring ( const Rectangle rect,
std::vector< geom::Coordinate > *  ring 
)
private
bool geos::operation::intersection::RectangleIntersectionBuilder::empty ( ) const
private
void geos::operation::intersection::RectangleIntersectionBuilder::reconnect ( )
private

Reconnect disjointed parts

When we clip a LinearRing we may get multiple linestrings. Often the first and last ones can be reconnected to simplify output.

Sample clip with a rectangle 0,0 –> 10,10 without reconnecting:

Input: POLYGON ((5 10,0 0,10 0,5 10)) Output: MULTILINESTRING ((5 10,0 0),(10 0,5 10)) Desired: LINESTRING (10 0,5 10,0 0)

TODO: If there is a very sharp spike from inside the rectangle outside, and then back in, it is possible that the intersection points at the edge are equal. In this case we could reconnect the linestrings. The task is the same we're already doing for the 1st/last linestrings, we'd just do it for any adjacent pair as well.

void geos::operation::intersection::RectangleIntersectionBuilder::reconnectPolygons ( const Rectangle rect)
private

Build polygons from parts left by clipping one.

  1. Build exterior ring(s) from lines
  2. Attach polygons as holes to the exterior ring(s)
void geos::operation::intersection::RectangleIntersectionBuilder::release ( RectangleIntersectionBuilder parts)
private

Export parts to another container

void geos::operation::intersection::RectangleIntersectionBuilder::reverseLines ( )
private

Friends And Related Function Documentation

friend class RectangleIntersection
friend

Definition at line 65 of file RectangleIntersectionBuilder.h.

Member Data Documentation

const geom::GeometryFactory& geos::operation::intersection::RectangleIntersectionBuilder::_gf
private

Definition at line 152 of file RectangleIntersectionBuilder.h.

std::list<geom::LineString*> geos::operation::intersection::RectangleIntersectionBuilder::lines
private

Definition at line 126 of file RectangleIntersectionBuilder.h.

std::list<geom::Point*> geos::operation::intersection::RectangleIntersectionBuilder::points
private

Definition at line 127 of file RectangleIntersectionBuilder.h.

std::list<geom::Polygon*> geos::operation::intersection::RectangleIntersectionBuilder::polygons
private

Definition at line 125 of file RectangleIntersectionBuilder.h.


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