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

Speed-optimized clipping of a Geometry with a rectangle. More...

#include <RectangleIntersection.h>

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

Static Public Member Functions

static std::unique_ptr< geom::Geometryclip (const geom::Geometry &geom, const Rectangle &rect)
 Clip geometry with a rectangle. More...
 
static std::unique_ptr< geom::GeometryclipBoundary (const geom::Geometry &geom, const Rectangle &rect)
 Clip boundary of a geometry with a rectangle. More...
 

Private Member Functions

 RectangleIntersection (const geom::Geometry &geom, const Rectangle &rect)
 
std::unique_ptr< geom::GeometryclipBoundary ()
 
std::unique_ptr< geom::Geometryclip ()
 
void clip_geom (const geom::Geometry *g, RectangleIntersectionBuilder &parts, const Rectangle &rect, bool keep_polygons)
 
void clip_point (const geom::Point *g, RectangleIntersectionBuilder &parts, const Rectangle &rect)
 
void clip_multipoint (const geom::MultiPoint *g, RectangleIntersectionBuilder &parts, const Rectangle &rect)
 
void clip_linestring (const geom::LineString *g, RectangleIntersectionBuilder &parts, const Rectangle &rect)
 
void clip_multilinestring (const geom::MultiLineString *g, RectangleIntersectionBuilder &parts, const Rectangle &rect)
 
void clip_polygon (const geom::Polygon *g, RectangleIntersectionBuilder &parts, const Rectangle &rect, bool keep_polygons)
 
void clip_multipolygon (const geom::MultiPolygon *g, RectangleIntersectionBuilder &parts, const Rectangle &rect, bool keep_polygons)
 
void clip_geometrycollection (const geom::GeometryCollection *g, RectangleIntersectionBuilder &parts, const Rectangle &rect, bool keep_polygons)
 
void clip_polygon_to_linestrings (const geom::Polygon *g, RectangleIntersectionBuilder &parts, const Rectangle &rect)
 
void clip_polygon_to_polygons (const geom::Polygon *g, RectangleIntersectionBuilder &parts, const Rectangle &rect)
 
bool clip_linestring_parts (const geom::LineString *gi, RectangleIntersectionBuilder &parts, const Rectangle &rect)
 Clip geometry. More...
 

Private Attributes

const geom::Geometry_geom
 
const Rectangle_rect
 
const geom::GeometryFactory_gf
 
const geom::CoordinateSequenceFactory_csf
 

Detailed Description

Speed-optimized clipping of a Geometry with a rectangle.

Two different methods are provided. The first performs normal clipping, the second clips the boundaries of polygons, not the polygons themselves. In the first case a polygon will remain a polygon or is completely cut out. In the latter case polygons will be converted to polylines if any vertex is outside the clipping rectangle, or will be cut out completely.

The algorithm works best when the number of intersections is very low. For example, if the geometry is completely to the left of the clipping rectangle, only the x-coordinate of the geometry is ever tested and is only compared with the x-coordinate of the left edge of the rectangle. Hence clipping may be faster than calculating the envelope of the geometry for trivial overlap tests.

The input geometry must be valid. In particular all LinearRings must be properly closed, or the algorithm may not terminate.

Definition at line 75 of file RectangleIntersection.h.

Constructor & Destructor Documentation

geos::operation::intersection::RectangleIntersection::RectangleIntersection ( const geom::Geometry geom,
const Rectangle rect 
)
private

Member Function Documentation

static std::unique_ptr<geom::Geometry> geos::operation::intersection::RectangleIntersection::clip ( const geom::Geometry geom,
const Rectangle rect 
)
static

Clip geometry with a rectangle.

Parameters
geoma Geometry
recta Rectangle
Returns
the clipped geometry
NULL if the geometry is outside the Rectangle
std::unique_ptr<geom::Geometry> geos::operation::intersection::RectangleIntersection::clip ( )
private
void geos::operation::intersection::RectangleIntersection::clip_geom ( const geom::Geometry g,
RectangleIntersectionBuilder parts,
const Rectangle rect,
bool  keep_polygons 
)
private
void geos::operation::intersection::RectangleIntersection::clip_geometrycollection ( const geom::GeometryCollection g,
RectangleIntersectionBuilder parts,
const Rectangle rect,
bool  keep_polygons 
)
private
void geos::operation::intersection::RectangleIntersection::clip_linestring ( const geom::LineString g,
RectangleIntersectionBuilder parts,
const Rectangle rect 
)
private
bool geos::operation::intersection::RectangleIntersection::clip_linestring_parts ( const geom::LineString gi,
RectangleIntersectionBuilder parts,
const Rectangle rect 
)
private

Clip geometry.

Returns true if the geometry was fully inside, and does not output anything to RectangleIntersectionBuilder.

void geos::operation::intersection::RectangleIntersection::clip_multilinestring ( const geom::MultiLineString g,
RectangleIntersectionBuilder parts,
const Rectangle rect 
)
private
void geos::operation::intersection::RectangleIntersection::clip_multipoint ( const geom::MultiPoint g,
RectangleIntersectionBuilder parts,
const Rectangle rect 
)
private
void geos::operation::intersection::RectangleIntersection::clip_multipolygon ( const geom::MultiPolygon g,
RectangleIntersectionBuilder parts,
const Rectangle rect,
bool  keep_polygons 
)
private
void geos::operation::intersection::RectangleIntersection::clip_point ( const geom::Point g,
RectangleIntersectionBuilder parts,
const Rectangle rect 
)
private
void geos::operation::intersection::RectangleIntersection::clip_polygon ( const geom::Polygon g,
RectangleIntersectionBuilder parts,
const Rectangle rect,
bool  keep_polygons 
)
private
void geos::operation::intersection::RectangleIntersection::clip_polygon_to_linestrings ( const geom::Polygon g,
RectangleIntersectionBuilder parts,
const Rectangle rect 
)
private
void geos::operation::intersection::RectangleIntersection::clip_polygon_to_polygons ( const geom::Polygon g,
RectangleIntersectionBuilder parts,
const Rectangle rect 
)
private
static std::unique_ptr<geom::Geometry> geos::operation::intersection::RectangleIntersection::clipBoundary ( const geom::Geometry geom,
const Rectangle rect 
)
static

Clip boundary of a geometry with a rectangle.

Any polygon which intersects the rectangle will be converted to a polyline or a multipolyline - including the holes.

Parameters
geoma Geometry
recta Rectangle
Returns
the clipped geometry
NULL if the geometry is outside the Rectangle
std::unique_ptr<geom::Geometry> geos::operation::intersection::RectangleIntersection::clipBoundary ( )
private

Member Data Documentation

const geom::CoordinateSequenceFactory* geos::operation::intersection::RectangleIntersection::_csf
private

Definition at line 114 of file RectangleIntersection.h.

const geom::Geometry& geos::operation::intersection::RectangleIntersection::_geom
private

Definition at line 111 of file RectangleIntersection.h.

const geom::GeometryFactory* geos::operation::intersection::RectangleIntersection::_gf
private

Definition at line 113 of file RectangleIntersection.h.

const Rectangle& geos::operation::intersection::RectangleIntersection::_rect
private

Definition at line 112 of file RectangleIntersection.h.


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