georust / geo

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

getting one of the closest point for `Closest::Indeterminate` #1167

Open kraktus opened 3 months ago

kraktus commented 3 months ago

Hello, thanks for the great lib!

When using geo::algorithm::closest_point::ClosestPoint, is there a one of the closest point when the result is Closest:: Indeterminate? If defined

michaelkirk commented 1 month ago

I'm sorry but I don't understand your question. Can you try to rephrase it or give a more specific example?

The docs for Indeterminate if you haven't seen them: https://docs.rs/geo/latest/geo/enum.Closest.html#variant.Indeterminate

kraktus commented 1 month ago

Sorry, some words got missing in my issue. When there is an "infinite number of closest points", is there a way a method that retrieves one of those?

My real use case was:

extract from my code

// licence: AGPLv3
            let arp_pt = airport.to_point();
            let Closest::SinglePoint(closest_point) = polygon.closest_point(&arp_pt) else {
                panic!("no closest point")
            };
            let distance_m = arp_pt.haversine_distance(&closest_point) as usize;

In case of of Indeterminate, I would be fine with any one of closest points. For now I bailed out, fortunately it didn't happen in practice