定义了两个GEO地点之间距离的门槛? [英] Defining a threshold for Distance between two GEO Locations?

查看:141
本文介绍了定义了两个GEO地点之间距离的门槛?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到我的适用的两个GEO位置,我与他们之间的距离计算后,计算距离我有这个结果比较与定义的阈值这是在我的情况下50米,我将如何界定浮动的门槛。此外,目前,我在我的Andr​​oid Fone公司是在同一位置,但我总是得到一个时间间隔后确定为50多米我2两geolocations之间的距离计算。这怎么可能?我正在为50米门限值为:

I am getting two GEO locations in my application and I have to calculate distance between them and after distance calculation I have to compare that result with the a defined threshold which is in my case 50 meters, how would I define that threshold in float. Also, Currently I my android fone is at the same location, but I always get the calculated distance between my 2 two geolocations determined after an interval to be more than 50 meters. How is it possible? I am taking threshold of 50 meters as:

private static final float DISTANCE_CHANGE_METERS = 50.0f; //50 meters

和我通过以下公式计算距离我上StackOverflow的发现:

and I am calculating distance through following formula I found on StackOverflow:

public static float distFrom(double lat1, double lng1, double lat2, double lng2) {

    double earthRadius = 3958.75;
    double dLat = Math.toRadians(lat2 - lat1);
    double dLng = Math.toRadians(lng2 - lng1);
    double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(dLng / 2) * Math.sin(dLng / 2);
    double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
    double dist = earthRadius * c;

    int meterConversion = 1609;

    return new Float(dist * meterConversion).floatValue();
}

请帮我在这方面。谢谢!

Kindly help me out in this regard. Thanks!

推荐答案

目前我的Andr​​oid手机是在同一位置,但我总是得到一个区间后确定我2两geolocations之间的计算距离超过50米。这怎么可能?

这实际上取决于你是如何传递的经度和纬度的 distFrom 功能。只是提醒你,有一个简单的计算遥远的距离。结果
您可以使用的 distanceTo()函数= nofollow的> Android的API 使用位置来计算这样的两地之间的距离:

It actually depends on how you are passing the latitude and longitude to the distFrom function. Just to remind you that there is a simpler way to calculate the distance.
You can use just distanceTo() function in android API using Location to calculate the distance between two places like this:

Location locationA = new Location("point A");
locationA.setLatitude(latA); // co-ordinates in double
locationA.setLongitude(lngA);

Location locationB = new Location("point B");
locationB.setLatitude(latB);
locationB.setLongitude(lngB);

float distance = locationA.distanceTo(locationB);

如果用这个你也得到一个更大的距离超过50米,然后,你所提供的坐标后,不准确。其完美的罚款,因为它的强硬小于50米precision得到准确度。如果您正在使用GPS使用以及互联网这将是最准确的。如果你看到这里,即使您使用 ACCURACY_HIGH 作为标准来选择位置提供,它提供了不到100米的精度。它可以精确高达100,70或甚至50米。因此,即使是最准确的选项是不能保证得到极高的精度。如果您在使用GPS /网络提供商获取的位置,那么你的情况是非常可能的。获得使用`网络Provider1的位置也并不准确,因为它可以捕捉不同场合2网络塔,它可以很好地分开身体的信号。

If after using this also you are getting a distance greater than 50 meters then your co-ordinates that you are providing are not that accurate. Its perfectly fine because its tough to get accuracy with less that 50 meter precision. It would be most accurate if you are using internet along with GPS. If you see here, even if you use ACCURACY_HIGH as a criteria to choose a Location Provider, it provides accuracy of less than 100 meters. It can be accurate upto 100, 70 or even 50 meters. So even the most accurate option is not guaranteed to give extreme accuracy. If you are using GPS/Network provider for getting Location, then it your situation is very much possible. Getting location using `Network Provider1 is also not that accurate as it can catch signals of 2 network towers on different occasions, which can be well apart physically.

希望它可以帮助和清除点在一定程度上。它的问题到你的位置提供精度。

Hope it helps and clears the point to some extent. Its the problem to accuracy of your Location Provider.

这篇关于定义了两个GEO地点之间距离的门槛?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆