正确的经纬度数据类型? (在activerecord中) [英] Correct datatype for latitude and longitude? (in activerecord)

查看:67
本文介绍了正确的经纬度数据类型? (在activerecord中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该将纬度和经度存储为字符串或浮点数(或其他东西)吗?

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

(如果重要的话,我在轨道上使用activerecord / ruby​​)。

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

更新:

开发中的MySQL和生产中的PostgreSQL(为什么重要?)

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

推荐答案

如果需要进行更复杂的地理计算,则可以调查用于Postgresql的PostGIS MySQL的MySQL Spatial Extensions 。否则,应该使用浮点数(双精度可能是个好主意)。

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.

编辑:看起来像 GeoRuby 库包含一个Rails扩展,用于处理上述两个数据库的空间/ GIS扩展。

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

这篇关于正确的经纬度数据类型? (在activerecord中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆