Class MinimumDiameter
java.lang.Object
org.locationtech.jts.algorithm.MinimumDiameter
Computes the minimum diameter of a
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
- the minimum-width rectangle of the input geometry.
The rectangle has width equal to the minimum diameter, and has one side
parallel to the supporting segment.
In degenerate cases the rectangle may be a LineString or a Point.
(Note that this may not be the enclosing rectangle with minimum area;
use
MinimumAreaRectangleto compute this.)
- Version:
- 1.7
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMinimumDiameter(Geometry inputGeom) Compute a minimum diameter for a givenGeometry.MinimumDiameter(Geometry inputGeom, boolean isConvex) Compute a minimum diameter for a giverGeometry, with a hint if the Geometry is convex (e.g. a convex Polygon or LinearRing, or a two-point LineString, or a Point). -
Method Summary
Modifier and TypeMethodDescriptionGets aLineStringwhich is a minimum diameterdoubleGets the length of the minimum diameter of the input Geometrystatic GeometrygetMinimumDiameter(Geometry geom) Gets the length of the minimum diameter enclosing a geometryGets the rectangularPolygonwhich encloses the input geometry and is based on the minimum diameter supporting segment.static GeometrygetMinimumRectangle(Geometry geom) Gets the minimum-width rectangularPolygonwhich encloses the input geometry and is based along the supporting segment.Gets the segment forming the base of the minimum diameterGets theCoordinateforming one end of the minimum diameter
-
Constructor Details
-
MinimumDiameter
-
MinimumDiameter
Compute a minimum diameter for a giverGeometry, with a hint if the Geometry is convex (e.g. a convex Polygon or LinearRing, or a two-point LineString, or a Point).- Parameters:
inputGeom- a Geometry which is convexisConvex-trueif the input geometry is convex
-
-
Method Details
-
getMinimumRectangle
Gets the minimum-width rectangularPolygonwhich encloses the input geometry and is based along the supporting segment. The rectangle has width equal to the minimum diameter, and a longer length. If the convex hull of the input is degenerate (a line or point) aLineStringorPointis returned.This is not necessarily the rectangle with minimum area. Use
MinimumAreaRectangleto compute this.- Parameters:
geom- the geometry- Returns:
- the minimum-width rectangle enclosing the geometry
- See Also:
-
getMinimumDiameter
-
getLength
public double getLength()Gets the length of the minimum diameter of the input Geometry- Returns:
- the length of the minimum diameter
-
getWidthCoordinate
Gets theCoordinateforming one end of the minimum diameter- Returns:
- a coordinate forming one end of the minimum diameter
-
getSupportingSegment
Gets the segment forming the base of the minimum diameter- Returns:
- the segment forming the base of the minimum diameter
-
getDiameter
Gets aLineStringwhich is a minimum diameter- Returns:
- a
LineStringwhich is a minimum diameter
-
getMinimumRectangle
Gets the rectangularPolygonwhich encloses the input geometry and is based on the minimum diameter supporting segment. The rectangle has width equal to the minimum diameter, and a longer length. If the convex hull of the input is degenerate (a line or point) aLineStringorPointis returned.This is not necessarily the enclosing rectangle with minimum area.
- Returns:
- a rectangle enclosing the input (or a line or point if degenerate)
- See Also:
-