Trait geo::algorithm::relate::Relate [−][src]
pub trait Relate<F, T> { fn relate(&self, other: &T) -> IntersectionMatrix; }
Topologically relate two geometries based on DE-9IM semantics.
See IntersectionMatrix
for details.
Examples
use geo::{Coordinate, Line, Rect, line_string}; use crate::geo::relate::Relate; let line = Line::new(Coordinate { x: 2.0, y: 2.0}, Coordinate { x: 4.0, y: 4.0 }); let rect = Rect::new(Coordinate { x: 2.0, y: 2.0}, Coordinate { x: 4.0, y: 4.0 }); let intersection_matrix = rect.relate(&line); assert!(intersection_matrix.is_intersects()); assert!(!intersection_matrix.is_disjoint()); assert!(intersection_matrix.is_contains()); assert!(!intersection_matrix.is_within()); let line = Line::new(Coordinate { x: 1.0, y: 1.0}, Coordinate { x: 5.0, y: 5.0 }); let rect = Rect::new(Coordinate { x: 2.0, y: 2.0}, Coordinate { x: 4.0, y: 4.0 }); let intersection_matrix = rect.relate(&line); assert!(intersection_matrix.is_intersects()); assert!(!intersection_matrix.is_disjoint()); assert!(!intersection_matrix.is_contains()); assert!(!intersection_matrix.is_within()); let rect_boundary = line_string![ (x: 2.0, y: 2.0), (x: 4.0, y: 2.0), (x: 4.0, y: 4.0), (x: 2.0, y: 4.0), (x: 2.0, y: 2.0) ]; let intersection_matrix = rect.relate(&rect_boundary); assert!(intersection_matrix.is_intersects()); assert!(!intersection_matrix.is_disjoint()); // According to DE-9IM, polygons don't contain their own boundary assert!(!intersection_matrix.is_contains()); assert!(!intersection_matrix.is_within());
Note: Relate
must not be called on geometries containing NaN
coordinates.