Answer the question
In order to leave comments, you need to log in
Mysql - how to select points within a radius of 10 kilometers using gps coordinates?
Good day. No matter how much the Internet was swarming, it was not possible to design a working solution.
The task is as follows: The mysql database has a table with points on the ground, each point, of course, has gps coordinates. How to extract points from the base within a radius of 10, for example, kilometers from the search point, the gps coordinates of which are also known?
For specific code examples, I will be very grateful.
Answer the question
In order to leave comments, you need to log in
SELECT
id, (
3959 * acos (
cos ( radians(60.0000) )
* cos( radians( lat ) )
* cos( radians( lng ) - radians(30.0000) )
+ sin ( radians(60.0000) )
* sin( radians( lat ) )
)
) AS distance
FROM markers
HAVING distance < 30
ORDER BY distance
LIMIT 0 , 20;
It seems to me that you have chosen the wrong DBMS for your tasks. PostgreSQL clicks things like nefig to do - there are special data types, indexes and so on. Here are some details on this.
This is one of the few situations where stored functions will be useful. Do you know the Pythagorean theorem?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question