Answer the question
In order to leave comments, you need to log in
How to select objects that are "closer than 500 meters" from a set of other objects?
Hello Toaster!
1. There is a mysql table with a set of points (lat, lng fields). This is how I store the coordinates of the Black Sea contour :)
2. There is a table with hotels (they also have lat and lng fields).
How can I select "all hotels located near the sea" with one request (from 0 to 1000 meters from the sea).
In Google I found an example of a query to search for "the nearest points relative to the current one":
SELECT id, ( 3959 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance
FROM sea_latlng
HAVING distance < 25
ORDER BY distance
Answer the question
In order to leave comments, you need to log in
Поискать библиотеки для работы с геоданными, который умеют работать с полигонами.
Один раз прогнать все отели, посчитав удаленность каждого, записать в базу в отдельное поле. Фильтровать по нему.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question