1 | <?php |
||
26 | class Coordinate implements GeometryInterface |
||
27 | { |
||
28 | /** |
||
29 | * @var float |
||
30 | */ |
||
31 | protected $lat; |
||
32 | |||
33 | /** |
||
34 | * @var float |
||
35 | */ |
||
36 | protected $lng; |
||
37 | |||
38 | /** |
||
39 | * @var Ellipsoid |
||
40 | */ |
||
41 | protected $ellipsoid; |
||
42 | |||
43 | /** |
||
44 | * @param float $lat -90.0 .. +90.0 |
||
45 | * @param float $lng -180.0 .. +180.0 |
||
46 | * @param Ellipsoid $ellipsoid if omitted, WGS-84 is used |
||
47 | * |
||
48 | * @throws \InvalidArgumentException |
||
49 | */ |
||
50 | public function __construct($lat, $lng, Ellipsoid $ellipsoid = null) |
||
69 | |||
70 | /** |
||
71 | * @return float |
||
72 | */ |
||
73 | public function getLat() |
||
77 | |||
78 | /** |
||
79 | * @return float |
||
80 | */ |
||
81 | public function getLng() |
||
85 | |||
86 | /** |
||
87 | * Returns an array containing the point |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | public function getPoints() |
||
95 | |||
96 | /** |
||
97 | * @return Ellipsoid |
||
98 | */ |
||
99 | public function getEllipsoid() |
||
103 | |||
104 | /** |
||
105 | * Calculates the distance between the given coordinate |
||
106 | * and this coordinate. |
||
107 | * |
||
108 | * @param Coordinate $coordinate |
||
109 | * @param DistanceInterface $calculator instance of distance calculation class |
||
110 | * |
||
111 | * @return float |
||
112 | */ |
||
113 | public function getDistance(Coordinate $coordinate, DistanceInterface $calculator) |
||
117 | |||
118 | /** |
||
119 | * @param FormatterInterface $formatter |
||
120 | * |
||
121 | * @return mixed |
||
122 | */ |
||
123 | public function format(FormatterInterface $formatter) |
||
127 | |||
128 | /** |
||
129 | * Validates latitude |
||
130 | * |
||
131 | * @param mixed $latitude |
||
132 | * |
||
133 | * @return bool |
||
134 | */ |
||
135 | protected function isValidLatitude($latitude) |
||
139 | |||
140 | /** |
||
141 | * Validates longitude |
||
142 | * |
||
143 | * @param mixed $longitude |
||
144 | * |
||
145 | * @return bool |
||
146 | */ |
||
147 | protected function isValidLongitude($longitude) |
||
151 | |||
152 | /** |
||
153 | * Checks if the given value is (1) numeric, and (2) between lower |
||
154 | * and upper bounds (including the bounds values). |
||
155 | * |
||
156 | * @param float $value |
||
157 | * @param float $lower |
||
158 | * @param float $upper |
||
159 | * |
||
160 | * @return bool |
||
161 | */ |
||
162 | protected function isNumericInBounds($value, $lower, $upper) |
||
174 | } |
||
175 |