Has anybody implemented basic methods/classes to calculate distance
between two points (lat, long) and similar operations? Regards, Esteban A. Maringolo |
Answering myself...
I found a solution and transcribed it: http://pastebin.com/ThKDXCKK Esteban A. Maringolo 2013/12/25 Esteban A. Maringolo <[hidden email]>: > Has anybody implemented basic methods/classes to calculate distance > between two points (lat, long) and similar operations? > > Regards, > > Esteban A. Maringolo |
Hi Esteban,
On 26 Dec 2013, at 02:23, Esteban A. Maringolo <[hidden email]> wrote: > Answering myself... > > I found a solution and transcribed it: http://pastebin.com/ThKDXCKK This is the formula that we have been using for years in Pharo, Java[Script], Common Lisp: distanceBetween: firstPosition and: secondPosition "T3GeoTools distanceBetween: 5.33732@50.926 and: 5.49705@50.82733" | c | c := (firstPosition y degreeSin * secondPosition y degreeSin) + (firstPosition y degreeCos * secondPosition y degreeCos * (secondPosition x degreesToRadians - firstPosition x degreesToRadians) cos). c := c >= 0 ifTrue: [ 1 min: c ] ifFalse: [ -1 max: c ]. ^ c arcCos * 6371000 This is between WGS84 coordinates. It seems simpler than yours. We have been using this page as reference: http://www.movable-type.co.uk/scripts/latlong.html Regards, Sven > Esteban A. Maringolo > > > 2013/12/25 Esteban A. Maringolo <[hidden email]>: >> Has anybody implemented basic methods/classes to calculate distance >> between two points (lat, long) and similar operations? >> >> Regards, >> >> Esteban A. Maringolo > |
If no one has nothing agains it, I will move this Q/A on StackOverflow.
Uko On 26 Dec 2013, at 11:35, Sven Van Caekenberghe <[hidden email]> wrote: > Hi Esteban, > > On 26 Dec 2013, at 02:23, Esteban A. Maringolo <[hidden email]> wrote: > >> Answering myself... >> >> I found a solution and transcribed it: http://pastebin.com/ThKDXCKK > > This is the formula that we have been using for years in Pharo, Java[Script], Common Lisp: > > distanceBetween: firstPosition and: secondPosition > "T3GeoTools distanceBetween: 5.33732@50.926 and: 5.49705@50.82733" > > | c | > c := (firstPosition y degreeSin * secondPosition y degreeSin) > + (firstPosition y degreeCos * secondPosition y degreeCos > * (secondPosition x degreesToRadians - firstPosition x degreesToRadians) cos). > c := c >= 0 ifTrue: [ 1 min: c ] ifFalse: [ -1 max: c ]. > ^ c arcCos * 6371000 > > This is between WGS84 coordinates. It seems simpler than yours. We have been using this page as reference: > > http://www.movable-type.co.uk/scripts/latlong.html > > Regards, > > Sven > >> Esteban A. Maringolo >> >> >> 2013/12/25 Esteban A. Maringolo <[hidden email]>: >>> Has anybody implemented basic methods/classes to calculate distance >>> between two points (lat, long) and similar operations? >>> >>> Regards, >>> >>> Esteban A. Maringolo >> > > |
On 26 Dec 2013, at 10:58, Yuriy Tymchuk <[hidden email]> wrote: > If no one has nothing agains it, I will move this Q/A on StackOverflow. With proper attribution, please do. > Uko > > On 26 Dec 2013, at 11:35, Sven Van Caekenberghe <[hidden email]> wrote: > >> Hi Esteban, >> >> On 26 Dec 2013, at 02:23, Esteban A. Maringolo <[hidden email]> wrote: >> >>> Answering myself... >>> >>> I found a solution and transcribed it: http://pastebin.com/ThKDXCKK >> >> This is the formula that we have been using for years in Pharo, Java[Script], Common Lisp: >> >> distanceBetween: firstPosition and: secondPosition >> "T3GeoTools distanceBetween: 5.33732@50.926 and: 5.49705@50.82733" >> >> | c | >> c := (firstPosition y degreeSin * secondPosition y degreeSin) >> + (firstPosition y degreeCos * secondPosition y degreeCos >> * (secondPosition x degreesToRadians - firstPosition x degreesToRadians) cos). >> c := c >= 0 ifTrue: [ 1 min: c ] ifFalse: [ -1 max: c ]. >> ^ c arcCos * 6371000 >> >> This is between WGS84 coordinates. It seems simpler than yours. We have been using this page as reference: >> >> http://www.movable-type.co.uk/scripts/latlong.html >> >> Regards, >> >> Sven >> >>> Esteban A. Maringolo >>> >>> >>> 2013/12/25 Esteban A. Maringolo <[hidden email]>: >>>> Has anybody implemented basic methods/classes to calculate distance >>>> between two points (lat, long) and similar operations? >>>> >>>> Regards, >>>> >>>> Esteban A. Maringolo >>> >> >> > > |
In reply to this post by Sven Van Caekenberghe-2
Hi Sven,
2013/12/26 Sven Van Caekenberghe <[hidden email]>: > Hi Esteban, > On 26 Dec 2013, at 02:23, Esteban A. Maringolo <[hidden email]> wrote: >> Answering myself... >> >> I found a solution and transcribed it: http://pastebin.com/ThKDXCKK > > This is the formula that we have been using for years in Pharo, Java[Script], Common Lisp: > > distanceBetween: firstPosition and: secondPosition > "T3GeoTools distanceBetween: 5.33732@50.926 and: 5.49705@50.82733" [snip] > http://www.movable-type.co.uk/scripts/latlong.html According to this website your implementation uses the "Spherical law of cosines" whilst mine uses the Haversine formula. Yours is simpler, no doubt. Best regards! Esteban A. Maringolo |
Free forum by Nabble | Edit this page |