我正在创建一个ArrayList
纬度/经度坐标,然后想要获取所有这些并找到总行驶距离。但是我当前的代码一直返回 0。有人可以告诉我我做错了什么吗?
public float getDistanceTraveled() {
float[] dist = new float[1];
float totalDist = 0;
for(int i = 0; locs.size()-2 >= i; i++) {
double lat1 = locs.get(i).getLatitude();
double lon1 = locs.get(i+1).getLongitude();
double lat2 = locs.get(i).getLatitude();
double lon2 = locs.get(i+1).getLongitude();
Location.distanceBetween(lat1, lon1, lat2, lon2, dist);
totalDist += dist[0];
Log.d("", "totaldist " + String.valueOf(totalDist));
}
return totalDist;
}