0
How to find nearest location using latitude and longitude from mysql?
I want to find nearest location from one location in my database, the table fields are : id, school_name, address, latitude, and longitude please help....
4 ответов
+ 6
Pythagorean theorem: a^2+b^2=c^2
Compare c^2.
https://en.m.wikipedia.org/wiki/Pythagorean_theorem
+ 5
Just to mention it:
For the real distance you need the height, too. And then Pythagoras twice:
distance^2 = c^2 + height^2
c^2 is the result from my first answer.
And take care for the measurement units, too. Lat/long has to be translated to a distance unit.
+ 5
I think it can be done with sql, but I wouldn't do that. Choose a programming language to learn next.
I can only speak for Java concerning this geospatial stuff. There are a lot of sdk/api/frameworks which make that calculation available to you. And show your locations on a map and so on. The simplest imo is NASA World Wind sdk.
0
it seems hard to be implemented in sql query