请记住,我将在lat / long对上执行计算,什么数据类型最适合与MySQL数据库一起使用?


当前回答

从一个完全不同和简单的角度来看:

if you are relying on Google for showing your maps, markers, polygons, whatever, then let the calculations be done by Google! you save resources on your server and you simply store the latitude and longitude together as a single string (VARCHAR), E.g.: "-0000.0000001,-0000.000000000000001" (35 length and if a number has more than 7 decimal digits then it gets rounded); if Google returns more than 7 decimal digits per number, you can get that data stored in your string anyway, just in case you want to detect some flees or microbes in the future; you can use their distance matrix or their geometry library for calculating distances or detecting points in certain areas with calls as simple as this: google.maps.geometry.poly.containsLocation(latLng, bermudaTrianglePolygon)) there are plenty of "server-side" APIs you can use (in Python, Ruby on Rails, PHP, CodeIgniter, Laravel, Yii, Zend Framework, etc.) that use Google Maps API.

这样,您就不必担心索引号和与数据类型相关的所有其他问题,这些问题可能会破坏您的坐标。

其他回答

谷歌提供了一个从开始到结束的PHP/MySQL解决方案的例子“商店定位器”应用程序与谷歌地图。在本例中,它们将lat/lng值存储为“Float”,长度为“10,6”

http://code.google.com/apis/maps/articles/phpsqlsearch.html

我建议您使用浮动数据类型的SQL Server。

MySQL使用double为所有浮点数… 所以使用double类型。在大多数情况下,使用float会导致不可预测的四舍五入值

PostGIS中的空间函数比MySQL中的空间函数更具功能性(即不局限于BBOX操作)。看看:链接文本

在GIS中使用MySQL的空间扩展。