Open sumsamvoi opened 3 years ago
Thank you, but this is already implemented in the orb/geo
package where all "geo" type functions are located. Flat/euclidean stuff is located in orb/planar
. https://github.com/paulmach/orb/blob/master/geo/distance.go#L26
For the "distance from" stuff. I'm not sure that's accurate for points+lines on a sphere. I would have to think about but I assume you'd need some more trig functions in there.
Thank you, but this is already implemented in the
orb/geo
package where all "geo" type functions are located. Flat/euclidean stuff is located inorb/planar
. https://github.com/paulmach/orb/blob/master/geo/distance.go#L26For the "distance from" stuff. I'm not sure that's accurate for points+lines on a sphere. I would have to think about but I assume you'd need some more trig functions in there.
Thank you for the comment. Basically, my use case here was the distance from
stuff. That was missing in the current implementation. I wanted to calculate distance(actual distance on earth) from a geographical location to a geometery
. The current implementation was only calculating planar distances in that context. And yes you are right, maybe i should have added it in the orb/geo
package and use the existing "geo distance" method from there, but i figured, since you have all the "distance from" implementation inside planar package so i might as well add it there.
On your point about how accurate that is, from the benchmark testing I did, it is almost identical to what postGIS
calculates. Basically, we moved some logic from db layer (which was using postGIS) into code using your lib and benchmarked the results from both implementations, and they were almost identical. We are already using the forked repo i created in production. But having said that, its probably better to be safe and double check the implementation and validate it thoroughly. For now, we are using the forked repo (https://github.com/sumsamvoi/orb). But once we finalize this PR, we can start using this one again in our services.
@paulmach Made some changes to this, moved all the geo calculations in the geo package and started using the existing "DistanceHaversine" function for calculating the distance between points on earth. Please give further directions of what needs to done to move forward with this.
In this PR, I have added the implementation for calculating haversine distance between geo coordinates in kilometers. This is useful if you are working with latitude and longitudes. The original implementation only calculates euclidean distances.