pub trait CoordinatePosition {
    type Scalar: GeoNum;

    // Required method
    fn calculate_coordinate_position(
        &self,
        coord: &Coord<Self::Scalar>,
        is_inside: &mut bool,
        boundary_count: &mut usize
    );

    // Provided method
    fn coordinate_position(&self, coord: &Coord<Self::Scalar>) -> CoordPos { ... }
}
Expand description

Determine whether a Coord 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§

source

fn calculate_coordinate_position( &self, coord: &Coord<Self::Scalar>, is_inside: &mut bool, boundary_count: &mut usize )

Provided Methods§

source

fn coordinate_position(&self, coord: &Coord<Self::Scalar>) -> CoordPos

Implementors§

source§

impl<T> CoordinatePosition for Geometry<T>
where T: GeoNum,

§

type Scalar = T

source§

impl<T> CoordinatePosition for Coord<T>
where T: GeoNum,

§

type Scalar = T

source§

impl<T> CoordinatePosition for GeometryCollection<T>
where T: GeoNum,

§

type Scalar = T

source§

impl<T> CoordinatePosition for Line<T>
where T: GeoNum,

§

type Scalar = T

source§

impl<T> CoordinatePosition for LineString<T>
where T: GeoNum,

§

type Scalar = T

source§

impl<T> CoordinatePosition for MultiLineString<T>
where T: GeoNum,

§

type Scalar = T

source§

impl<T> CoordinatePosition for MultiPoint<T>
where T: GeoNum,

§

type Scalar = T

source§

impl<T> CoordinatePosition for MultiPolygon<T>
where T: GeoNum,

§

type Scalar = T

source§

impl<T> CoordinatePosition for Point<T>
where T: GeoNum,

§

type Scalar = T

source§

impl<T> CoordinatePosition for Polygon<T>
where T: GeoNum,

§

type Scalar = T

source§

impl<T> CoordinatePosition for Rect<T>
where T: GeoNum,

§

type Scalar = T

source§

impl<T> CoordinatePosition for Triangle<T>
where T: GeoNum,

§

type Scalar = T

source§

impl<T: GeoNum> CoordinatePosition for MonoPoly<T>

§

type Scalar = T