From 1cce0a3374fe24cf1b0fed43fdfa93f7ed2b40b9 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 22 Mar 2021 13:27:32 -0700 Subject: [PATCH] add Relate impls for GeometryCollection, remove most for Geometry We *do* want to be able to relate any Geometry _variant_ with any other _variant_. So I've added the missing impls for GeometryCollection. However, in line with our other traits, we typically only want to relate any Geometry with another _Geometry_, not to each inner variant directly, so I've replaced the combinatoric `impl` for Geometry with a single `impl Relate for Geometry` --- geo/src/algorithm/relate/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/geo/src/algorithm/relate/mod.rs b/geo/src/algorithm/relate/mod.rs index 3debcfdb4..7ef8d9597 100644 --- a/geo/src/algorithm/relate/mod.rs +++ b/geo/src/algorithm/relate/mod.rs @@ -2,8 +2,8 @@ pub(crate) use edge_end_builder::EdgeEndBuilder; pub use geomgraph::intersection_matrix::IntersectionMatrix; use crate::{ - GeoFloat, Geometry, GeometryCow, Line, LineString, MultiLineString, MultiPoint, MultiPolygon, - Point, Polygon, Rect, Triangle, + GeoFloat, Geometry, GeometryCollection, GeometryCow, Line, LineString, MultiLineString, + MultiPoint, MultiPolygon, Point, Polygon, Rect, Triangle, }; mod edge_end_builder; @@ -65,6 +65,9 @@ impl Relate> for GeometryCow<'_, F> { } macro_rules! relate_impl { + ($k:ty, $t:ty) => { + relate_impl![($k, $t),]; + }; ($(($k:ty, $t:ty),)*) => { $( impl Relate for $k { @@ -111,4 +114,5 @@ macro_rules! cartesian_pairs_helper { // Implement Relate for every combination of Geometry. Alternatively we could do something like // `impl Relate> for Into { }` // but I don't know that we want to make GeometryCow public (yet?). -cartesian_pairs!(relate_impl, [Geometry, Point, Line, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, Rect, Triangle]); +cartesian_pairs!(relate_impl, [Point, Line, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, Rect, Triangle, GeometryCollection]); +relate_impl!(Geometry, Geometry);