如何修复为Google地图编码多段线时丢失的精确度 [英] How to fix losing precision when encoding polylines for Google Maps

查看:100
本文介绍了如何修复为Google地图编码多段线时丢失的精确度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现这个引用良好的网页为Google地图编码多段线。我已经在我的应用程序中实现了用于对多段线进行编码和解码的算法,但是我正面临着一些保持坐标精度的问题。



我有这些坐标我的折线:

  57.012415241636155,9.99178024863532 
57.012422477487256,9.991334773101812
57.01190974033057,9.99068645350514
code>

如果我使用他们的编码器我得到这个编码折线:

  qf〜zIso〜{ @ AxAfB`C 

如果我之后尝试使用他们的解码器我得到这些坐标:

  57.01241,9.99178 
57.012420000000006,9.991330000000001
57.011900000000004,9.990680000000001

为什么我失去了坐标的精度?我需要我的编码折线更精确。 解决方案



然而,你当然不需要那么精确。 (57.012410,9.991780)与(57.012411,9.991781)之间的距离—小数点后第一位 - 1是12厘米。小数点后第五位的每个数字约为一米。这些地图并不准确。


I've found this well-referenced page Encoding polylines for Google Maps. I've implemented their algorithms for encoding and decoding polylines in my application, but I'm facing some issues keeping the precision of the coordinates.

I've these coordinates for my polyline:

57.012415241636155, 9.99178024863532
57.012422477487256, 9.991334773101812
57.01190974033057, 9.99068645350514

If I encode them using their encoder I get this encoded polyline:

qf~zIso~{@AxAfB`C

If I afterwards try to decode this encoded string using their decoder I get these coordinates:

57.01241, 9.99178
57.012420000000006, 9.991330000000001
57.011900000000004, 9.990680000000001

Why am I losing the precision of my coordinates? I need my encoded polyline to be more precise.

解决方案

You are losing precision because encoding does that.

However, you most certainly do not need that precision. The distance between (57.012410, 9.991780) and (57.012411, 9.991781) — 1 at the sixth decimal place — is 12cm. Each digit at the fifth decimal place will be about a metre. The maps aren't that accurate.

这篇关于如何修复为Google地图编码多段线时丢失的精确度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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