使用 `PolyUtil.encode()` 在 Google 地图上保存重要的多边形是否安全?
Is it safe to use `PolyUtil.encode()` to save important Polygons on Google Maps?
我正在使用地图应用程序,此应用程序的功能之一是允许用户在地图上绘制多边形以完成特定任务。
此 Polygon
将保存在我们的服务器上供以后使用。
我设法对点进行编码并生成编码字符串路径,以减少在服务器之间存储和传输多边形的大小。
String path = PolyUtil.encode(latLngs); // Android
但我在 Google developer webiste 上读到:
Polyline encoding is a lossy compression algorithm that allows you to store a series of coordinates as a single string. Point coordinates are encoded using signed values. If you only have a few static points, you may also wish to use the interactive polyline encoding utility.
读到这里我感到震惊:( 因为我在不止一个应用程序中使用 encodedPath
。
有损压缩是什么意思?
那么使用这种类型来存储用户的多边形是否安全?
我的意思是:encoded
字符串的每个 decode
都会产生相同的点是真的吗?
或者把polygon
作为多点存储在服务器上比较好?
感谢您的帮助。
如果您查看用于对 Google Maps Android API Utility Library 上的 latitude/longitudes 序列进行编码的 encode
方法,您会发现它舍入了小数点后第五位:
long lat = Math.round(point.latitude * 1e5);
long lng = Math.round(point.longitude * 1e5);
从the Wikipedia开始,0.00001 十进制度数相当于赤道的 1.1132 米。
无论如何,考虑到这就是现在的行为,并且它对您来说是透明的,因此您可能不会注意到实现是否更改为允许更高的精度或者精度是否被截断了。因此,如果坐标的精度对您很重要,您可能希望将坐标存储为系统中的点列表。
我正在使用地图应用程序,此应用程序的功能之一是允许用户在地图上绘制多边形以完成特定任务。
此 Polygon
将保存在我们的服务器上供以后使用。
我设法对点进行编码并生成编码字符串路径,以减少在服务器之间存储和传输多边形的大小。
String path = PolyUtil.encode(latLngs); // Android
但我在 Google developer webiste 上读到:
Polyline encoding is a lossy compression algorithm that allows you to store a series of coordinates as a single string. Point coordinates are encoded using signed values. If you only have a few static points, you may also wish to use the interactive polyline encoding utility.
读到这里我感到震惊:( 因为我在不止一个应用程序中使用 encodedPath
。
有损压缩是什么意思?
那么使用这种类型来存储用户的多边形是否安全?
我的意思是:encoded
字符串的每个 decode
都会产生相同的点是真的吗?
或者把polygon
作为多点存储在服务器上比较好?
感谢您的帮助。
如果您查看用于对 Google Maps Android API Utility Library 上的 latitude/longitudes 序列进行编码的 encode
方法,您会发现它舍入了小数点后第五位:
long lat = Math.round(point.latitude * 1e5);
long lng = Math.round(point.longitude * 1e5);
从the Wikipedia开始,0.00001 十进制度数相当于赤道的 1.1132 米。
无论如何,考虑到这就是现在的行为,并且它对您来说是透明的,因此您可能不会注意到实现是否更改为允许更高的精度或者精度是否被截断了。因此,如果坐标的精度对您很重要,您可能希望将坐标存储为系统中的点列表。