Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
point.php
1
<?php
2
3
namespace
Bitrix\Location\Geometry\Type
;
4
5
use InvalidArgumentException;
6
7
class
Point
extends
BaseGeometry
8
{
10
protected
$lat
;
11
13
protected
$lng
;
14
21
public
function
__construct
(
float
$lat
,
float
$lng
)
22
{
23
if
(!$this->
isValidLatitude
($lat))
24
{
25
throw
new
InvalidArgumentException(
'Latitude value must be numeric -90.0 .. +90.0 (given: '
.
$lat
.
')'
);
26
}
27
28
if
(!$this->
isValidLongitude
($lng))
29
{
30
throw
new
InvalidArgumentException(
31
'Longitude value must be numeric -180.0 .. +180.0 (given: '
.
$lng
.
')'
32
);
33
}
34
35
$this->lat =
$lat
;
36
$this->lng =
$lng
;
37
}
38
42
public
function
getLat
(): float
43
{
44
return
$this->lat
;
45
}
46
50
public
function
getLng
(): float
51
{
52
return
$this->lng
;
53
}
54
58
public
function
asArray
(): array
59
{
60
return
[
61
$this->lng
,
62
$this->lat
,
63
];
64
}
65
70
protected
function
isValidLatitude
(
float
$latitude): bool
71
{
72
return
$this->
isNumericInBounds
($latitude, -90.0, 90.0);
73
}
74
79
protected
function
isValidLongitude
(
float
$longitude): bool
80
{
81
return
$this->
isNumericInBounds
($longitude, -180.0, 180.0);
82
}
83
88
protected
function
isNumericInBounds
(
float
$value,
float
$lower,
float
$upper): bool
89
{
90
return
!($value < $lower || $value > $upper);
91
}
92
}
Bitrix\Location\Geometry\Type\BaseGeometry
Definition
basegeometry.php:6
Bitrix\Location\Geometry\Type\Point
Definition
point.php:8
Bitrix\Location\Geometry\Type\Point\asArray
asArray()
Definition
point.php:58
Bitrix\Location\Geometry\Type\Point\isValidLongitude
isValidLongitude(float $longitude)
Definition
point.php:79
Bitrix\Location\Geometry\Type\Point\getLng
getLng()
Definition
point.php:50
Bitrix\Location\Geometry\Type\Point\__construct
__construct(float $lat, float $lng)
Definition
point.php:21
Bitrix\Location\Geometry\Type\Point\$lng
$lng
Definition
point.php:13
Bitrix\Location\Geometry\Type\Point\isNumericInBounds
isNumericInBounds(float $value, float $lower, float $upper)
Definition
point.php:88
Bitrix\Location\Geometry\Type\Point\getLat
getLat()
Definition
point.php:42
Bitrix\Location\Geometry\Type\Point\isValidLatitude
isValidLatitude(float $latitude)
Definition
point.php:70
Bitrix\Location\Geometry\Type\Point\$lat
$lat
Definition
point.php:10
Bitrix\Location\Geometry\Type
Definition
basegeometry.php:3
modules
location
lib
geometry
type
point.php
Создано системой
1.10.0