T
T
try_to_find_solution2020-07-07 16:12:57
OpenStreetMap
try_to_find_solution, 2020-07-07 16:12:57

What free services exist for calculating distances between coordinates on a map?

Good day, colleagues. Consult, please. Are there any services / engines that allow you to calculate the distances between coordinates using, for example, api. Not osrm/YOURS/openrouterservice (requiring own resources) and not commercial. Approximately several million points. The accuracy of the calculation is not critical.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Sergey Pankov, 2020-07-07
@try_to_find_solution

Why do you need third party services? If there are coordinates at the input, then you can use locally either https://gdal.org/
If the points are already in postgres, then install postgis and there all the necessary functions right in the database. At least count on the fly, at least aggregate.
I can write you personally such a web service inexpensively =)

F
freeExec, 2020-07-07
@freeExec

Math is free. The formula for calculating the length on a sphere (accuracy is not important to you) was derived a thousand years ago.

R
Roman Mirilaczvili, 2020-07-07
@2ord

SQL DBMS with OpenGIS support have the functionST_Distance()

A
Anton, 2020-07-07
@anton99zel

honestly stole the code:

// Радиус земли
define('EARTH_RADIUS', 6372795);
 
/*
* Расстояние между двумя точками
* $φA, $λA - широта, долгота 1-й точки,
* $φB, $λB - широта, долгота 2-й точки
* Написано по мотивам http://gis-lab.info/qa/great-circles.html
* Михаил Кобзарев <[email protected]>
*
*/
function calculateTheDistance ($φA, $λA, $φB, $λB) {
 
// перевести координаты в радианы
$lat1 = $φA * M_PI / 180;
$lat2 = $φB * M_PI / 180;
$long1 = $λA * M_PI / 180;
$long2 = $λB * M_PI / 180;
 
// косинусы и синусы широт и разницы долгот
$cl1 = cos($lat1);
$cl2 = cos($lat2);
$sl1 = sin($lat1);
$sl2 = sin($lat2);
$delta = $long2 - $long1;
$cdelta = cos($delta);
$sdelta = sin($delta);
 
// вычисления длины большого круга
$y = sqrt(pow($cl2 * $sdelta, 2) + pow($cl1 * $sl2 - $sl1 * $cl2 * $cdelta, 2));
$x = $sl1 * $sl2 + $cl1 * $cl2 * $cdelta;
 
//
$ad = atan2($y, $x);
$dist = $ad * EARTH_RADIUS;
 
return $dist;
}
$lat1 = 77.1539;
$long1 = -139.398;
$lat2 = -77.1804;
$long2 = -139.55;
 
echo calculateTheDistance($lat1, $long1, $lat2, $long2) . " метров";
// Вернет "17166029 метров"

D
Developer, 2020-07-07
@samodum

Service for calculating 2 + 2 is not needed? And that is, I have

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question