0

如何检查我当前的位置是否在我之前绘制的路线上,如果不是,则重绘路线。

所以我怎么想:我们有这样的东西:

ArrayList<LatLng> listGeopoints = new ArrayList<LatLng>()

(作为回应

String url = "http://maps.googleapis.com/maps/api/directions/xml?" 
            + "origin=" + start.latitude + "," + start.longitude  
            + "&destination=" + end.latitude + "," + end.longitude 
            + "&sensor=false&units=metric&mode=driving";

)

我必须使功能像这样

for(LatLng point : listGeopoint){
    if (checkIfPointNearly(currentPoint, point)) return true;
     else return false
}
4

1 回答 1

0

基本方法是 - 您必须检查您当前的位置是否靠近一些以前注册的点 Location 类有一种方法来测量到其他位置的距离。

对于性能 - 您可以采用 Pitagoras 公式 - 只需记住纬度是(相当)恒定的,经度根据当前纬度而变化 length_of_longitude_degree = cos(latitude)。位置距离(此方法的名称不确定)基于一些复杂的几何形状、地球的“真实”形状等,因此针对数千个地理点使用它是不明智的。

于 2013-09-24T11:38:54.257 回答