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 坐标,我应该在数据库中存储多少位有效数字?
基础教程推荐
- 是否可以执行按位分组功能? 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 无法解决整理冲突 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 在 SQL 中连接多个表 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
