1.0.0 • Published 5 years ago

mavrlnodeserver v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

From: Doctor Rick Subject: Re: Using Longitude and Latitude to Determine Distance

Hi, Bryan.

I think a linear scaling will be fine for a map with maximum distances less than 10 miles, as your area suggests. It is hard to give a formula for the maximum error, but the following page from the Dr. Math Archives has a table that will help:

Planar Approximation: Latitude and Longitude http://mathforum.org/library/drmath/view/62720.html

There is one assumption I didn't mention with the linear scaling formula: it assumes that the latitudes and longitudes at the corners of the map have been chosen so that the map will have the same scale horizontally and vertically. The Planar Approximation formula in the page I just mentioned will help you do this.

x = (lon2-lon1)cos(lat1)pi/180 y = (lat2-lat1)*pi/180

Here, x and y are in radians; if we want them in miles, we should use

x = (lon2-lon1)cos(lat1)piR/180 y = (lat2-lat1)pi*R/180

where R is the radius of the earth, R = 6367 km = 3956 mi. Solving for lon2,lat2 in terms of x,y:

lat2 = lat1 + y180/(piR) lon2 = lon1 + x180/(piR*cos(lat1))

If (lon1,lat1) is the center of the map, w pixels across and h pixels high, and you want a scale of n pixels on the map = one mile on earth, the latitudes and longitudes of the corners of the map should be

lat = lat1 +or- (w/2)n180/(piR) lon = lon1 +or- (h/2)n180/(piR*cos(lat1))