########################################################################################## VEH-63: Journey Map broken ########################################################################################## Issue Type: Bug ----------------------------------------------------------------------------------------- Issue Information ==================== Priority: Critical Status: Closed Resolution: Done (2013-12-28 21:14:17) Project: VehMan (VEH) Reported By: btasker Assigned To: btasker Affected Versions: - 1.0.15 Targeted for fix in version: - 1.0.2 Time Estimate: 0 minutes Time Logged: 0 minutes ----------------------------------------------------------------------------------------- Issue 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 ----------------------------------------------------------------------------------------- Activity ========== ----------------------------------------------------------------------------------------- 2013-12-28 19:57:10 ----------------------------------------------------------------------------------------- btasker changed priority from '[issuelistpty 3]Major[/issuelistpty]' to '[issuelistpty 2]Critical[/issuelistpty]' ----------------------------------------------------------------------------------------- 2013-12-28 19:57:12 ----------------------------------------------------------------------------------------- btasker changed status from 'Open' to 'In Progress' ----------------------------------------------------------------------------------------- 2013-12-28 19:58:32 btasker ----------------------------------------------------------------------------------------- Have disabled the chart cache to aid in troubleshooting -- BEGIN QUOTE -- lib/Charts/api_init.php var $cacheenabled = false; //For debugging purposes only, should be true -- END QUOTE -- ----------------------------------------------------------------------------------------- 2013-12-28 20:01:50 btasker ----------------------------------------------------------------------------------------- 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. ----------------------------------------------------------------------------------------- 2013-12-28 20:01:50 ----------------------------------------------------------------------------------------- btasker added 'chartsrc.txt' to Attachments ----------------------------------------------------------------------------------------- 2013-12-28 20:06:28 btasker ----------------------------------------------------------------------------------------- There does seem to be location data in the DB -- BEGIN QUOTE -- 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) -- END QUOTE -- ----------------------------------------------------------------------------------------- 2013-12-28 20:18:23 btasker ----------------------------------------------------------------------------------------- Added some debug code to Charts submodule -- BEGIN QUOTE -- $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); -- END QUOTE -- 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 ----------------------------------------------------------------------------------------- 2013-12-28 20:19:16 btasker ----------------------------------------------------------------------------------------- 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. ----------------------------------------------------------------------------------------- 2013-12-28 20:24:40 btasker ----------------------------------------------------------------------------------------- Obviously changing the logic of the helper may have a knock on effect for other submodules. Checking where its called from -- BEGIN QUOTE -- $ 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); -- END QUOTE -- 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 ----------------------------------------------------------------------------------------- 2013-12-28 20:31:40 btasker ----------------------------------------------------------------------------------------- Commit 9d363de implements the fix. Same code has been manually applied to the Production API as an emergency patch ----------------------------------------------------------------------------------------- 2013-12-28 20:37:12 btasker ----------------------------------------------------------------------------------------- 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. ----------------------------------------------------------------------------------------- 2013-12-28 21:14:10 btasker ----------------------------------------------------------------------------------------- Charts are now generating correctly. Have re-enabled the chart cache ----------------------------------------------------------------------------------------- 2013-12-28 21:14:17 ----------------------------------------------------------------------------------------- btasker changed status from 'In Progress' to 'Resolved' ----------------------------------------------------------------------------------------- 2013-12-28 21:14:17 ----------------------------------------------------------------------------------------- btasker added 'Done' to resolution ----------------------------------------------------------------------------------------- 2013-12-28 21:14:21 ----------------------------------------------------------------------------------------- btasker changed status from 'Resolved' to 'Closed'