我应该如何准确地存储经度和纬度? [英] How accurately should I store latitude and longitude?

查看:128
本文介绍了我应该如何准确地存储经度和纬度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里读到这个问题:



似乎普遍的共识是使用Decimal(9,6)是要走的路。我的问题是,我真的需要这样的准确度吗?



例如,Google的API会返回如下结果:

 lat:37.4219720,
lng:-122.0841430

在-122.0841430之外,我需要多少位数?我已经阅读了几本指南,但是我无法从中弄清楚他们的想法。



更准确地说,在我的问题中:如果我想成为准确的位置在50英尺内准确,我需要存储多少个小数点?

也许一个更好的问题实际上是一个非编程问题,但它会be:每个小数点能给你多少精确度?



这是简单的吗?


  1. 列表项目

  2. x00 = 6000英里
  3. xx0 = 600英里
  4. 60英里
  5. xxx.x = 6英里
  6. xxx.xx = .6英里

  7. etc?


解决方案

准确性与赤道小数位之比

 小数度距离
地方
------------------------ -------
0 1.0 111 km
1 0.1 11.1 km
2 0.01 1.11 km
3 0.001 111 m
4 0.0001 11.1 m
5 0.00001 1.11 m
6 0.000001 0.111 m
7 0.0000001 1.11 cm
8 0.00000001 1.11 mm

ref: https://en.wikipedia.org/wiki/Decimal_degrees#Precision


I was reading this question here:

What datatype to use when storing latitude and longitude data in SQL databases?

And it seems the general consensus is that using Decimal(9,6) is the way to go. The question for me is, how accurate do I really need this?

For instance, Google's API returns a result like:

"lat": 37.4219720,
"lng": -122.0841430

Out of -122.0841430, how many digits do I need? I've read several guides but I can't make enough sense out of them to figure this out.

To be more precise in my question: If I want to be accurate within 50 feet of the exact location, how many decimal points do I need to store?

Perhaps a better question would actually be a non-programming question, but it would be: how much more accurate does each decimal point give you?

Is it this simple?

  1. List item
  2. x00 = 6000 miles
  3. xx0 = 600 miles
  4. xxx = 60 miles
  5. xxx.x = 6 miles
  6. xxx.xx = .6 miles
  7. etc?

解决方案

Accuracy versus decimal places at the equator

decimal  degrees    distance
places
-------------------------------  
0        1.0        111 km
1        0.1        11.1 km
2        0.01       1.11 km
3        0.001      111 m
4        0.0001     11.1 m
5        0.00001    1.11 m
6        0.000001   0.111 m
7        0.0000001  1.11 cm
8        0.00000001 1.11 mm

ref : https://en.wikipedia.org/wiki/Decimal_degrees#Precision

这篇关于我应该如何准确地存储经度和纬度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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