From 9e2c8fa85ec59c0ec20a4a1ac6287862fa7ccb9c Mon Sep 17 00:00:00 2001 From: Jens Hassler Date: Sun, 28 Feb 2021 11:40:44 +0100 Subject: [PATCH] do SORT_BY_TIMESTAMP only for tracks with timestamps --- src/phpGPX/Models/Route.php | 2 +- src/phpGPX/Models/Track.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/phpGPX/Models/Route.php b/src/phpGPX/Models/Route.php index 5e28553..c9677c4 100644 --- a/src/phpGPX/Models/Route.php +++ b/src/phpGPX/Models/Route.php @@ -47,7 +47,7 @@ public function getPoints() $points = array_merge($points, $this->points); - if (phpGPX::$SORT_BY_TIMESTAMP && !empty($points)) { + if (phpGPX::$SORT_BY_TIMESTAMP && !empty($points) && $points[0]->time !== null) { usort($points, array('phpGPX\Helpers\DateTimeHelper', 'comparePointsByTimestamp')); } diff --git a/src/phpGPX/Models/Track.php b/src/phpGPX/Models/Track.php index 3b02888..18d365c 100644 --- a/src/phpGPX/Models/Track.php +++ b/src/phpGPX/Models/Track.php @@ -46,7 +46,7 @@ public function getPoints() $points = array_merge($points, $segment->points); } - if (phpGPX::$SORT_BY_TIMESTAMP && !empty($points)) { + if (phpGPX::$SORT_BY_TIMESTAMP && !empty($points) && $points[0]->time !== null) { usort($points, array('phpGPX\Helpers\DateTimeHelper', 'comparePointsByTimestamp')); }