What MySQL data type should be used for Latitude/Longitude with 8 decimal places?(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 数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:8 位小数的纬度/经度应该使用哪种 MySQL 数据类型?
基础教程推荐
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 无法解决整理冲突 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
