GEOS  3.9.1dev
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
geos::algorithm::MinimumDiameter Class Reference

Computes the minimum diameter of a geom::Geometry. More...

#include <MinimumDiameter.h>

Collaboration diagram for geos::algorithm::MinimumDiameter:
[legend]

Public Member Functions

 ~MinimumDiameter ()=default
 
 MinimumDiameter (const geom::Geometry *newInputGeom)
 Compute a minimum diameter for a given Geometry. More...
 
 MinimumDiameter (const geom::Geometry *newInputGeom, const bool newIsConvex)
 Compute a minimum diameter for a given Geometry, with a hint if the Geometry is convex (e.g. a convex Polygon or LinearRing, or a two-point LineString, or a Point). More...
 
double getLength ()
 Gets the length of the minimum diameter of the input Geometry. More...
 
const geom::CoordinategetWidthCoordinate ()
 Gets the geom::Coordinate forming one end of the minimum diameter. More...
 
std::unique_ptr< geom::LineStringgetSupportingSegment ()
 Gets the segment forming the base of the minimum diameter. More...
 
std::unique_ptr< geom::LineStringgetDiameter ()
 Gets a LineString which is a minimum diameter. More...
 
std::unique_ptr< geom::GeometrygetMinimumRectangle ()
 Gets the minimum rectangular Polygon which encloses the input geometry. More...
 

Static Public Member Functions

static std::unique_ptr< geom::GeometrygetMinimumRectangle (geom::Geometry *geom)
 Gets the minimum rectangle enclosing a geometry. More...
 
static std::unique_ptr< geom::GeometrygetMinimumDiameter (geom::Geometry *geom)
 Gets the length of the minimum diameter enclosing a geometry. More...
 

Private Member Functions

void computeMinimumDiameter ()
 
void computeWidthConvex (const geom::Geometry *geom)
 
void computeConvexRingMinDiameter (const geom::CoordinateSequence *pts)
 
unsigned int findMaxPerpDistance (const geom::CoordinateSequence *pts, const geom::LineSegment *seg, unsigned int startIndex)
 

Static Private Member Functions

static unsigned int getNextIndex (const geom::CoordinateSequence *pts, unsigned int index)
 
static double computeC (double a, double b, const geom::Coordinate &p)
 
static geom::LineSegment computeSegmentForLine (double a, double b, double c)
 

Private Attributes

const geom::GeometryinputGeom
 
bool isConvex
 
std::unique_ptr< geom::CoordinateSequenceconvexHullPts
 
geom::LineSegment minBaseSeg
 
geom::Coordinate minWidthPt
 
size_t minPtIndex
 
double minWidth
 

Detailed Description

Computes the minimum diameter of a geom::Geometry.

The minimum diameter is defined to be the width of the smallest band that contains the geometry, where a band is a strip of the plane defined by two parallel lines. This can be thought of as the smallest hole that the geometry can be moved through, with a single rotation.

The first step in the algorithm is computing the convex hull of the Geometry. If the input Geometry is known to be convex, a hint can be supplied to avoid this computation.

This class can also be used to compute a line segment representing the minimum diameter, the supporting line segment of the minimum diameter, and a minimum rectangle enclosing the input geometry. This rectangle will have width equal to the minimum diameter, and have one side parallel to the supporting segment.

See also
ConvexHull

Definition at line 63 of file MinimumDiameter.h.

Constructor & Destructor Documentation

geos::algorithm::MinimumDiameter::~MinimumDiameter ( )
default
geos::algorithm::MinimumDiameter::MinimumDiameter ( const geom::Geometry newInputGeom)

Compute a minimum diameter for a given Geometry.

Parameters
newInputGeoma Geometry
geos::algorithm::MinimumDiameter::MinimumDiameter ( const geom::Geometry newInputGeom,
const bool  newIsConvex 
)

Compute a minimum diameter for a given Geometry, with a hint if the Geometry is convex (e.g. a convex Polygon or LinearRing, or a two-point LineString, or a Point).

Parameters
newInputGeoma Geometry which is convex
newIsConvextrue if the input geometry is convex

Member Function Documentation

static double geos::algorithm::MinimumDiameter::computeC ( double  a,
double  b,
const geom::Coordinate p 
)
staticprivate
void geos::algorithm::MinimumDiameter::computeConvexRingMinDiameter ( const geom::CoordinateSequence pts)
private

Compute the width information for a ring of geom::Coordinates. Leaves the width information in the instance variables.

Parameters
pts
Returns
void geos::algorithm::MinimumDiameter::computeMinimumDiameter ( )
private
static geom::LineSegment geos::algorithm::MinimumDiameter::computeSegmentForLine ( double  a,
double  b,
double  c 
)
staticprivate
void geos::algorithm::MinimumDiameter::computeWidthConvex ( const geom::Geometry geom)
private
unsigned int geos::algorithm::MinimumDiameter::findMaxPerpDistance ( const geom::CoordinateSequence pts,
const geom::LineSegment seg,
unsigned int  startIndex 
)
private
std::unique_ptr<geom::LineString> geos::algorithm::MinimumDiameter::getDiameter ( )

Gets a LineString which is a minimum diameter.

Returns
a LineString which is a minimum diameter
double geos::algorithm::MinimumDiameter::getLength ( )

Gets the length of the minimum diameter of the input Geometry.

Returns
the length of the minimum diameter
static std::unique_ptr<geom::Geometry> geos::algorithm::MinimumDiameter::getMinimumDiameter ( geom::Geometry geom)
static

Gets the length of the minimum diameter enclosing a geometry.

Parameters
geomthe geometry
Returns
the length of the minimum diameter of the geometry
std::unique_ptr<geom::Geometry> geos::algorithm::MinimumDiameter::getMinimumRectangle ( )

Gets the minimum rectangular Polygon which encloses the input geometry.

The rectangle has width equal to the minimum diameter, and a longer length. If the convex hill of the input is degenerate (a line or point) a LineString or Point is returned. The minimum rectangle can be used as an extremely generalized representation for the given geometry.

Returns
the minimum rectangle enclosing the input (or a line or point if degenerate)
static std::unique_ptr<geom::Geometry> geos::algorithm::MinimumDiameter::getMinimumRectangle ( geom::Geometry geom)
static

Gets the minimum rectangle enclosing a geometry.

Parameters
geomthe geometry
Returns
the minimum rectangle enclosing the geometry
static unsigned int geos::algorithm::MinimumDiameter::getNextIndex ( const geom::CoordinateSequence pts,
unsigned int  index 
)
staticprivate
std::unique_ptr<geom::LineString> geos::algorithm::MinimumDiameter::getSupportingSegment ( )

Gets the segment forming the base of the minimum diameter.

Returns
the segment forming the base of the minimum diameter
const geom::Coordinate& geos::algorithm::MinimumDiameter::getWidthCoordinate ( )

Gets the geom::Coordinate forming one end of the minimum diameter.

Returns
a coordinate forming one end of the minimum diameter

Member Data Documentation

std::unique_ptr<geom::CoordinateSequence> geos::algorithm::MinimumDiameter::convexHullPts
private

Definition at line 68 of file MinimumDiameter.h.

const geom::Geometry* geos::algorithm::MinimumDiameter::inputGeom
private

Definition at line 65 of file MinimumDiameter.h.

bool geos::algorithm::MinimumDiameter::isConvex
private

Definition at line 66 of file MinimumDiameter.h.

geom::LineSegment geos::algorithm::MinimumDiameter::minBaseSeg
private

Definition at line 70 of file MinimumDiameter.h.

size_t geos::algorithm::MinimumDiameter::minPtIndex
private

Definition at line 72 of file MinimumDiameter.h.

double geos::algorithm::MinimumDiameter::minWidth
private

Definition at line 73 of file MinimumDiameter.h.

geom::Coordinate geos::algorithm::MinimumDiameter::minWidthPt
private

Definition at line 71 of file MinimumDiameter.h.


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