code_junkie

Calculating Distance Between 2 Cities

Nov 10th, 2011
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. // Cities are points x0,y0 and x1,y1 in kilometers or miles or Smoots[1]
  2. dx = x1 - x0;
  3. dy = y1 - y0;
  4. dist = sqrt(dx*dx + dy*y);
  5.  
  6. dist = sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0));
  7.  
  8. SELECT geography::Point(lat1, lon1, 4326).STDistance(geography::Point(lat2, lon2, 4326))
  9. -- computes distance in meters using eliptical model, accurate to the mm
  10.  
  11. dist = sqrt(dx*dx + dy*dy);
Add Comment
Please, Sign In to add comment