pub trait ChamberlainDuquetteArea<T>where
    T: CoordFloat,{
    // Required methods
    fn chamberlain_duquette_signed_area(&self) -> T;
    fn chamberlain_duquette_unsigned_area(&self) -> T;
}
Expand description

Calculate the signed approximate geodesic area of a Geometry.

Units

  • return value: meters²

References

  • Robert. G. Chamberlain and William H. Duquette, “Some Algorithms for Polygons on a Sphere”,

    JPL Publication 07-03, Jet Propulsion Laboratory, Pasadena, CA, June 2007 https://trs.jpl.nasa.gov/handle/2014/41271

Examples

use geo::{polygon, Polygon};
use geo::chamberlain_duquette_area::ChamberlainDuquetteArea;

// The O2 in London
let mut polygon: Polygon<f64> = polygon![
    (x: 0.00388383, y: 51.501574),
    (x: 0.00538587, y: 51.502278),
    (x: 0.00553607, y: 51.503299),
    (x: 0.00467777, y: 51.504181),
    (x: 0.00327229, y: 51.504435),
    (x: 0.00187754, y: 51.504168),
    (x: 0.00087976, y: 51.503380),
    (x: 0.00107288, y: 51.502324),
    (x: 0.00185608, y: 51.501770),
    (x: 0.00388383, y: 51.501574),
];

// 78,478 meters²
assert_eq!(78_478., polygon.chamberlain_duquette_unsigned_area().round());
assert_eq!(78_478., polygon.chamberlain_duquette_signed_area().round());

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

assert_eq!(78_478., polygon.chamberlain_duquette_unsigned_area().round());
assert_eq!(-78_478., polygon.chamberlain_duquette_signed_area().round());

Required Methods§

Implementors§