The best way to store GPS coordinates (track) on server

Konstantin.Efimenko picture Konstantin.Efimenko · Nov 16, 2012 · Viewed 7.7k times · Source

What is the best way to store GPS coordinates (track) on server (MySQL or Oracle or maybe in any file)? How is it implemented it the GoogleMaps, for example? I want to save and compare tracks for same parts.

P.S. I have all necessary data.

Answer

O. Jones picture O. Jones · Nov 16, 2012

If I were you I'd use a TRACK and a POINT table.

The TRACK table would contain a row for each distinct track

  TRACK_ID      int not null  (PK)
  NAME          varchar(40)
  DESCRIPTION   varchar(255)
  other identifying information

The POINT table would contain multiple rows per track, one for each point in the track

  POINT_ID     int not null  (PK)
  TRACK_ID     int not null  (FK to TRACK)
  LAT          float  degrees  .. positive means north
  LONG         float  degrees  .. positive means east, negative means west
  ALT          float (elevation if you have it)
  TS           timestamp of point

A couple of notes about this. Keep the rows of the POINT table short; you will have lots of them and you want to be able to crunch them quickly. Also, don't succumb to the temptation of using double instead of float; the float data format has plenty of precision for a typical point (unless you are a land surveyor and know about stuff like universal transverse mercator projections).