경로표시 어플을 제작하는 중에 인터넷에서 이런 소스를 찾았습니다.
이 소스를 바탕으로 어플을 만들려고 실행해봤는데
경로 기록이 첨부한 이미지처럼 계속 이상한 값이 튀는데 이건 어떻게 해결해야될까요??
(이미지에 보이는 것처럼 경로를 따라 기록하다가 한번 이상한 점으로 뛰는데 그 값은 항상 동일)
지금 위치 제공자로 GPS, NETWORK 등등에서 Best로 받는데 혹시 이상한걸까봐 GPS 하나만 받게 소스를 고쳐도 제대로 된값이 나오지 않습니다.;;
중간에 이렇게 값이 하나씩 튀어서 제대로 경로가 기록되지 않습니다.
어떻게 해결해야 할까요 ㅠㅠ

[출처] 안드로이드사이드 - http://www.androidside.com /B49/49526

SC20110908-234941.png

 

자체답변 :

인터넷에서 GPX 파일을 구해서 에뮬레이터로 돌려보니 소스에는 문제가 없더라구요 -_-;;

근데 갤탭에서만 이런 문제가 생기나 하고 다른 안드로이드 10가지 정도에 돌려봤는데 다들 이런 문제가 있더라구요

그래서 값이 튀는 부분에서 값이 튈 때 그 값을 무시하고 지나가게 소스를 살짝 변경했습니다.

MyOverlayClass.java 에 있는 updatePath 를 아래와 같이 바꾸시면 됩니다 

 public void updatePath()
 {
  
  for(int i = 0 ; i < mMyPathLocationArray.size() ; i++)
  {
   Point startPoint = new Point();
   Point endPoint = new Point();
   Point tempPoint = new Point(); 
   int check=0;
   
MyPathLocation temp = mMyPathLocationArray.get(i);
mMapView.getProjection().toPixels(new GeoPoint((int)(temp.mMyBeforeLocation.getLatitude()*1E6), (int)(temp.mMyBeforeLocation.getLongitude()*1E6)), startPoint);
   mMapView.getProjection().toPixels(new GeoPoint((int)(temp.mMyCurrentLocation.getLatitude()*1E6), (int)(temp.mMyCurrentLocation.getLongitude()*1E6)), endPoint);
   
   Path p = new Path();
   
   p.reset();
   if((Math.abs(startPoint.x - endPoint.x) > 15)||(Math.abs(startPoint.y - endPoint.y) > 15)){
    if(check==1){
     startPoint = tempPoint;
     check=0;
    }
    else {
     tempPoint = startPoint;
     check++;
    }
     continue;
   }
   else {
    p.moveTo(startPoint.x, startPoint.y);
    p.lineTo(endPoint.x, endPoint.y);
   }
   mPath.addPath(p);
  }
 }