Answer the question
In order to leave comments, you need to log in
How to calculate the distance in kilometers by the coordinates of longitude and latitude?
A request comes from the client with its gps (android, ios) data and I make a request to mysql to select the object closest to it that I need (just the longitude latitude object is stored there)
$arrayToSort[$i]['pos'] =(abs($value[0] - $userPos[0]) + abs($value[1] - $userPos[1]));
usort($ArrReadyToSort, "cmp");
$arrayToSort[$i]['pos'] =(abs($value[0] - $userPos[0]) + abs($value[1] - $userPos[1]));
Answer the question
In order to leave comments, you need to log in
Haversine formula:
const double R=6371; // Earth's radius
double sin1=sin((lat1-lat2)/2);
double sin2=sin((lon1-lon2)/2);
return 2*R*asin(sqrt(sin1*sin1+sin2*sin2*cos(lat1)*cos(lat2)));
Good day, dear ones! )
I have a similar problem, but I can't figure out how to apply this formula in MySQL.
I need to calculate the total distance traveled from a list of coordinates, preferably in km, or meters for a given period of time.
SELECT SUM )
FROM `data`
WHERE `ID_Dev` = 1 and
`DateTime` BETWEEN '2021-05-04 08:00:00' AND '2021-05-04 20:00:00'
Can someone help me build a MySQL query to this formula processed the coordinates and gave the total total distance?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question