VEH-63: Journey Map broken



Issue Information

Issue Type: Bug
 
Priority: Critical
Status: Closed

Reported By:
Ben Tasker
Assigned To:
Ben Tasker
Project: VehMan (VEH)
Resolution: Done (2013-12-28 21:14:17)
Affects Version: 1.0.15,
Target version: 1.0.2,

Created: 2013-12-27 23:18:09
Time Spent Working


Description
The Journey maps aren't generating. Any Journey imported after Track ID 102 doesn't display a route (possible the Journeys before only display because they're cached prior to a change).

Speed chart displays correctly.


Attachments

chartsrc.txt

Subtasks

VEH-64: Update Documentation to reflect fix
Toggle State Changes

Activity


btasker changed priority from 'Major' to 'Critical'
btasker changed status from 'Open' to 'In Progress'
Have disabled the chart cache to aid in troubleshooting


lib/Charts/api_init.php

var $cacheenabled = false; //For debugging purposes only, should be true

With cache disabled, the older journeys still show a route.

Viewing the source of a newer route, the lat/lon points aren't being written into the page (attached).

Suggests a data issue rather than a logic issue.
btasker added 'chartsrc.txt' to Attachments
There does seem to be location data in the DB


mysql> SELECT * FROM JourneySegments WHERE TrackID=129;

| segmentID | trackID | start | end | maxSpeed | minSpeed | modalSpeed | avgSpeed | journeyDuration | status | maxEle | minEle | EleAvgChange | timeMoving | timeStationary | timeAccelerating | timeDecelerating |
| 2534 | 129 | 1388080522 | 1388080850 | 29 | 0 | 6 | 11.13 | 328 | 1 | 80 | 66 | 0 | 317 | 8 | 35 | 268 |
1 row in set (0.03 sec)

mysql> SELECT MAX(Lat) FROM JourneyTrackPoints WHERE SegmentID=2534;

| MAX(Lat) |
| 52.129815 |
1 row in set (0.06 sec)

mysql> SELECT MAX(Lon) FROM JourneyTrackPoints WHERE SegmentID=2534;

| MAX(Lon) |
| 1.415866 |
1 row in set (0.00 sec)

mysql> SELECT COUNT\(\) FROM JourneyTrackPoints WHERE SegmentID=2534;

| COUNT\(
\) |
| 86 |
1 row in set (0.00 sec)


mysql> SELECT * FROM JourneyTrackPoints WHERE SegmentID=2534 AND speedint > 0 LIMIT 5;

| TrackPtID | segmentID | JourneyID | VehicleID | lat | lon | time | speed | speedint | elevation | acceleration | deceleration | elevationChange |
| 436719 | 2534 | 101 | 28 | 52.129815 | 1.415846 | 1388080522 | 2 mph | 2 | 66 | 0.0000 | 0.0000 | 0 |
| 436720 | 2534 | 101 | 28 | 52.129757 | 1.415771 | 1388080760 | 1 mph | 1 | 80 | 0.0000 | 0.0019 | 14 |
| 436721 | 2534 | 101 | 28 | 52.129755 | 1.415783 | 1388080761 | 1 mph | 1 | 80 | 0.0000 | 0.0000 | 0 |
| 436722 | 2534 | 101 | 28 | 52.129749 | 1.415797 | 1388080762 | 2 mph | 2 | 80 | 0.4470 | 0.0000 | 0 |
| 436723 | 2534 | 101 | 28 | 52.129744 | 1.415815 | 1388080763 | 2 mph | 2 | 80 | 0.0000 | 0.0000 | 0 |
5 rows in set (0.00 sec)

Added some debug code to Charts submodule


$track = VehMan_API_Journey_Helper::getRoute($this->veh->VehicleID);
ob_start();
print_r($track);
$fh = fopen('/tmp/test.txt','w');
fwrite($fh,ob_get_clean());
fclose($fh);


File is created, but is empty, so for some reason the Journey is coming back blank.

Suggests the helper is failing to retrieve any data

The cause is a logic error in the helper. It treats the second part of the URL (if specified) as a Segment ID when in fact it's a TrackID. So the routes aren't displaying because there is no Segment with that ID.
Obviously changing the logic of the helper may have a knock on effect for other submodules. Checking where its called from


$ grep "getRoute" -R *
lib/Journey/api_init.php: return VehMan_API_Journey_Helper::getRoute(VehMan_API_Vehicle_Helper::getVehDetails($this->reg)->VehicleID);
lib/Journey/helper.php: static function getRoute($vehicle){
lib/Charts/api_init.php: $track = VehMan_API_Journey_Helper::getRoute($this->veh->VehicleID);


The Call within the Journey submodule is for the getjourneytrack call. The documentation makes reference to using a Segment ID, so the documentation will need to be updated if a logic change is made to use Tracks (which seems a logical decision). - http://www.vehiclefueltracker.co.uk/developers/index#11:journeysJourneyPathDetails
Commit 9d363de implements the fix. Same code has been manually applied to the Production API as an emergency patch
Think the cause of the break was really different logic being used in VehMan Legacy to list the available charts, however following work on VehManPi it does seem more logical to refer to tracks than segments.
Charts are now generating correctly. Have re-enabled the chart cache
btasker changed status from 'In Progress' to 'Resolved'
btasker added 'Done' to resolution
btasker changed status from 'Resolved' to 'Closed'