-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How best to calculate Point to Polygon distance? #59
Comments
This is a tangential thought, but maybe we could move this point-line-distance implementation into the
Can't you get the exterior ring segments from the first value in a |
Hmm I think you're right. RE moving pld to |
Merge #61 a=@urschrei r=@frewsxcv ________________________________________________________________________ This PR adds distance methods from a `Point` to: - a `LineString` - a `Polygon` To note: - Points **inside a `Polygon`** return `0.0` - Points on a **`Polygon` boundary** return `0.0` - Points **on a `LineString`** return `0.0` - distance to an **empty `LineString`** returns `0.0` - distance to an **empty `Polygon`** (shouldn't be possible, but we're handling it for now) returns `0.0` - I'm using a [`BinaryHeap`](https://doc.rust-lang.org/std/collections/struct.BinaryHeap.html) implemented as a minimum priority queue with some floating-point-compatible comparator methods (see the `Ord` and `PartialOrd` `impl`s on `Mindist`) – I just adapted the linked example to use partial ordering. Please chime in if this is Bad, or if you can think of a better design. Also WIP because: - <s>no handling of empty geometries yet</s> - <s>no docs / doctests yet</s> This will close #59 if/when it merges.
59: impl serde::Deserialize for Wkt and Geometry (and helper function) r=michaelkirk a=woshilapin - [x] I agree to follow the project's [code of conduct](https://github.com/georust/geo/blob/master/CODE_OF_CONDUCT.md). - [x] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users. --- Co-authored-by: Jean SIMARD <woshilapin@tuziwo.info>
I'm working on an algorithm that requires calculating the minimum signed distance from a Point to a Polygon exterior (negative implies that the point lies inside the Polygon /
polygon.contains(point)
istrue
).I can't see a good way to do this, currently – I've implemented point-line-distance in simplify, but that's for segments, and there's currently no way to get Polygon exterior ring segments. Or is there? If anyone can think of an approach here, or point to an existing implementation I'd be very grateful (and I'll implement it ASAP)
The text was updated successfully, but these errors were encountered: