如何找到给定坐标的最近点

时间:2021-10-26 11:30:52

How do i identify if a point with a LAT, LONG coordinate format is near to other point.

如何识别具有LAT,LONG坐标格式的点是否接近其他点。

Lets Say i want to find all the points near to:

让我说我想找到附近的所有点:

-38.9086621 ,-68.082214

That are at less than 1km of distance. I already know how to find a coordinate in a given quadrant but not how to find a quadrant near a point.

距离不到1公里。我已经知道如何在给定象限中找到坐标,但不知道如何在点附近找到象限。

1 个解决方案

#1


0  

You can use the haversine formular to calculate distances between two given coordinates. The calculated distance is the direct connection between the given coordinates (beeline).

您可以使用hasrsine公式来计算两个给定坐标之间的距离。计算的距离是给定坐标(直线)之间的直接连接。

JavaScript example (Source):

JavaScript示例(来源):

var R = 6371e3; // meters
var lat1Radians = lat1.toRadians();
var lat2Radians = lat2.toRadians();
var deltaLat = (lat2-lat1).toRadians();
var deltaLon = (lon2-lon1).toRadians();

var a = Math.sin(deltaLat/2) * Math.sin(deltaLat/2) +
        Math.cos(lat1Radians) * Math.cos(lat2Radians) *
        Math.sin(deltaLon/2) * Math.sin(deltaLon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));

var d = R * c;

#1


0  

You can use the haversine formular to calculate distances between two given coordinates. The calculated distance is the direct connection between the given coordinates (beeline).

您可以使用hasrsine公式来计算两个给定坐标之间的距离。计算的距离是给定坐标(直线)之间的直接连接。

JavaScript example (Source):

JavaScript示例(来源):

var R = 6371e3; // meters
var lat1Radians = lat1.toRadians();
var lat2Radians = lat2.toRadians();
var deltaLat = (lat2-lat1).toRadians();
var deltaLon = (lon2-lon1).toRadians();

var a = Math.sin(deltaLat/2) * Math.sin(deltaLat/2) +
        Math.cos(lat1Radians) * Math.cos(lat2Radians) *
        Math.sin(deltaLon/2) * Math.sin(deltaLon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));

var d = R * c;