SQL query to query nearby points of interest based on lat/long - SQLite

后端 未结 3 796
面向向阳花
面向向阳花 2021-02-08 03:46

Given a database that contains three fields:

Latitude Longitude Proximity

Where Lat and Long are GPS coordinates, and Proximity is (some unit - feet? Seconds? Mi

3条回答
  •  难免孤独
    2021-02-08 04:18

    The Haversine formula is what you want. Using simple Euclidian distance formula isn't sufficient, because the curvature of the earth affects the distance between two points.

    Creating a Store Locator with PHP, MySQL & Google Maps is an article about implementing this solution with MySQL, but SQLite doesn't support trig functions.

    Check out the answers in Calculating Great-Circle Distance with SQLite here on Stack Overflow for further tips on extending SQLite functions so you can solve this.

提交回复
热议问题