georust / geo

Rust geospatial primitives & algorithms
https://crates.io/crates/geo
Other
1.58k stars 199 forks source link

Proof of concept: Allow custom earth radii #1220

Closed frewsxcv closed 1 month ago

frewsxcv commented 1 month ago
michaelkirk commented 1 month ago

With my work on #1216, I've been thinking about this too!

I was imagining something kind of like what you've laid out here. Here's a POC with configurable haversine: b89c07e0

It's built on top of #1216 + the unified length trait I mentioned in #256 (I haven't opened a PR for #256 yet, I'm waiting on #1216 first).

One thing that my POC does not account for are methods on geometries - e.g. I haven't come up with a nice way to use a parameterized instance of a metric space (Haversine/Geodesic) to implement the unified Length trait. It seems likely doing so would require moving the implementation off of the geometry and onto an instance of Haversine.

So (e.g.) instead of line_string.length::<Haversine>() you'd do Haversine::wgs84().length(&line_string), Haversine::default().length(&line_string), etc.