GEO calculations with MySQL

Geo-enabled or applications using user’s locations are increasing dramatically. I am currently working on an application which collects user’s location data, which led me to do more research and find an efficient methods to achieve the common tasks in a geo-enabled application.

  • Finding distance between 2 points using latitude and longitude.
  • Finding places of interest in a radius. (Example: All the coffee shops in 1 KM radius.

Basics:

ALTER TABLE places ADD coord POINT NOT NULL;
CREATE SPATIAL INDEX coord ON places (coord);

read more