geo icon indicating copy to clipboard operation
geo copied to clipboard

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

Open kraktus opened this issue 1 year ago • 4 comments

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

kraktus avatar Apr 03 '24 15:04 kraktus

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

michaelkirk avatar May 08 '24 01:05 michaelkirk

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:

  • I want to compute the haversine distance between a point and a polygon, but since it is not defined, I approximate it by
  • Computing the closest point between the polygon and the point
  • computing the haversine distance between one polygon and the closest point of the polygon

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

kraktus avatar May 15 '24 10:05 kraktus