1 | <?php |
||
14 | class Coordinate implements GeometryInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var float |
||
18 | */ |
||
19 | protected $lat; |
||
20 | |||
21 | /** |
||
22 | * @var float |
||
23 | */ |
||
24 | protected $lng; |
||
25 | |||
26 | /** |
||
27 | * @var Ellipsoid |
||
28 | */ |
||
29 | protected $ellipsoid; |
||
30 | |||
31 | /** |
||
32 | * @param float $lat -90.0 .. +90.0 |
||
33 | * @param float $lng -180.0 .. +180.0 |
||
34 | * @param Ellipsoid $ellipsoid if omitted, WGS-84 is used |
||
35 | * |
||
36 | * @throws \InvalidArgumentException |
||
37 | */ |
||
38 | public function __construct(float $lat, float $lng, Ellipsoid $ellipsoid = null) |
||
61 | |||
62 | /** |
||
63 | * @return float |
||
64 | */ |
||
65 | public function getLat(): float |
||
69 | |||
70 | /** |
||
71 | * @return float |
||
72 | */ |
||
73 | public function getLng(): float |
||
77 | |||
78 | /** |
||
79 | * Returns an array containing the point |
||
80 | * |
||
81 | * @return Coordinate[] |
||
82 | */ |
||
83 | public function getPoints(): array |
||
87 | |||
88 | /** |
||
89 | * @return Ellipsoid |
||
90 | */ |
||
91 | public function getEllipsoid(): Ellipsoid |
||
95 | |||
96 | /** |
||
97 | * Calculates the distance between the given coordinate |
||
98 | * and this coordinate. |
||
99 | * |
||
100 | * @param Coordinate $coordinate |
||
101 | * @param DistanceInterface $calculator instance of distance calculation class |
||
102 | * |
||
103 | * @return float |
||
104 | */ |
||
105 | public function getDistance(Coordinate $coordinate, DistanceInterface $calculator): float |
||
109 | |||
110 | /** |
||
111 | * @param FormatterInterface $formatter |
||
112 | * |
||
113 | * @return mixed |
||
114 | */ |
||
115 | public function format(FormatterInterface $formatter) |
||
119 | |||
120 | /** |
||
121 | * Validates latitude |
||
122 | * |
||
123 | * @param float $latitude |
||
124 | * |
||
125 | * @return bool |
||
126 | */ |
||
127 | protected function isValidLatitude(float $latitude): bool |
||
131 | |||
132 | /** |
||
133 | * Validates longitude |
||
134 | * |
||
135 | * @param float $longitude |
||
136 | * |
||
137 | * @return bool |
||
138 | */ |
||
139 | protected function isValidLongitude(float $longitude): bool |
||
143 | |||
144 | /** |
||
145 | * Checks if the given value is (1) numeric, and (2) between lower |
||
146 | * and upper bounds (including the bounds values). |
||
147 | * |
||
148 | * @param float $value |
||
149 | * @param float $lower |
||
150 | * @param float $upper |
||
151 | * |
||
152 | * @return bool |
||
153 | */ |
||
154 | protected function isNumericInBounds(float $value, float $lower, float $upper): bool |
||
158 | |||
159 | /** |
||
160 | * Returns the request in latitude and longitude strintring |
||
161 | * |
||
162 | * @return string |
||
163 | */ |
||
164 | public function __toString() { |
||
169 | } |
||
170 |