开发者

Location.distanceTo uses the error parameter in approximate distance calculation?

I am wondering if the Location.distanceTo method will use the accuracy field of the Location object when approximates the location, or do I have to add by my own the errors to these fields. The usage is to开发者_如何学运维 compare the distance against a proximity value.

Float dist=currentLocation.distanceTo(loc2);

Would this be

if (dist<100meters)

or

if (dist+currentLocation.getAccuracy()+loc2.getAccuracy()<100meters)


It looks like it ignores accuracy:
https://android.googlesource.com/platform/frameworks/base/+/donut-release/location/java/android/location/Location.java#400

 400     /**
 401      * Returns the approximate distance in meters between this
 402      * location and the given location.  Distance is defined using
 403      * the WGS84 ellipsoid.
 404      *
 405      * @param dest the destination location
 406      * @return the approximate distance in meters
 407      */
 408     public float distanceTo(Location dest) {
 409         // See if we already have the result
 410         synchronized (mResults) {
 411             if (mLatitude != mLat1 || mLongitude != mLon1 ||
 412                 dest.mLatitude != mLat2 || dest.mLongitude != mLon2) {
 413                 computeDistanceAndBearing(mLatitude, mLongitude,
 414                     dest.mLatitude, dest.mLongitude, mResults);
 415                 mLat1 = mLatitude;
 416                 mLon1 = mLongitude;
 417                 mLat2 = dest.mLatitude;
 418                 mLon2 = dest.mLongitude;
 419                 mDistance = mResults[0];
 420                 mInitialBearing = mResults[1];
 421             }
 422             return mDistance;
 423         }
 424     }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜