简体   繁体   English

如何在两对纬度经度之间以几米为单位获得距离

[英]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.

相关问题 如何使用php使用经度和纬度获取点之间的距离? - how to get distance between points using latitude and longitude using php? 如何从具有经度和纬度的mysql地址表中获取经度和纬度的距​​离 - How to get distance from latitude and longitude from mysql Address table which have latitude and longitude 在给定经度和纬度的情况下,如何从数据库获取到地点的距离 - How to get distance to places from DB given longitude and latitude 如何获取当前用户的经纬度并计算与位置 B 的距离? - How to get current user latitude and longitude and calculate distance with location B? 街道和点之间的距离(如果是经度和纬度) - Distance between street and point, if latitude and longitude 用于查找使用纬度和经度之间的距离的Sql返回错误的距离 - Sql for finding the distance between using latitude and longitude returns wrong distance 如何使用经度和纬度计算餐厅与该餐厅附近的 10 个司机之间的距离? - How to calculate the distance between a restaurant and 10 drivers who are nearby to that restaurant restaurant using longitude and latitude? Laravel中两个位置之间的距离在数据库查询中使用经纬度 - Distance between two locations in Laravel using latitude and longitude in database query 通过Google API获取经纬度的行驶距离 - get driving distance from latitude and longitude via google api 如何仅在经度和纬度在给定距离内时才显示查询结果 - How to Display query results only if longitude and latitude are in a given distance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM