paulmach / go.geo

Geometry/geography library in Go, DEPRECATED, use ->
https://github.com/paulmach/orb
MIT License
330 stars 55 forks source link

Added FindKNearestMatchingGeo that takes maxDistance in meters #60

Closed vagmi closed 6 years ago

vagmi commented 6 years ago

I needed this on a project I was working on where I need to choose clusters based on how close they were and the users were given the option to tune the distance. The max squared distance was arbitrary and is difficult to reason with.

paulmach commented 6 years ago

I don't think there is a really great (efficient) way to do this. I would suggest projecting your points to the plane first using mercator or something, then projecting back once you find the point. I'm pretty sure that'll work reasonably well for the values in your test.

You can do this using geo.Mercator.Project and geo.Mercator.Inverse in this package.