Correct datatype for latitude and longitude? (in activerecord)

前端 未结 6 1379
借酒劲吻你
借酒劲吻你 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:24

    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}
    

提交回复
热议问题