Hi, does anyone know a gem / plugin / class with methods to do calculations based on lat/lon coordinates? E.g. calculate the distance of 2 points on the earth surface. I tried to implement my own stuff, which does not quite give me exact results. thx, Robert -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Hi Robert does anyone know a gem / plugin / class with methods to do calculations> based on lat/lon coordinates? E.g. calculate the distance of 2 points on > the earth surface. I tried to implement my own stuff, which does not > quite give me exact results.(quite a repost from a recent railsfrance ML thread, sorry for people subscribing to both lists) Not specifically a gem for the moment, but you may find the information useful though. Are you trying to compute bird-flight distances, or driving distances ? for bird-flight distances: - if you have access to the Google API, you can rely on "distanceFrom" - if you don''t, you can rely on the Haversine formula (did you use this very one in your own implementation ?) => http://www.movable-type.co.uk/scripts/GIS-FAQ-5.1.html => http://en.wikipedia.org/wiki/Haversine_formula => implementation example here : http://www.supinfo-projects.com/fr/2006/getting%5Fstarted%5Fwith%5Fgoogle%5Fmaps/1/ for driving distances it''s more complicated (and google API doesn''t expose this functionaly AFAIK, although it''s available in maps.google.com hope this helps Thibaut --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
There are various mathematical formulae that do this. Here'' s pretty good (if slightly dense) list of them: http://www.movable-type.co.uk/scripts/LatLong.html I use the cosine method (via a MySQL query -- MySQL has distance as one of the spatial functions, but it doesn''t come up with the right answers -- assumes the earth is flat, I think; PotGis might be better) and it seems to work pretty well. You should also check out ym4r and georuby (at http://www.thepochisuperstarmegashow.com/) HTH CT Thibaut Barrère wrote:> Hi Robert > > does anyone know a gem / plugin / class with methods to do > calculations > based on lat/lon coordinates? E.g. calculate the distance of 2 > points on > the earth surface. I tried to implement my own stuff, which does not > quite give me exact results. > > > (quite a repost from a recent railsfrance ML thread, sorry for people > subscribing to both lists) > > Not specifically a gem for the moment, but you may find the > information useful though. > > Are you trying to compute bird-flight distances, or driving distances ? > > for bird-flight distances: > - if you have access to the Google API, you can rely on "distanceFrom" > - if you don''t, you can rely on the Haversine formula (did you use > this very one in your own implementation ?) > => http://www.movable-type.co.uk/scripts/GIS-FAQ-5.1.html > => http://en.wikipedia.org/wiki/Haversine_formula > => implementation example here : > http://www.supinfo-projects.com/fr/2006/getting%5Fstarted%5Fwith%5Fgoogle%5Fmaps/1/ > <http://www.supinfo-projects.com/fr/2006/getting%5Fstarted%5Fwith%5Fgoogle%5Fmaps/1/> > > for driving distances it''s more complicated (and google API doesn''t > expose this functionaly AFAIK, although it''s available in > maps.google.com <http://maps.google.com> > > hope this helps > > Thibaut > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Hi Thibaut, thanks for the hints, I will evaluate those. I need bird-flight distances for a distance-limited search function. Robert -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---