[英]How to get distance in few meters between 2 pair of latitude longitude
I would like to calculate distance between 2 points of latitude and longitude in PHP (NOT IN ANDROID)**i have read about **Haversine Formula and Spherical Law of Cosines for calculate distance between two points but my main motive is get best location difference between 2 points in Meters.我想在PHP 中计算纬度和经度 2 点之间的距离(不在 ANDROID 中)**我已经阅读了关于 **Haversine 公式和余弦球面定律来计算两点之间的距离,但我的主要动机是获得最佳位置差异以米为单位的 2 点之间。
For Example Two devices place at next to each other and that android devices is sending location to server,So we need to take that location of each device and calculate minimum distance between these 2 device in meter.Result from Server after calculation should be like in 2-3 meters when device is placed next to each others例如,两个设备彼此相邻放置,而 android 设备正在向服务器发送位置,因此我们需要获取每个设备的位置并计算这两个设备之间的最小距离(以米为单位)。计算后服务器的结果应如下所示设备并排放置时为 2-3 米
So what are the possible ways to calculate minimum distance between two device in meters when device next to each other on server side那么当设备在服务器端彼此相邻时,有哪些可能的方法来计算两个设备之间的最小距离(以米为单位)
Note : I need to calculate distance which i got in kms or miles which is big difference when device is next to each other.注意:我需要计算以公里或英里为单位的距离,这在设备彼此相邻时会有很大差异。 Haversine Formula and Spherical Law of Cosines is i found best way to calculate but i need to do more in these formulas to get minimum difference between 2 device.Not on Android Device.
余弦的半正弦公式和球面定律是我找到的最佳计算方法,但我需要在这些公式中做更多工作才能获得 2 个设备之间的最小差异。不是在 Android 设备上。 This question is not related to This Question
此问题与此问题无关
I have used the Haversine formula in PHP to calculate distance in kms between two geocoordinates:我在 PHP 中使用了 Haversine 公式来计算两个地理坐标之间的距离(以公里为单位):
// Haversine formula
function geoDistance($lon1, $lat1, $lon2, $lat2) {
$R = 6371; // Radius of the earth in km
$dLat = deg2rad($lat2 - $lat1);
$dLon = deg2rad($lon2 - $lon1);
$a = sin($dLat/2) * sin($dLat/2) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * sin($dLon/2) * sin($dLon/2);
$c = 2 * atan2(sqrt($a), sqrt(1-$a));
$d = $R * $c; // Distance in km
return $d;
}
I guess, having enough precision in lon and lat would yield a result that multiplied by 1,000 migth be useful as a measure of distance in meters, right?我想,在 lon 和 lat 中有足够的精度会产生乘以 1,000 migth 的结果,作为以米为单位的距离度量是有用的,对吗?
According to https://gis.stackexchange.com/questions/8650/measuring-accuracy-of-latitude-and-longitude the fifth decimal place is worth up to 1.1 m: it distinguish trees from each other.根据https://gis.stackexchange.com/questions/8650/measuring-accuracy-of-latitude-and-longitude ,小数点后第五位的价值高达 1.1 m:它将树木彼此区分开来。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.