我从这篇文章中得到了答案
需要这两个函数将折线数组编码为 ascii 字符串
private static String encodeSignedNumber(int num) {
int sgn_num = num << 1;
if (num < 0) {
sgn_num = ~(sgn_num);
}
return(encodeNumber(sgn_num));
}
private static String encodeNumber(int num) {
StringBuffer encodeString = new StringBuffer();
while (num >= 0x20) {
encodeString.append((char)((0x20 | (num & 0x1f)) + 63));
num >>= 5;
}
encodeString.append((char)(num + 63));
return encodeString.toString();
}
用于测试尝试从这个站点的坐标并比较输出
这是片段
StringBuffer encodeString = new StringBuffer();
String encode = Geo_Class.encodeSignedNumber(3850000)+""+Geo_Class.encodeSignedNumber(-12020000);
encodeString.append(encode);
encode = Geo_Class.encodeSignedNumber(220000)+""+Geo_Class.encodeSignedNumber(-75000);
encodeString.append(encode);
encode = Geo_Class.encodeSignedNumber(255200)+""+Geo_Class.encodeSignedNumber(-550300);
encodeString.append(encode);
Log.v("encode string", encodeString.toString());
从你得到这一点的坐标链接
Points: (38.5, -120.2), (40.7, -120.95), (43.252, -126.453)
好的,所以现在您认为坐标是为什么不同的原因,当您获得新坐标时,您会从前一个坐标中减去例如
1. 3850000,-12020000 => 3850000,-12020000
2. 4070000,-12095000 => (4070000 - 3850000),(-12095000 - -12020000) => +220000, -75000
您必须将该值传递给 encodeSignedNumber() 方法,然后您将获得该坐标的 ascii 值
等等....