Correct datatype for latitude and longitude? (in activerecord)

前端 未结 6 1376
借酒劲吻你
借酒劲吻你 2021-01-30 03:07

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

6条回答
  •  醉酒成梦
    2021-01-30 03:44

    If you need to do more complex geographical calculations, you can investigate PostGIS for Postgresql or MySQL Spatial Extensions for MySQL. Otherwise, a float (double precision might be a good idea) should work.

    Edit: It looks like the GeoRuby library includes a Rails extension for working with the spatial/GIS extensions for both of the aforementioned databases.

提交回复
热议问题