2012-09-05 6 views
1

내 응용 프로그램은 java google map 웹 응용 프로그램입니다. 2 점을 받고 Google에 보내십시오 http://maps.googleapis.com/maps/api/directions/json?origin="+saddr+"&destination="+daddr+"&sensor=false, 그것은 json을줍니다. 그럼 난 overview_polyline 디코딩을했습니다. 내 문제는 때로는 확장 된 가치를 부여합니다.Google지도 overview_polyline이 잘못된 값을 제공합니다.

이것은 내 디코드 부분입니다.

public static ArrayList<Location> decodePoly(String encoded) { 
     ArrayList<Location> poly = new ArrayList<Location>(); 
     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; 
     Location p = new Location((((double) lat/1E5)), 
     (((double) lng/1E5))); 

    // System.out.println("==p==" +p.getLatitude()); 
     // System.out.println("==p==" +p.getLongitude()); 
     poly.add(p); 
     } 
     return poly; 
    } 

enter image description here

검은 색 마크는 담당자가 해당 경로로 이동하지 않았다. 그러나 그 것처럼 그려졌다. http://maps.googleapis.com/maps/api/directions/json?origin=6.95522,79.8864&destination=6.96165,79.8958&sensor=falseoverview_polyline이 2 잘못된 경로가

enter image description here을 그려 [email protected]}xqfNEkEM{@[email protected]@[email protected]@[email protected]@gA}@qD_DiDgD{MoN_DeDJEVGvBS

입니다 내 DB 샘플 데이터 ... enter image description here

몇 가지 아이디어를 제공하세요? 문제가 무엇인가요? 사전에

감사합니다. 에 기재된

+0

이 결과를 제공하는 샘플 출발지 및 도착지를 제공 할 수 있습니까? 디코딩 한 인코딩 된 폴리 라인을 제공 할 수 있습니까? 길을 따라가는 것처럼 보입니다. 요청한 것일 수도 있고 반환 된 폴리 라인에있는 것일 수도 있습니다. – geocodezip

+0

샘플 코드 – Piraba

+0

을 업데이트했습니다. 추가적으로 샘플 원본 및 대상이 예제 코드화 된 폴리 라인을 생성하는 것이 무엇인지 명확하지 않습니다. – geocodezip

답변

1

아마이는 점 평활인가 단지 에러 인 documentation :

overview_polyline는 대략적인 (평활화 된) 경로를 나타내는 인코딩 된 점의 배열을 보유하는 개체를 포함 결과 방향.

사실 내 경로가 두 번 어떻게 그려지는지 실제로 보았습니다. 마지막 점은 첫 번째 점과 연결되어 가까운 경로를 만듭니다.

콜 출력의이 요소는 원거리 확대 또는 유사한 용도로만 사용됩니다.

그러나 나머지 내용은 in this post과 같이 구문 분석 할 수 있습니다.

관련 문제