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 数据类型?
基础教程推荐
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- 在多列上分布任意行 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
