Reported on Github as #10
If speed isn't present in the source GPX file, and has instead been calculated (i.e.
calcDistance has been enabled), a number of E_WARNINGS are raised as a result of trying to generate acceleration stats
Warning: max() [function.max]: Array must contain at least one element in \GPXIngest.php on line 947
Warning: max() [function.max]: Array must contain at least one element in \GPXIngest.php on line 948
Warning: min() [function.min]: Array must contain at least one element in \GPXIngest.php on line 949
Warning: min() [function.min]: Array must contain at least one element in \GPXIngest.php on line 950
Warning: Division by zero in \GPXIngest.php on line 952
Warning: Division by zero in \GPXIngest.php on line 953
The relevant lines are
$this->journey->journeys->$jkey->stats->maxacceleration = max($this->faccel);
$this->journey->journeys->$jkey->stats->maxdeceleration = max($this->fdecel);
$this->journey->journeys->$jkey->stats->minacceleration = min($this->faccel);
$this->journey->journeys->$jkey->stats->mindeceleration = min($this->fdecel);
$this->journey->journeys->$jkey->stats->avgacceleration = round(array_sum($this->faccel)/count($this->faccel),2);
$this->journey->journeys->$jkey->stats->avgdeceleration = round(array_sum($this->fdecel)/count($this->fdecel),2);
Activity
2016-02-21 19:54:32
GPXIN-16 also saw these errors, the fix at the time was to suppress speed if it wasn't present in the GPX file, but the implementation of calcDistance (GPXIN-6) has essentially overridden that protection.
2016-02-21 19:54:46
2016-02-21 20:03:40
But ptspeed is supposed to be set during the calculations
Dropping some debug into calculateAcceleration we do seem to be passing it calculated values
And we do seem to be getting Acceleration stats
So it doesn't look like that's the root cause.
Will try and get a copy of the GPX file the user is using - wonder if they've got a track with only one trackpoint or something? Should really check whether those arrays are empty before running max/min on them though
2016-02-21 20:03:46
2016-02-21 20:06:07
2016-02-21 20:11:51
2016-02-21 20:12:32
Webhook User-Agent
View Commit
2016-02-22 07:07:07
The speed (and by extension (ac|de)cel) calculations are based on lat/lon. But in that file they're static (though the user's elevation is changing) so we wouldn't record any values to push into those arrays.
2016-02-22 07:11:37
Whether or not that's a bad thing I can't decide. If we introduce calculation of 0 values then we're talking average acceleration over a track. Without, we're talking average rate of acceleration when accelerating which is a subtle but fairly important distinction. I can see a use-case for both, though I think the currently existing stats will have to continue to use the status quo, as the calculations are correct (if a little ambiguous) I don't want to break b/c over them
2017-07-04 12:13:25
Having a file with absolutely no lat/lon present, but static, whilst only elevation changes across the whole file is such an edge case (unless you're interested in tracking journeys in lifts), that it doesn't seem worth putting too much effort into.
The commit above should have fixed the warnings in any case.
2017-07-04 12:13:25
2017-07-04 12:13:25
2017-07-04 12:13:29