double distance;
double distanceA =0;
String meter;
double pointY[] = {127.011016, 127.011081, 127.011113, 127.011167, 127.011253, 127.010480};
double pointX[] = {37.583560, 37.583449, 37.583143, 37.582795, 37.582395, 37.582301};
for (int i = 0; i < pointX.length; i++) {
Location locationA = new Location("point A");
locationA.setLatitude(pointX[i]);
locationA.setLongitude(pointY[i]);
Location locationB = new Location("point B");
locationB.setLatitude(pointX[i + 1]);
locationB.setLongitude(pointY[i + 1]);
distance = locationA.distanceTo(locationB);
distanceA =+distance;
}
meter = Double.toString(distanceA);
TextView distanceoutput = (TextView) findViewById(R.id.distance);
distanceoutput.setText("이동거리:" + meter + "m");
}
위도 경도로 표시된 좌표 6개의 이동거리 합을 구하려고 합니다.
distanceTo() 를 이용하여 두점 사이의 거리를 구하고 for문을 이용하여 좌표 6개의 이동거리 합을 구하려고 하는데 문법상으로는 문제가 없다고 나오는데 앱으로 돌리면 오류나면서 팅기네요 ㅠㅠ
어떤 문제인지 전혀 모르겠습니다....
도움 부탁드려요 ㅠㅠ