How to efficiently use longitude / latitude values ​​in Mysql?

Thanks to Wikileaks, here in the UK, we can now access our longitude and latitude coordinates for each postal code wikileaks postcodes uk IMPORTANT, Do not use this data in public applications. Regarding the fact that the data was intentionally corrupted, and you may be deemed to violate copyright law. Try using data from an open source site such as Postcode UK site

Now you can calculate the distances between each point using the following calculation (originally from the excellent Pro Mysql book):

The distance d between two points (x1, y1) and (x2, y2) can be calculated from the following equation (as long as x is latitude and y is longitude in radians, r is the radius of a sphere that is 3956 miles):

d = acos (sin (x1) * sin (x2) + cos (x1) * cos (x2) * cos (y2-y1)) * r

Now this is good enough, or should I use the new types and functions of GIS data, and if so, how can I convert the longitude and latitude links to a point data type? I understand that since the Earth is not an ideal sphere, therefore, the calculation of the distance that I quote above is not perfect; however, this is good enough for my purposes. Will the new GIS functionality be used: a) make distance calculation faster b) make distance calculation more accurate?

+3
2

(a):

, lat, long, xaxis, yaxis zxais, x, y z :

xaxis = cos(radians(Lat)) * cos(radians(Lon))
yaxis = cos(radians(Lat)) * sin(radians(Lon))
zaxis = sin(radians(Lat))

SQL, (acos( xaxis * $xaxis + yaxis * $yaxis + zaxis * $zaxis ) * 6367.0 / 1.852) ( , $, , )

.

+2

, "", , ( , , , ). GIS , .

lat/long , , API Google. (. GLatLng.)

+1

Source: https://habr.com/ru/post/1718308/


All Articles