Correct datatype for latitude and longitude? (in activerecord)

Tom Lehman picture Tom Lehman · Jul 28, 2009 · Viewed 28.8k times · Source

Should I store latitude and longitude as strings or floats (or something else)?

(I'm using activerecord / ruby on rails, if that matters).

Update:

Mysql in development and postgresql in production (why does it matter?)

Answer

Gokul picture Gokul · Aug 3, 2011

This is what I use:

add_column :table_name, :lat, :decimal, {:precision=>10, :scale=>6}
add_column :table_name, :lng, :decimal, {:precision=>10, :scale=>6}