Hmm... interesting --thank you Darren. Found a link w/ a Haversine
formula in js which is surprisingly simple too.. maybe I'm not so far
off (we'll see!)

Thanks again!



LatLong.distHaversine = function(p1, p2) {
  var R = 6371; // earth's mean radius in km
  var dLat  = p2.lat - p1.lat;
  var dLong = p2.lon - p1.lon;

  var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
          Math.cos(p1.lat) * Math.cos(p2.lat) * Math.sin(dLong/2) *
Math.sin(dLong/2);
  var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
  var d = R * c;

  return d;
}



http://www.movable-type.co.uk/scripts/LatLong.html




On 12/13/06, Darren Cook <[EMAIL PROTECTED]> wrote:
> > Getting some slightly 'off' results...anyone w/ a little geodata
> > experience up for checking my math here? Really appreciate any
> > suggestions for improving the code here too!
>
> There was an article in a recent php Architect (Vol 5, Issue 10)
> (http://www.phparch.com) where they gave this link:
> http://en.wikipedia.org/wiki/Haversine_formula
>
> FWIW, your code looks simpler than the php implementation in that
> article, so you may be missing something.
>
> Darren
>
>
> _______________________________________________
> osflash mailing list
> [email protected]
> http://osflash.org/mailman/listinfo/osflash_osflash.org
>

_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to