Tính khoảng cách khi biết tọa độ distance (ok)
function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2, $unit = 'miles') {
$theta = $longitude1 - $longitude2;
$distance = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)));
$distance = acos($distance);
$distance = rad2deg($distance);
$distance = $distance * 60 * 1.1515;
switch($unit) {
case 'miles':
break;
case 'kilometers' :
$distance = $distance * 1.609344;
}
return (round($distance,2));
}
Đọc thêm :)
https://app.gitbook.com/@learnsql/s/lernmysql/elasticsearch-la-gi
https://stackoverflow.com/questions/31636676/how-to-find-nearest-location-by-latitude-and-longitude
https://ourcodeworld.com/articles/read/1019/how-to-find-nearest-locations-from-a-collection-of-coordinates-latitude-and-longitude-with-php-mysql
https://martech.zone/calculate-distance/
https://www.tutorialspoint.com/elasticsearch/index.htm#:~:text=Elasticsearch%20is%20a%20real%2Dtime,the%20Apache%20license%20version%202.0.
https://viblo.asia/p/elasticsearch-example-queries-part-01-gAm5yqVA5db
https://viblo.asia/p/series-elasticsearch-huong-dan-cai-dat-elasticsearch-tren-windows-10-3P0lPmBp5ox
PreviousClientBuilder Elasticsearch (ok)NextMột cách viết ngắn gọn của quan hệ 2 ngôi ?? ' ' (ok) isset
Last updated