pub trait MinimumRotatedRect<'a, T> {
    type Scalar: GeoNum;

    // Required method
    fn minimum_rotated_rect(&'a self) -> Option<Polygon<Self::Scalar>>;
}
Expand description

Return the minimum bounding rectangle(MBR) of geometry reference: https://en.wikipedia.org/wiki/Minimum_bounding_box minimum rotated rect is the rectangle that can enclose all points given and have smallest area of all enclosing rectangles the rect can be any-oriented, not only axis-aligned.

Examples

use geo_types::{line_string, polygon, LineString, Polygon};
use geo::MinimumRotatedRect;
let poly: Polygon<f64> = polygon![(x: 3.3, y: 30.4), (x: 1.7, y: 24.6), (x: 13.4, y: 25.1), (x: 14.4, y: 31.0),(x:3.3,y:30.4)];
let mbr = MinimumRotatedRect::minimum_rotated_rect(&poly).unwrap();
assert_eq!(
    mbr.exterior(),
    &LineString::from(vec![
        (1.7000000000000006, 24.6),
        (1.4501458363715918, 30.446587428904767),
        (14.4, 31.0),
        (14.649854163628408, 25.153412571095235),
        (1.7000000000000006, 24.6),
    ])
);

Required Associated Types§

Required Methods§

Implementors§

source§

impl<'a, T, G> MinimumRotatedRect<'a, T> for Gwhere T: CoordFloat + GeoFloat + GeoNum, G: CoordsIter<'a, Scalar = T>,

§

type Scalar = T