Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
distancecalculator.php
1
<?php
2
3
namespace
Bitrix\Location\Entity\Location
;
4
5
use
Bitrix\Location\Entity\Location
;
6
12
class
DistanceCalculator
13
{
14
private
const
EARTH_RADIUS = 6371;
15
21
public
function
calculate
(
Location
$location1,
Location
$location2)
22
{
23
if
(
24
empty($location1->
getLatitude
())
25
|| empty($location1->
getLongitude
())
26
|| empty($location2->
getLatitude
())
27
|| empty($location2->
getLongitude
())
28
)
29
{
30
return
false
;
31
}
32
33
$lat1 = $location1->
getLatitude
() / 180 * M_PI;
34
$lat2 = $location2->
getLatitude
() / 180 * M_PI;
35
$lon1 = $location1->
getLongitude
() / 180 * M_PI;
36
$lon2 = $location2->
getLongitude
() / 180 * M_PI;
37
38
return
(
float
)acos(sin($lat1)*sin($lat2)
39
+ cos($lat1)*cos($lat2)
40
* cos($lon2-$lon1))
41
* self::EARTH_RADIUS;
42
}
43
}
Bitrix\Location\Entity\Location\DistanceCalculator
Definition
distancecalculator.php:13
Bitrix\Location\Entity\Location\DistanceCalculator\calculate
calculate(Location $location1, Location $location2)
Definition
distancecalculator.php:21
Bitrix\Location\Entity\Location
Definition
location.php:20
Bitrix\Location\Entity\Location\getLongitude
getLongitude()
Definition
location.php:442
Bitrix\Location\Entity\Location\getLatitude
getLatitude()
Definition
location.php:424
Bitrix\Location\Entity\Location
Definition
collection.php:3
modules
location
lib
entity
location
distancecalculator.php
Создано системой
1.10.0