Problem 1: degrees of latitude and longitude have different lengths ... the same at the equator (assuming the earth is a sphere), but at the poles longitude has zero length.
Update To give an example of the severity of your problem:
111,2 ( , ). 111,2 . -41,3 83,5 .
(-41,3, 174,8) (-41,3, 174,92) 10,0 . , 13,3 - 33%.
4- :
from math import pi, sqrt, radians, cos
Earth_radius_km = 6371.009
km_per_deg_lat = 2 * pi * Earth_radius_km / 360.0
def approx_dist_1(lat1, lon1, lat2, lon2):
return km_per_deg_lat * sqrt((lat1 - lat2) ** 2 + (lon1 - lon2) ** 2)
def approx_dist_2(lat1, lon1, lat2, lon2):
km_per_deg_lon = km_per_deg_lat * cos(radians(lat1))
return sqrt((km_per_deg_lat *(lat1 - lat2)) ** 2 + (km_per_deg_lon * (lon1 - lon2)) ** 2)
" " , , SQLite, sin/cos/tan .
2: SQLite , , (lat - '-41.288889')
3: SQLlite:
sqlite> create table foo (lat float, lon float);
sqlite> insert into foo values(99.9, -170.1);
sqlite> select * from foo;
99.9|-170.1
sqlite> SELECT *, ((lat - '-41.288889') * (lat - '-41.288889')
...> + (lon - 174.777222) * (lon - 174.777222)) AS distance from foo;
99.9|-170.1|138874.600631492
sqlite>
, , " , "... e
?