1 | <?php |
||
13 | final class TrackPoint |
||
14 | { |
||
15 | /** |
||
16 | * Latitude of the point. |
||
17 | * |
||
18 | * @var float |
||
19 | */ |
||
20 | private $latitude; |
||
21 | |||
22 | /** |
||
23 | * Longitude of the point. |
||
24 | * |
||
25 | * @var float |
||
26 | */ |
||
27 | private $longitude; |
||
28 | |||
29 | /** |
||
30 | * Elevation of the point. |
||
31 | * |
||
32 | * @var float |
||
33 | */ |
||
34 | private $elevation; |
||
35 | |||
36 | /** |
||
37 | * The time for the point. |
||
38 | * |
||
39 | * @var \DateTimeImmutable |
||
40 | */ |
||
41 | private $dateTime; |
||
42 | |||
43 | /** |
||
44 | * Array of extensions. |
||
45 | * |
||
46 | * @var ExtensionInterface[] |
||
47 | */ |
||
48 | private $extensions = array(); |
||
49 | |||
50 | /** |
||
51 | * @param float $latitude The latitude. |
||
52 | * @param float $longitude The longitude. |
||
53 | * @param \DateTimeImmutable $dateTime The date and time of the point. |
||
54 | * @param float|null $elevation |
||
55 | * @param array $extensions |
||
56 | */ |
||
57 | private function __construct( |
||
73 | |||
74 | /** |
||
75 | * Add an extension to the workout. |
||
76 | * |
||
77 | * @param ExtensionInterface $extension The extension to add. |
||
78 | */ |
||
79 | private function addExtension(ExtensionInterface $extension) |
||
83 | |||
84 | /** |
||
85 | * @param float|null $latitude |
||
86 | * @param float|null $longitude |
||
87 | * @param \DateTimeImmutable $dateTime |
||
88 | * @param float|null $elevation |
||
89 | * @param array $extensions |
||
90 | * @return TrackPoint |
||
91 | */ |
||
92 | public static function with( |
||
107 | |||
108 | /** |
||
109 | * Get the elevation. |
||
110 | * |
||
111 | * @return float |
||
112 | */ |
||
113 | public function elevation(): float |
||
117 | |||
118 | /** |
||
119 | * Get the extensions. |
||
120 | * |
||
121 | * @return ExtensionInterface[] |
||
122 | */ |
||
123 | public function extensions(): array |
||
127 | |||
128 | |||
129 | /** |
||
130 | * Check if an extension is present. |
||
131 | * |
||
132 | * @param string $idExtension The ID of the extension. |
||
133 | * @return boolean |
||
134 | */ |
||
135 | public function hasExtension(string $idExtension): bool |
||
139 | |||
140 | /** |
||
141 | * Get an extension by ID. |
||
142 | * |
||
143 | * @param string $idExtension The ID of the extension. |
||
144 | * @return ExtensionInterface |
||
145 | * @throws \OutOfBoundsException If the extension is not found. |
||
146 | */ |
||
147 | public function extension($idExtension): ExtensionInterface |
||
155 | |||
156 | /** |
||
157 | * Get the latitude. |
||
158 | * |
||
159 | * @return float |
||
160 | */ |
||
161 | public function latitude(): ?float |
||
165 | |||
166 | /** |
||
167 | * Get the longitude. |
||
168 | * |
||
169 | * @return float |
||
170 | */ |
||
171 | public function longitude(): ?float |
||
175 | |||
176 | /** |
||
177 | * Get the date time of the point. |
||
178 | * |
||
179 | * @return \DateTimeImmutable |
||
180 | */ |
||
181 | public function dateTime(): \DateTimeImmutable |
||
185 | |||
186 | /** |
||
187 | * Get the distance between this point and another point in meters. |
||
188 | * |
||
189 | * @param TrackPoint $trackPoint The other point. |
||
190 | * @return float The distance in meters. |
||
191 | */ |
||
192 | public function distanceFromPoint(TrackPoint $trackPoint): float |
||
213 | |||
214 | /** |
||
215 | * Get the speed between this point and another point in km/h. |
||
216 | * |
||
217 | * @param TrackPoint $trackPoint The other point. |
||
218 | * @return float |
||
219 | */ |
||
220 | public function speed(TrackPoint $trackPoint): float |
||
235 | } |
||
236 |