8/24/2010

Latitude/longitude spherical geodesy formulae & scripts spreadsheets interface

Latitude/longitude spherical geodesy formulae & scripts spreadsheets interface


Open spreadsheets https://spreadsheets.google.com/ccc?key=0AppCRCbx33I9dG5Wem1jTjMtbl9wTXpNUUUzOFl6TkE&hl=en

Credits and implementation code
http://www.movable-type.co.uk/scripts/latlong.html

Script interface

Copy Source | Copy HTML
  1. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
  2. /*  Latitude/longitude spherical geodesy formulae & scripts spreadsheets interface                */
  3. /*  Credits - www.movable-type.co.uk/scripts/latlong.html                                         */
  4.  
  5.  
  6. function GCDist(lat1, lon1, lat2, lon2) {
  7. // Return Great Circle Distance between points calculation
  8.    var p1 = new LatLon(lat1, lon1);
  9.    var p2 = new LatLon(lat2, lon2);
  10.    var dist = p1.distanceTo(p2); // in km
  11.   return dist;
  12. }
  13.  
  14. function Bearing(lat1, lon1, lat2, lon2) {
  15. // Return Bearing between points calculation
  16.    var p1 = new LatLon(lat1, lon1);
  17.    var p2 = new LatLon(lat2, lon2);
  18.    var brng = p1.bearingTo(p2); // in degrees clockwise from north
  19.   return brng;
  20. }
  21.  
  22. function Midpointlat(lat1, lon1, lat2, lon2) {
  23. // Returns the midpoint latitude between this point and the supplied point.
  24.    var p1 = new LatLon(lat1, lon1);
  25.    var p2 = new LatLon(lat2, lon2);
  26.    var midp = p1.midpointTo(p2); // in deg
  27.   return midp._lat;
  28. }
  29.  
  30. function Midpointlon(lat1, lon1, lat2, lon2) {
  31. // Returns the midpoint longitude between this point and the supplied point.
  32.    var p1 = new LatLon(lat1, lon1);
  33.    var p2 = new LatLon(lat2, lon2);
  34.    var midp = p1.midpointTo(p2); // in deg
  35.   return midp._lon;
  36. }
  37.  
  38. function Destpointlat(lat1, lon1, bearing, distance) {
  39. // Returns the destination point latitude from this point having travelled the given distance (in km) on the 
  40. // given initial bearing (bearing may vary before destination is reached)
  41.    var p1 = new LatLon(lat1, lon1);
  42.    var midp = p1.destinationPoint(bearing, distance); // in degrees clockwise from north
  43.   return midp._lat;
  44. }
  45.  
  46. function Destpointlon(lat1, lon1, bearing, distance) {
  47. // Returns the destination point longitude from this point having travelled the given distance (in km) on the 
  48. // given initial bearing (bearing may vary before destination is reached)
  49.    var p1 = new LatLon(lat1, lon1);
  50.    var midp = p1.destinationPoint(bearing, distance); // in degrees clockwise from north
  51.   return midp._lon;
  52. }
  53.  
Post a Comment