8 位小数的纬度/经度应该使用哪种 MySQL 数据类型? [英] What MySQL data type should be used for Latitude/Longitude with 8 decimal places?

查看:32
本文介绍了8 位小数的纬度/经度应该使用哪种 MySQL 数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理地图数据,Latitude/Longitude 扩展到小数点后 8 位.例如:

I'm working with map data, and the Latitude/Longitude extends to 8 decimal places. For example:

Latitude 40.71727401
Longitude -74.00898606

我在 Google 文档中看到使用:

lat FLOAT( 10, 6 ) NOT NULL,  
lng FLOAT( 10, 6 ) NOT NULL

但是,它们的小数位只能到 6.
我应该使用 FLOAT(10, 8) 还是有另一种方法可以考虑存储这些数据,所以它是精确的.它将与地图计算一起使用.谢谢!

however, their decimal places only go to 6.
Should I use FLOAT(10, 8) or is there another method to consider for storing this data so it's precise. It will be used with map calculations. Thanks!

推荐答案

MySQL支持空间数据类型Point 是可以使用的单值类型.示例:

MySQL supports Spatial data types and Point is a single-value type which can be used. Example:

CREATE TABLE `buildings` (
  `coordinate` POINT NOT NULL,
  /* Even from v5.7.5 you can define an index for it */
  SPATIAL INDEX `SPATIAL` (`coordinate`)
) ENGINE=InnoDB;

/* then for insertion you can */
INSERT INTO `buildings` 
(`coordinate`) 
VALUES
(POINT(40.71727401 -74.00898606));

这篇关于8 位小数的纬度/经度应该使用哪种 MySQL 数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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