我有两个Geopoints从距离值获取经纬度值从描绘路径中的Android
GeoPoint gp1;
GeoPoint gp2;
我也有这两个geopoints之间的距离。截至目前它是174公里。我需要这两个地理点之间准确的中间地理位置,所以我如何获得Middle GeoPoint。
以上两种的GeoPoint是路线绘制这是不直这样的一部分,我需要描绘路径不是直线的中间点
我的代码:
List<GeoPoint> _geopoints = decodePoly(_path);
GeoPoint gp1;
GeoPoint gp2;
gp2 = _geopoints.get(0);
System.out.println("gp2 "+gp2);
System.out.println("_geopoints"+_geopoints.size());
System.out.println("_midgeopoint"+_geopoints.size()/2);
mGeoPointMiddleOne=_geopoints.get(_geopoints.size()/2);
private List<GeoPoint> decodePoly(String encoded) {
List<GeoPoint> poly = new ArrayList<GeoPoint>();
int index = 0, len = encoded.length();
int lat = 0, lng = 0;
while (index < len) {
int b, shift = 0, result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do {
b = encoded.charAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lng += dlng;
GeoPoint p = new GeoPoint((int) (((double) lat/1E5) * 1E6),
(int) (((double) lng/1E5) * 1E6));
poly.add(p);
}
return poly;
}
上述功能decoePoly(路径)负责在两个地点之间绘制路线,所以我得到两点之间的路线。
,我也得到这两个geopoints之间的距离调用谷歌地图API绘制路线,低于
http://maps.googleapis.com/maps/api/directions/xml? origin=52.31,16.71&destination=51.27,6.75&sensor=false
,所以我在Web服务
所以我需求量的得到标记两点之间的距离我怎样才能获得从这条路线的中距离值纬度经度?
我添加了一个链接到我的回答。请看看它。 – hakiko 2013-03-10 14:39:42