geos::operation::intersection::RectangleIntersection Class Reference

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

`#include <RectangleIntersection.h>`

## Static Public Member Functions

static std::unique_ptr< geom::Geometry > | clip (const geom::Geometry &geom, const Rectangle &rect)
| Clip geometry with a rectangle.
static std::unique_ptr< geom::Geometry > | clipBoundary (const geom::Geometry &geom, const Rectangle &rect)
| Clip boundary of a geometry with a rectangle.

## 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.

## Member Function Documentation

## clip()

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

static

Clip geometry with a rectangle.

Parameters

  geom | a Geometry
  rect | a Rectangle

Returns
  the clipped geometry
  NULL if the geometry is outside the Rectangle

Referenced by clipBoundary().

## clipBoundary()

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

  geom | a Geometry
  rect | a Rectangle

Returns
  the clipped geometry
  NULL if the geometry is outside the Rectangle

References clip(), and clipBoundary().

Referenced by clipBoundary().

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

- RectangleIntersection.h