How to find the distance of coordinates between two points

This article shows how to find the straight line distance between two points from their latitude and longitude.

What is latitude and longitude?

If you have arrived here, there is no need to explain it now, but I will explain it just in case.
Latitude and longitude are a coordinate system that expresses our position on the earth. Latitude is the angle from the equator, and longitude is the angle from the meridian line passing through the site of Greenwich Observatory in England.
Some people may find it easier to understand if they remember that longitude is in the x-direction and latitude is in the y-direction.
Using these values, we can calculate the distance between two points on the earth.

Algorithm for finding a straight line distance from latitude and longitude

Several algorithms exist to determine linear distances from latitude and longitude.
These methods can be used depending on the shape of the earth and accuracy requirements.
This article describes three typical types.

Hybeny's Distance Formula

It is obtained from the commonly used Hybeny's distance formula.

Haversine Formula

The GoogleMapAPI geometory.computeDistanceBetween uses this formula.
In reality, the earth is not an exact sphere but an ellipsoid, so there is an error, but the formula is simple and can be calculated quickly.

Geodesic Navigation

Finally

The above sources are available in Composer, so you can try them yourself for speed and performance.

composer require chiyoyo/distance
Bash

コメント

Copied title and URL