Google Directions API 中路线编码解析
2024-09-08 10:42:54
public List<Location> GetGeoPoints(string encoded)
{
List<Location> poly = new List<Location>();
int index = , len = encoded.Length;
int lat = , lng = ;
while (index < len)
{
int b, shift = , result = ;
do
{
b = encoded.ToCharArray()[index++] - ;
result |= (b & 0x1f) << shift;
shift += ;
} while (b >= 0x20);
int dlat = ((result & ) != ? ~(result >> ) : (result >> ));
lat += dlat; shift = ;
result = ;
do
{
b = encoded.ToCharArray()[index++] - ;
result |= (b & 0x1f) << shift;
shift += ;
} while (b >= 0x20);
int dlng = ((result & ) != ? ~(result >> ) : (result >> ));
lng += dlng; double latResult = ((double)lat / 1E5) * 1E6 * Math.Pow(, -);
double lngResult = ((double)lng / 1E5) * 1E6 * Math.Pow(, -);
Location p = new Location(latResult, lngResult);
poly.Add(p);
}
return poly;
}
最新文章
- SilverFoxServer出炉!!
- VS2010 项目引用了微软企业库,但是编译时提示:未能找到类型或命名空间名称
- java-语句
- Linux命令-tr
- 为Ubuntu配置ssh服务 方便远程登陆
- Java NIO中核心组成和IO区别
- Android 常用动画小结
- 外设:K9F2G08 nandflash 底层读写、控制驱动程序,可随机读写
- iis虚拟目录引发的路径问题
- table在 点击线条颜色
- linux下操作mysql
- SSH框架搭建最终版【测试、log4j、baseDao】
- jquery常用函数
- PIC单片机基础2
- wrapper induction随笔
- Pycharm 远程调试
- SQLSERVER查询数据库死锁的存储过程
- 冬瓜头答疑:磁盘阵列内部FC-AL的性能问题
- 认识Hadoop
- Python之输出当前时间