How many significant digits should I store in my database for a GPS coordinate?(对于 GPS 坐标,我应该在数据库中存储多少位有效数字?)
问题描述
我的 MySQL 数据库中有经度和纬度坐标(GPS 数据).
I have in my MySQL database both longitude and latitude coordinates (GPS data).
目前存储为:
column type
------------------------
geolat decimal(10,6)
geolng decimal(10,6)
问题:我真的需要像 decimal(10,6) 这样大的数据类型来正确存储坐标数据吗?
Question: Do I really need a data type as large as decimal(10,6) to properly store coordinate data?
由于我有一个经度和纬度的组合索引,所以这个索引大小很大.如果我可以在不影响任何东西的情况下将其缩小,那就太好了.
Since I have a combined index on the longitude and latitude, this index size is huge. If I can make it smaller without compromising anything, that would be great.
推荐答案
WGS84 基准面通常是以完全十进制表示法给出的坐标,通常有 5 个小数位,因此对于纬度(-90 到 +90),您可以使用小数(7、5)(-90.00000 到 90.00000),对于经度,您可以使用小数(8,5)(-180.00000 到 180.00000).
WGS84 datum are usually given as coordinates in a fully decimal notation, usually with 5 decimal places, so for latitude (-90 to +90) you could use decimal(7, 5) (-90.00000 to 90.00000), for longitude you could use decimal(8, 5) (-180.00000 to 180.00000).
.00001 在赤道处给出大约一米的精度
DECIMAL/NUMERIC 数据类型是一个固定精度的缩放整数 并且范围的正负部分始终可用 - 它们不会影响精度或比例(显然需要存储空间,但对于 DECIMAL,您无法选择)
The DECIMAL/NUMERIC data type is a fixed precision scaled integer and both positive and negative parts of the range are always available - they do not affect the precision or scale (there is obviously storage required for it, but you don't get a choice about that for DECIMAL)
这篇关于对于 GPS 坐标,我应该在数据库中存储多少位有效数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:对于 GPS 坐标,我应该在数据库中存储多少位有效数字?
基础教程推荐
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- 在多列上分布任意行 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
