Trait geo::algorithm::concave_hull::ConcaveHull[][src]

pub trait ConcaveHull {
    type Scalar: CoordNum;
    fn concave_hull(&self, concavity: Self::Scalar) -> Polygon<Self::Scalar>;
}

Returns a polygon which covers a geometry. Unlike convex hulls, which also cover their geometry, a concave hull does so while trying to further minimize its area by constructing edges such that the exterior of the polygon incorporates points that would be interior points in a convex hull.

This implementation is inspired by https://github.com/mapbox/concaveman and also uses ideas from the following paper: www.iis.sinica.edu.tw/page/jise/2012/201205_10.pdf

Examples

use geo::{line_string, polygon};
use geo::algorithm::concave_hull::ConcaveHull;

// a square shape
let poly = polygon![
    (x: 0.0, y: 0.0),
    (x: 4.0, y: 0.0),
    (x: 4.0, y: 4.0),
    (x: 0.0, y: 4.0),
];

// The correct concave hull coordinates
let correct_hull = line_string![
    (x: 4.0, y: 0.0),
    (x: 4.0, y: 4.0),
    (x: 0.0, y: 4.0),
    (x: 0.0, y: 0.0),
    (x: 4.0, y: 0.0),
];

let res = poly.concave_hull(2.0);
assert_eq!(res.exterior(), &correct_hull);

Associated Types

Loading content...

Required methods

fn concave_hull(&self, concavity: Self::Scalar) -> Polygon<Self::Scalar>[src]

Loading content...

Implementors

impl<T> ConcaveHull for LineString<T> where
    T: GeoFloat + RTreeNum
[src]

type Scalar = T

impl<T> ConcaveHull for MultiLineString<T> where
    T: GeoFloat + RTreeNum
[src]

type Scalar = T

impl<T> ConcaveHull for MultiPoint<T> where
    T: GeoFloat + RTreeNum
[src]

type Scalar = T

impl<T> ConcaveHull for MultiPolygon<T> where
    T: GeoFloat + RTreeNum
[src]

type Scalar = T

impl<T> ConcaveHull for Polygon<T> where
    T: GeoFloat + RTreeNum
[src]

type Scalar = T

Loading content...