“The Graticule Ruby gem makes it super easy to geocode addresses using multiple services. One thing…”

“The Graticule Ruby gem makes it super easy to geocode addresses using multiple services. One thing I’ve found in developing Unthirsty is that sometimes a geocoding service either fails to be reached or the address couldn’t be found. So as a precaution, I’ve set up a way for Graticule to failover to another service if a lookup fails. Here’s how.”

via mattking.org

“The Graticule Ruby gem makes it super easy to geocode addresses using multiple services. One thing I’ve found in developing Unthirsty is that sometimes a geocoding service either fails to be reached or the address couldn’t be found. So as a precaution, I’ve set up a way for Graticule to failover to another service if a lookup fails. Here’s how.”

via mattking.org

Haversine formula in JavaScript

var lat2 = Math.asin( Math.sin(lat1)Math.cos(d/R) + Math.cos(lat1)Math.sin(d/R)*Math.cos(brng) );

var lon2 = lon1 + Math.atan2(Math.sin(brng)Math.sin(d/R)Math.cos(lat1), Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2));

Calculate distance and bearing between two Latitude/Longitude points using Haversine formula in JavaScript

Given a start point, initial bearing, and distance, this will calculate the destination point and final bearing travelling along a (shortest distance) great circle arc:

var lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) + 
                      Math.cos(lat1)*Math.sin(d/R)*Math.cos(brng) );
var lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(lat1), 
                             Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2));

Calculate distance and bearing between two Latitude/Longitude points using Haversine formula in JavaScript