Skip to main content

Geometry

Trait Geometry 

Source
pub trait Geometry {
    // Required methods
    fn bbox(&self) -> Option<Rect>;
    fn is_areal(&self) -> bool;
    fn visit_segments(&self, f: &mut dyn FnMut(Point, Point));
    fn locate(&self, p: Point) -> Location;
    fn any_point(&self) -> Option<Point>;

    // Provided methods
    fn component_points(&self, f: &mut dyn FnMut(Point)) { ... }
    fn first_not_outside(&self, pts: &[Point]) -> Option<Point> { ... }
}
Expand description

A geometry that queries (locate, intersects, contains, distances) accept.

Areal geometries (Ring, Polygon, polygon sets, PolyTree) are closed regions; linear ones (Segment, Path) and Point are just their point sets.

Required Methods§

Source

fn bbox(&self) -> Option<Rect>

Bounding box, None when empty.

Source

fn is_areal(&self) -> bool

true for regions (rings, polygons), false for points and linear geometries.

Source

fn visit_segments(&self, f: &mut dyn FnMut(Point, Point))

Calls f for every boundary segment (areal) or every segment (linear). A point geometry yields one degenerate segment (p, p); so does a single-vertex path.

Source

fn locate(&self, p: Point) -> Location

Location of p relative to the geometry.

Source

fn any_point(&self) -> Option<Point>

Some vertex of the geometry, if not empty.

Provided Methods§

Source

fn component_points(&self, f: &mut dyn FnMut(Point))

Calls f with one vertex of every connected component (every polygon of a set, every outer ring of a tree). Single-component geometries use any_point.

Source

fn first_not_outside(&self, pts: &[Point]) -> Option<Point>

The first of pts that is not outside this geometry, if any. Geometries made of many parts override this with a spatial index.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Geometry for Vec<Polygon>

Source§

fn bbox(&self) -> Option<Rect>

Source§

fn is_areal(&self) -> bool

Source§

fn visit_segments(&self, f: &mut dyn FnMut(Point, Point))

Source§

fn locate(&self, p: Point) -> Location

Source§

fn any_point(&self) -> Option<Point>

Source§

fn component_points(&self, f: &mut dyn FnMut(Point))

Source§

fn first_not_outside(&self, pts: &[Point]) -> Option<Point>

Source§

impl Geometry for [Polygon]

Source§

fn bbox(&self) -> Option<Rect>

Source§

fn is_areal(&self) -> bool

Source§

fn visit_segments(&self, f: &mut dyn FnMut(Point, Point))

Source§

fn locate(&self, p: Point) -> Location

Source§

fn any_point(&self) -> Option<Point>

Source§

fn component_points(&self, f: &mut dyn FnMut(Point))

Source§

fn first_not_outside(&self, pts: &[Point]) -> Option<Point>

Source§

impl<T: Geometry + ?Sized> Geometry for &T

Source§

fn bbox(&self) -> Option<Rect>

Source§

fn is_areal(&self) -> bool

Source§

fn visit_segments(&self, f: &mut dyn FnMut(Point, Point))

Source§

fn locate(&self, p: Point) -> Location

Source§

fn any_point(&self) -> Option<Point>

Source§

fn component_points(&self, f: &mut dyn FnMut(Point))

Source§

fn first_not_outside(&self, pts: &[Point]) -> Option<Point>

Implementors§