Java double vs BigDecimal用于纬度/经度 [英] Java double vs BigDecimal for latitude/longitude

查看:520
本文介绍了Java double vs BigDecimal用于纬度/经度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在存储通常为以下格式的纬度/经度时:44.087585(即,点和6dp之前最多2个数字)是否需要打扰十进制?

When storing latitudes/longitudes which are typically of the format: 44.087585 (i.e. max 2 numbers before the dot and 6dp) do I need to bother with bigdecimals?

推荐答案

使用double精度足以将纬度/经度降低至英寸,精确到6-7小数位.在航空业中,如果使用小数位,则它们通常至少升至7位小数.在我们的NASA模拟中,纬度/经度数据是双倍的,而所有其他姿态和高度都是浮点的.换句话说,海拔高度的小数点后第六位并不重要,而纬度/经度的小数点后第六位则代表亚英尺精度.如果您需要精确到子英尺的精度,则不应将float用作纬度/经度.

Using double has enough precision for accurate lat/lon down to inches for 6-7 decimal places. In aviation, if decimal degrees are used, they typically go to at least 7 decimal places. In our NASA simulations, lat/lon data are doubles while all other attitude and altitude are floats. In other words, the 6th decimal place for altitude isn't significant while the 6th decimal place for lat/lon is for sub-foot accuracy. You should not use float for lat/lon if you need precision down to sub-feet.

您可以在Google地球中玩耍,通过放置标记并操纵最后一个十进制数字来查看获得的精度.

You can play around in Google Earth to see what accuracy you get by placing markers and manipulating the last decimal digit.

这篇关于Java double vs BigDecimal用于纬度/经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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