georust / geo

Geospatial primitives and algorithms for Rust
https://crates.io/crates/geo
Other
1.48k stars 191 forks source link

Add is_equal_topo method to IntersectionMatrix to determine topological equality #1132

Closed urschrei closed 6 months ago

urschrei commented 6 months ago

This should test whether the matrix matches [T*F**FFF*], returning true if the two geometries are topologically equal. This is different from Eq, which is an exact equality comparison. For example, these two LineStrings satisfy [T*F**FFF*] even though they're obviously not Eq:

let ls1 = line_string![(x: 1.0, y: 1.0), (x: 2.0, y: 2.0)];
let ls2 = line_string![(x: 2.0, y: 2.0), (x: 1.0, y: 1.0)];
let lsrelation = ls1.relate(&ls2);
let de9im_eq = "T*F**FFF*";
assert_eq!(lsrelation.matches(&de9im_eq).unwrap(), true);

(please feel free to bikeshed the method name)