logo
pub trait CoordinatePosition {
    type Scalar: GeoNum;

    fn calculate_coordinate_position(
        &self,
        coord: &Coordinate<Self::Scalar>,
        is_inside: &mut bool,
        boundary_count: &mut usize
    ); fn coordinate_position(&self, coord: &Coordinate<Self::Scalar>) -> CoordPos { ... } }
Expand description

Determine whether a Coordinate lies inside, outside, or on the boundary of a geometry.

Examples

use geo::{polygon, coord};
use geo::coordinate_position::{CoordinatePosition, CoordPos};

let square_poly = polygon![(x: 0.0, y: 0.0), (x: 2.0, y: 0.0), (x: 2.0, y: 2.0), (x: 0.0, y: 2.0), (x: 0.0, y: 0.0)];

let inside_coord = coord! { x: 1.0, y: 1.0 };
assert_eq!(square_poly.coordinate_position(&inside_coord), CoordPos::Inside);

let boundary_coord = coord! { x: 0.0, y: 1.0 };
assert_eq!(square_poly.coordinate_position(&boundary_coord), CoordPos::OnBoundary);

let outside_coord = coord! { x: 5.0, y: 5.0 };
assert_eq!(square_poly.coordinate_position(&outside_coord), CoordPos::Outside);

Required Associated Types

Required Methods

Provided Methods

Implementors