(I made a prototype using Long / Lat to search for rows in a radius, but now abandoned this in favor of the GridRef system available in the UK)
As a first step, do not use the WHERE clause based on the calculated field (for example, the actual distance based on the given coordinate and row coordinate).
Instead, try the following:
- Imagine a circle where radius = maximum distance
- Draw a box around it using curved lines of longitude.
- Find items in this field.
In practice, this means:
- determine how many degrees of longitude represents your maximum distance at a given latitude.
- determine how many degrees latitude represents your maximum distance at a given longitude (this factor will be fixed when using the spherical-terrestrial model).
- SELECT * FROM places WHERE long> $ westside AND long <$ eastside AND lat <$ northside and lat> $ southside
This means that you are doing very simple calculations to get an indefinite subset covering the area 30% more than your actual circle. If you also want to add a text search, either SELECT FROM (subquery), or add your text sentence AFTER a simple comparison above, since text queries are expensive.
Emyr
source share