georust / geo

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

Allow returning the source of edges from BoolOp. #1097

Open andriyDev opened 8 months ago

andriyDev commented 8 months ago

BoolOps take two (multi-)polygons, the subject and the clip and returns the union/intersection/XOR/difference of these as a new (multi-)polygon. It can be useful to know which edges in the result polygon come from which edges in the subject and the clip.

Example: I have room A with wallpaper A, and a hallway C with wallpaper C. I want to attach these, so I take the union between room A's polygon and hallway C's polygon. Now what wallpaper do I assign to each wall in the union polygon?

Based on my understanding of the Martinez-Rueda-Feito algorithm:

This does mean we require a little more memory per event, and returning this metadata will require an extra allocation. Perhaps we can avoid the extra memory allocation by adding a new trait: BoolOpsWithEdgeSource?