pub(crate) use edge_end_builder::EdgeEndBuilder;
pub use geomgraph::intersection_matrix::IntersectionMatrix;
use relate_operation::RelateOperation;
use crate::geometry::*;
#[deprecated(
since = "0.31.1",
note = "PreparedGeometry has moved to geo::indexed::PreparedGeometry"
)]
pub use crate::indexed::PreparedGeometry;
pub use crate::relate::geomgraph::GeometryGraph;
use crate::{BoundingRect, GeoFloat, GeometryCow, HasDimensions};
mod edge_end_builder;
pub(crate) mod geomgraph;
mod relate_operation;
pub trait Relate<F: GeoFloat>: BoundingRect<F> + HasDimensions {
fn geometry_graph(&self, idx: usize) -> GeometryGraph<'_, F>;
fn relate(&self, other: &impl Relate<F>) -> IntersectionMatrix
where
Self: Sized,
{
RelateOperation::new(self, other).compute_intersection_matrix()
}
}
macro_rules! relate_impl {
($($t:ty ,)*) => {
$(
impl<F: GeoFloat> Relate<F> for $t {
fn geometry_graph(&self, arg_index: usize) -> GeometryGraph<'_, F> {
$crate::relate::GeometryGraph::new(arg_index, GeometryCow::from(self))
}
}
impl<F: GeoFloat> From<$t> for PreparedGeometry<'static, $t, F> {
fn from(geometry: $t) -> Self {
$crate::indexed::prepared_geometry::prepare_geometry(geometry)
}
}
impl<'a, F: GeoFloat> From<&'a $t> for PreparedGeometry<'a, &'a $t, F> {
fn from(geometry: &'a $t) -> Self {
$crate::indexed::prepared_geometry::prepare_geometry(geometry)
}
}
)*
};
}
relate_impl![
Point<F>,
Line<F>,
LineString<F>,
Polygon<F>,
MultiPoint<F>,
MultiLineString<F>,
MultiPolygon<F>,
Rect<F>,
Triangle<F>,
GeometryCollection<F>,
Geometry<F>,
];
#[cfg(test)]
mod tests {
#[test]
fn run_jts_relate_tests() {
jts_test_runner::assert_jts_tests_succeed("*Relate*.xml");
}
}