Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
point.php
1<?php
2
4
5use InvalidArgumentException;
6
7class 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 [
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}
isValidLongitude(float $longitude)
Definition point.php:79
__construct(float $lat, float $lng)
Definition point.php:21
isNumericInBounds(float $value, float $lower, float $upper)
Definition point.php:88
isValidLatitude(float $latitude)
Definition point.php:70