synw / geojson

Utilities to work with geojson data in Dart
MIT License
36 stars 53 forks source link

Proximity to polygon edge #35

Open lukepighetti opened 3 years ago

lukepighetti commented 3 years ago

I'd like to be able to query the two closest polygon edges to a single point. Any ideas?

Use case: tell the user which country border they are closest to. "You are 15km from the France/Germany border!"

synw commented 3 years ago

An idea: if you have the polygon's centroids your could get the closest polygons with a cheap points distance calculation ( https://github.com/wingkwong/geodesy#distancebetweentwogeopointslatlng-l1-latlng-l2-num-radius ). Then you can get the closest point in these polygons