Hi Sven, Are you ok if I integrate your code into Territorial? I'd like to have 'Ottawa@CA' asTerritoiralCity distanceWGS84To: 'Rome@IT' asTerritorialCity Hernán 2016-10-05 19:00 GMT-03:00 Sven Van Caekenberghe <sven@stfx.eu>:
Hi Paul,
This is what we use (given WGS84 coordinates)
T3GeoTools class>>#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
Sven
On 05 Oct 2016, at 23:28, Paul DeBruicker <pdebruic@gmail.com> wrote:
umm ... here is a good place to start
http://forum.world.st/Geo-coordinates-operations-td4732373.html#a4732441
Paul DeBruicker wrote
I've got a few objects with latitude and longitude and want to be able to find the nearest from a collection
Thanks
Paul
-- View this message in context: http://forum.world.st/Is- there-any-library-to-calculate-the-geographic-distance-between-two-points- tp4918207p4918208.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.