Trait geo::algorithm::area::Area

source ·
pub trait Area<T>
where T: CoordNum,
{ // Required methods fn signed_area(&self) -> T; fn unsigned_area(&self) -> T; }
Expand description

Signed and unsigned planar area of a geometry.

§Examples

use geo::polygon;
use geo::Area;

let mut polygon = polygon![
    (x: 0., y: 0.),
    (x: 5., y: 0.),
    (x: 5., y: 6.),
    (x: 0., y: 6.),
    (x: 0., y: 0.),
];

assert_eq!(polygon.signed_area(), 30.);
assert_eq!(polygon.unsigned_area(), 30.);

polygon.exterior_mut(|line_string| {
    line_string.0.reverse();
});

assert_eq!(polygon.signed_area(), -30.);
assert_eq!(polygon.unsigned_area(), 30.);

Required Methods§

source

fn signed_area(&self) -> T

source

fn unsigned_area(&self) -> T

Implementors§

source§

impl<T> Area<T> for Geometry<T>
where T: CoordFloat,

source§

impl<T> Area<T> for GeometryCollection<T>
where T: CoordFloat,

source§

impl<T> Area<T> for Line<T>
where T: CoordNum,

source§

impl<T> Area<T> for LineString<T>
where T: CoordNum,

source§

impl<T> Area<T> for MultiLineString<T>
where T: CoordNum,

source§

impl<T> Area<T> for MultiPoint<T>
where T: CoordNum,

source§

impl<T> Area<T> for MultiPolygon<T>
where T: CoordFloat,

Note. The implementation is a straight-forward summation of the signed areas of the individual polygons. In particular, unsigned_area is not necessarily the sum of the unsigned_area of the constituent polygons unless they are all oriented the same.

source§

impl<T> Area<T> for Point<T>
where T: CoordNum,

source§

impl<T> Area<T> for Polygon<T>
where T: CoordFloat,

Note. The implementation handles polygons whose holes do not all have the same orientation. The sign of the output is the same as that of the exterior shell.

source§

impl<T> Area<T> for Rect<T>
where T: CoordNum,

Because a Rect has no winding order, the area will always be positive.

source§

impl<T> Area<T> for Triangle<T>
where T: CoordFloat,