pub struct IntersectionMatrix(_);
Expand description
Models a Dimensionally Extended Nine-Intersection Model (DE-9IM) matrix.
DE-9IM matrix values (such as “212FF1FF2”) specify the topological relationship between two Geometries.
DE-9IM matrices are 3x3 matrices that represent the topological locations that occur in a geometry (Interior, Boundary, Exterior).
The indices are provided by the enum cases CoordPos::Inside, CoordPos::OnBoundary, CoordPos::Outside.
The matrix entries represent the Dimensions of each intersection.
For a description of the DE-9IM and the spatial predicates derived from it, see the following references:
- OGC 99-049 OpenGIS Simple Features Specification for SQL, Section 2.1.13
- OGC 06-103r4 OpenGIS Implementation Standard for Geographic information - Simple feature access - Part 1: Common architecture, Section 6.1.15 (which provides some further details on certain predicate specifications).
- Wikipedia article on DE-9IM
This implementation is heavily based on that from the JTS project.
Implementations
sourceimpl IntersectionMatrix
impl IntersectionMatrix
pub fn empty() -> Self
sourcepub fn is_disjoint(&self) -> bool
pub fn is_disjoint(&self) -> bool
Tests if this matrix matches [FF*FF****]
.
returns true
if the two geometries related by this matrix are disjoint
sourcepub fn is_intersects(&self) -> bool
pub fn is_intersects(&self) -> bool
Tests if is_disjoint
returns false.
returns true
if the two geometries related by this matrix intersect.
sourcepub fn is_within(&self) -> bool
pub fn is_within(&self) -> bool
Tests whether this matrix matches [T*F**F***]
.
returns true
if the first geometry is within the second.
sourcepub fn is_contains(&self) -> bool
pub fn is_contains(&self) -> bool
Tests whether this matrix matches [T*****FF*]
.
returns true
if the first geometry contains the second.
sourcepub fn get(&self, lhs: CoordPos, rhs: CoordPos) -> Dimensions
pub fn get(&self, lhs: CoordPos, rhs: CoordPos) -> Dimensions
Directly accesses this matrix
use geo_types::{LineString, Rect, line_string};
use geo::{coordinate_position::CoordPos, dimensions::Dimensions, relate::Relate};
let line_string: LineString = line_string![(x: 0.0, y: 0.0), (x: 10.0, y: 0.0), (x: 5.0, y: 5.0)];
let rect = Rect::new((0.0, 0.0), (5.0, 5.0));
let intersection = line_string.relate(&rect);
// The intersection of the two interiors is empty, because no part of the string is inside the rect
assert_eq!(intersection.get(CoordPos::Inside, CoordPos::Inside), Dimensions::Empty);
// The intersection of the line string's interior with the rect's boundary is one-dimensional, because part of the first line overlaps one of the rect's edges
assert_eq!(intersection.get(CoordPos::Inside, CoordPos::OnBoundary), Dimensions::OneDimensional);
// The intersection of the line string's interior with the rect's exterior is one-dimensional, because part of the string is outside the rect
assert_eq!(intersection.get(CoordPos::Inside, CoordPos::Outside), Dimensions::OneDimensional);
// The intersection of the line string's boundary with the rect's interior is empty, because neither of its end points are inside the rect
assert_eq!(intersection.get(CoordPos::OnBoundary, CoordPos::Inside), Dimensions::Empty);
// The intersection of the line string's boundary with the rect's boundary is zero-dimensional, because the string's start and end points are on the rect's edges
assert_eq!(intersection.get(CoordPos::OnBoundary, CoordPos::OnBoundary), Dimensions::ZeroDimensional);
// The intersection of the line string's boundary with the rect's exterior is empty, because neither of its end points are outside the rect
assert_eq!(intersection.get(CoordPos::OnBoundary, CoordPos::Outside), Dimensions::Empty);
// The intersection of the the line's exterior with the rect's interior is two-dimensional, because it's simply the rect's interior
assert_eq!(intersection.get(CoordPos::Outside, CoordPos::Inside), Dimensions::TwoDimensional);
// The intersection of the line's exterior with the rect's boundary is one-dimensional, because it's the rect's edges (minus where the string overlaps it)
assert_eq!(intersection.get(CoordPos::Outside, CoordPos::OnBoundary), Dimensions::OneDimensional);
// The intersection of the two exteriors is two-dimensional, because it's the whole plane around the two shapes
assert_eq!(intersection.get(CoordPos::Outside, CoordPos::Outside), Dimensions::TwoDimensional);
Trait Implementations
sourceimpl Clone for IntersectionMatrix
impl Clone for IntersectionMatrix
sourcefn clone(&self) -> IntersectionMatrix
fn clone(&self) -> IntersectionMatrix
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for IntersectionMatrix
impl Debug for IntersectionMatrix
sourceimpl FromStr for IntersectionMatrix
impl FromStr for IntersectionMatrix
sourceimpl PartialEq<IntersectionMatrix> for IntersectionMatrix
impl PartialEq<IntersectionMatrix> for IntersectionMatrix
sourcefn eq(&self, other: &IntersectionMatrix) -> bool
fn eq(&self, other: &IntersectionMatrix) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
impl Eq for IntersectionMatrix
impl StructuralEq for IntersectionMatrix
impl StructuralPartialEq for IntersectionMatrix
Auto Trait Implementations
impl RefUnwindSafe for IntersectionMatrix
impl Send for IntersectionMatrix
impl Sync for IntersectionMatrix
impl Unpin for IntersectionMatrix
impl UnwindSafe for IntersectionMatrix
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more