File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
app/Http/Controllers/Backend/Support Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -287,16 +287,19 @@ public function calculateDistance(): int {
287
287
$ geoJson = $ this ->getPolylineBetween ();
288
288
$ lastStopover = null ;
289
289
foreach ($ geoJson ->features as $ stopover ) {
290
- if ($ lastStopover !== null ) {
291
- $ distance += (new LineSegment (
292
- new Coordinate (
293
- $ lastStopover ->geometry ->coordinates [1 ],
294
- $ lastStopover ->geometry ->coordinates [0 ]
295
- ),
296
- new Coordinate ($ stopover ->geometry ->coordinates [1 ], $ stopover ->geometry ->coordinates [0 ])
297
- ))->calculateDistance ();
290
+ if ($ lastStopover === null || !isset ($ stopover ->geometry ->coordinates [0 ]) || !isset ($ stopover ->geometry ->coordinates [1 ])) {
291
+ $ lastStopover = $ stopover ;
292
+ continue ;
298
293
}
299
294
295
+ $ distance += (new LineSegment (
296
+ new Coordinate (
297
+ $ lastStopover ->geometry ->coordinates [1 ],
298
+ $ lastStopover ->geometry ->coordinates [0 ]
299
+ ),
300
+ new Coordinate ($ stopover ->geometry ->coordinates [1 ], $ stopover ->geometry ->coordinates [0 ])
301
+ ))->calculateDistance ();
302
+
300
303
$ lastStopover = $ stopover ;
301
304
}
302
305
} catch (JsonException $ e ) {
You can’t perform that action at this time.
0 commit comments