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....

15th Feb 2017, 3:07 AM
Moh Affan
Moh Affan - avatar
4 Réponses
+ 6
Pythagorean theorem: a^2+b^2=c^2 Compare c^2. https://en.m.wikipedia.org/wiki/Pythagorean_theorem
15th Feb 2017, 5:41 AM
Tashi N
Tashi N - avatar
+ 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.
15th Feb 2017, 6:03 AM
Tashi N
Tashi N - avatar
+ 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.
17th Feb 2017, 9:38 PM
Tashi N
Tashi N - avatar
0
it seems hard to be implemented in sql query
15th Feb 2017, 6:31 AM
Moh Affan
Moh Affan - avatar