##########################################################################################
GPXIN-27: Route Support
##########################################################################################
Issue Type: New Feature
-----------------------------------------------------------------------------------------
Issue Information
====================
Priority: Major Status: Closed
Resolution: Done (2017-07-04 14:28:40)
Project: PHP GPXIngest (GPXIN)
Reported By: btasker
Assigned To: btasker
Targeted for fix in version:
- 1.03
Time Estimate: 75 minutes
Time Logged: 45 minutes
-----------------------------------------------------------------------------------------
Issue Description
==================
GPXIN-24 introduced support for ingesting waypoints defined in the source GPX file. A
natural extension of that would be to add support for the _rteType_.
For purposes of clarity: A route is the planned route, whereas the track is the path
ultimately followed.
There'll normally only be the one route, but as with tracks, it's best to work on the
basis that there _may_ be more than one
-----------------------------------------------------------------------------------------
Issue Relations
================
- relates to GPXIN-24: Waypoint Support
- Causes GPXIN-31: Notices on Import
- Causes GPXIN-32: Fatal error for Route only files when speed etc not suppressed
- rteType (GPX Documentation) (http://www.topografix.com/gpx/1/1/#type_rteType)
-----------------------------------------------------------------------------------------
Activity
==========
-----------------------------------------------------------------------------------------
2016-02-20 23:43:42 btasker
-----------------------------------------------------------------------------------------
An example GPX might be (from CycleSeven)
-- BEGIN SNIPPET --
Test file by Patrick0.0Position 10.0Position 20.0Position 30.0Position 4Patrick's Route0.0Position 10.0Position 20.0Position 30.0Position 424-JUL-09DarkRed143.94136.06138.03148.75
-- END SNIPPET --
Note that _rtept_ is of type _wptType_ so as in GPXIN-24 need to consider that extensions
may be present
-----------------------------------------------------------------------------------------
2016-02-21 00:02:38 btasker
-----------------------------------------------------------------------------------------
Given that the handling for a rtept is exactly the same as that for a waypoint, it
probably makes sense to break some of the logic implemented in GPXIN-24 out into a new
method to avoid duplication
-----------------------------------------------------------------------------------------
2016-02-21 00:02:51
-----------------------------------------------------------------------------------------
btasker changed status from 'Open' to 'In Progress'
-----------------------------------------------------------------------------------------
2016-02-21 00:08:27 git
-----------------------------------------------------------------------------------------
-- BEGIN QUOTE --
Repo: PHP-GPX-Ingest
Commit: 5b2cf342baf967742f9c068ee68778f43156e393
Author: B Tasker >
Date: Sun Feb 21 00:07:10 2016 +0000
Commit Message: Moved wptType logic into new method. See GPXIN-27
Modified (-)(+)
-------
GPXIngest.class.php
-- END QUOTE --
*Webhook User-Agent*
-- BEGIN SNIPPET --
GitHub-Hookshot/21f57ba
-- END SNIPPET --
https://github.com/bentasker/PHP-GPX-Ingest/commit/5b2cf342baf967742f9c068ee68778f43156e393
-----------------------------------------------------------------------------------------
2016-02-21 00:10:43 btasker
-----------------------------------------------------------------------------------------
Have created
-- BEGIN SNIPPET --
private function buildWptType($wpt)
-- END SNIPPET --
To handle building the object.
Now need to look at actually pulling the routes out of the GPX file so that they can be
processed. They're more like tracks in the way that needs to be handled - there can be
multiple routes (some named, but it's not mandatory) and it'll have multiple children.
-----------------------------------------------------------------------------------------
2016-02-21 00:27:53 btasker
-----------------------------------------------------------------------------------------
Routes are now ingested under the _related_ property of the journey object, with the
following structure
-- BEGIN SNIPPET --
[routes] => stdClass Object
(
[route0] => stdClass Object
(
[name] => Patrick's Route
[meta] => stdClass Object
(
[comment] =>
[description] =>
[src] =>
[link] =>
[number] =>
[type] =>
)
[points] => stdClass Object
(
[rtpoint0] => stdClass Object
-- END SNIPPET --
Need to add some public methods to allow retrieval of them yet though
-----------------------------------------------------------------------------------------
2016-02-21 00:27:58
-----------------------------------------------------------------------------------------
btasker changed status from 'In Progress' to 'Open'
-----------------------------------------------------------------------------------------
2016-02-21 00:28:19
-----------------------------------------------------------------------------------------
btasker changed timespent from '0 minutes' to '25 minutes'
-----------------------------------------------------------------------------------------
2016-02-21 00:28:27 git
-----------------------------------------------------------------------------------------
-- BEGIN QUOTE --
Repo: PHP-GPX-Ingest
Commit: 7f429eee5695e5f578ca003f6f45a9a65dca87a5
Author: B Tasker >
Date: Sun Feb 21 00:26:09 2016 +0000
Commit Message: Added Route support into ingest method. See GPXIN-27
Modified (-)(+)
-------
GPXIngest.class.php
-- END QUOTE --
*Webhook User-Agent*
-- BEGIN SNIPPET --
GitHub-Hookshot/21f57ba
-- END SNIPPET --
https://github.com/bentasker/PHP-GPX-Ingest/commit/7f429eee5695e5f578ca003f6f45a9a65dca87a5
-----------------------------------------------------------------------------------------
2016-02-21 06:26:27 git
-----------------------------------------------------------------------------------------
-- BEGIN QUOTE --
Repo: PHP-GPX-Ingest
Commit: e523b4600f46110b27d189c1b432daf2b0c6b38f
Author: B Tasker >
Date: Sun Feb 21 06:25:32 2016 +0000
Commit Message: Added basic functions for retrieving routes. See GPXIN-27
Modified (-)(+)
-------
GPXIngest.class.php
-- END QUOTE --
*Webhook User-Agent*
-- BEGIN SNIPPET --
GitHub-Hookshot/21f57ba
-- END SNIPPET --
https://github.com/bentasker/PHP-GPX-Ingest/commit/e523b4600f46110b27d189c1b432daf2b0c6b38f
-----------------------------------------------------------------------------------------
2016-02-21 06:30:55 btasker
-----------------------------------------------------------------------------------------
Added three methods for getting route information
-- BEGIN SNIPPET --
public function getRouteNames()
public function getRouteByID($id)
public function getRouteCount()
-- END SNIPPET --
It's a bit of a sledgehammer approach at the moment, there's no way to extract an
individual route point. You'd need to use _getRouteByID_ and then iterate over the
_points_ property.
Conversely, there's also no way to extract all routes in one hit either
-----------------------------------------------------------------------------------------
2016-02-21 06:46:36 btasker
-----------------------------------------------------------------------------------------
Methods added so far have been added to the documentation -
https://www.bentasker.co.uk/documentation/development-programming/222-php-gpx-ingest#routes
-----------------------------------------------------------------------------------------
2016-02-21 06:46:51
-----------------------------------------------------------------------------------------
btasker changed timespent from '25 minutes' to '45 minutes'
-----------------------------------------------------------------------------------------
2017-07-04 12:01:13 btasker
-----------------------------------------------------------------------------------------
GPXIN-33 added support for various route related stats.
At the moment you access those by calling _getJourneyStats()_ and then grabbing the
attribute _routestats_ but I think it might be helpful to have a utility function that
does that for you.
-----------------------------------------------------------------------------------------
2017-07-04 12:07:30 git
-----------------------------------------------------------------------------------------
-- BEGIN QUOTE --
Repo: PHP-GPX-Ingest
Commit: 5a692439f40192f01bfb9a51708d927e5ae91956
Author: B Tasker >
Date: Tue Jul 04 12:06:05 2017 +0100
Commit Message: Exposed new method getRouteStats for GPXIN-27
Returns the general route stats object
Modified (-)(+)
-------
src/GPXIngest/GPXIngest.php
-- END QUOTE --
*Webhook User-Agent*
-- BEGIN SNIPPET --
GitHub-Hookshot/18889e1
-- END SNIPPET --
https://github.com/bentasker/PHP-GPX-Ingest/commit/5a692439f40192f01bfb9a51708d927e5ae91956
-----------------------------------------------------------------------------------------
2017-07-04 12:59:05 btasker
-----------------------------------------------------------------------------------------
Essentially, we want to the utility functions to be structured as they are for tracks -
https://www.bentasker.co.uk/documentation/development-programming/222-php-gpx-ingest#objectsextract
-----------------------------------------------------------------------------------------
2017-07-04 13:11:55
-----------------------------------------------------------------------------------------
btasker added '1.03' to Fix Version
-----------------------------------------------------------------------------------------
2017-07-04 13:11:55
-----------------------------------------------------------------------------------------
btasker removed '1.02' from Fix Version
-----------------------------------------------------------------------------------------
2017-07-04 13:12:00
-----------------------------------------------------------------------------------------
btasker removed '1.02' from Version
-----------------------------------------------------------------------------------------
2017-07-04 13:25:57 btasker
-----------------------------------------------------------------------------------------
So we already have
-- BEGIN SNIPPET --
public function getRouteNames()
public function getRouteByID($id)
public function getRouteCount()
-- END SNIPPET --
So we need some equivalents
- $gpx->getObject() = $gpx->getRoutesObject()
- $gpx->getTrack('journey0') = $gpx->getRouteByID('name')
- $gpx->getSegment('journey0','seg0') = no equivalent (there isn't really a segment
equivalent in routes)
- $gpx->getTrackPoint('journey0','seg0','trackpt0') =
$gpx->getRoutePoint('name','trkptname')
We also need equivalents to the ID fetchers -
https://www.bentasker.co.uk/documentation/development-programming/222-php-gpx-ingest#IDS
- $gpx->getTrackIDs() = $gpx->getRouteIDs()
- $gpx->getTrackNames() = $gpx->getRouteNames()
- $gpx->getTrackSegmentNames('journey0') = no equivalent
- $gpx->getTrackPointNames('journey0','seg0') = $gpx->getRoutePointNames('name')
For the route related functions that already exist, might want to also create some stub
functions so that naming is closer to their track counterparts, though I think there's
only one that needs doing:
- getRouteByID() = getRoute()
-----------------------------------------------------------------------------------------
2017-07-04 13:37:11 btasker
-----------------------------------------------------------------------------------------
OK, so far, we now have
-- BEGIN SNIPPET --
public function getRoute($id)
public function getRouteIDs()
public function getRoutePointNames($route)
-- END SNIPPET --
The following works as expected
-- BEGIN SNIPPET --
$rid = $gpx->getRouteIDs()[0];
print_r($gpx->getRoute($rid));
echo "------------------\n";
print_r($gpx->getRoutePointNames($rid));
-- END SNIPPET --
-----------------------------------------------------------------------------------------
2017-07-04 13:39:30 git
-----------------------------------------------------------------------------------------
-- BEGIN QUOTE --
Repo: PHP-GPX-Ingest
Commit: aecb44005c70718244c9e7c1653dff4b69a38773
Author: B Tasker >
Date: Tue Jul 04 13:37:20 2017 +0100
Commit Message: GPXIN-27 - Implementing route related ID fetchers.
Modified (-)(+)
-------
src/GPXIngest/GPXIngest.php
-- END QUOTE --
*Webhook User-Agent*
-- BEGIN SNIPPET --
GitHub-Hookshot/18889e1
-- END SNIPPET --
https://github.com/bentasker/PHP-GPX-Ingest/commit/aecb44005c70718244c9e7c1653dff4b69a38773
-----------------------------------------------------------------------------------------
2017-07-04 13:48:35 btasker
-----------------------------------------------------------------------------------------
Ok, we now have
-- BEGIN SNIPPET --
public function getRoutesObject()
public function getRoutePoint($route,$routepoint)
-- END SNIPPET --
And the following works as expected
-- BEGIN SNIPPET --
$rid = $gpx->getRouteIDs()[0];
$tpoint = $gpx->getRoutePointNames($rid)[0];
print_r($gpx->getRoutePoint($rid,$tpoint));
-- END SNIPPET --
So that gives us the following public methods
-- BEGIN SNIPPET --
getRoutesObject() // Retrieve the entire routes object
getRoute($id) // Retrieve a specific route object by ID
getRoutePoint($route,$ptid) // Retrieve a specific routepoint by ID
getRouteIDs() // list all route IDs
getRouteNames() // Get a list of all route names (with id also included in the array)
getRoutePointNames($route) // Get a list of all routepoint names for the given route
-- END SNIPPET --
-----------------------------------------------------------------------------------------
2017-07-04 13:49:30 git
-----------------------------------------------------------------------------------------
-- BEGIN QUOTE --
Repo: PHP-GPX-Ingest
Commit: f11dbc2ee9b25116ffd9151e16ed34e4c4864d5d
Author: B Tasker >
Date: Tue Jul 04 13:48:48 2017 +0100
Commit Message: GPXIN-27 Added route object fetchers.
Modified (-)(+)
-------
src/GPXIngest/GPXIngest.php
-- END QUOTE --
*Webhook User-Agent*
-- BEGIN SNIPPET --
GitHub-Hookshot/18889e1
-- END SNIPPET --
https://github.com/bentasker/PHP-GPX-Ingest/commit/f11dbc2ee9b25116ffd9151e16ed34e4c4864d5d
-----------------------------------------------------------------------------------------
2017-07-04 13:49:38 btasker
-----------------------------------------------------------------------------------------
Documentation will need updating, but otherwise I think we're done here.
-----------------------------------------------------------------------------------------
2017-07-04 14:28:33 btasker
-----------------------------------------------------------------------------------------
Documentation has been updated with examples -
https://www.bentasker.co.uk/documentation/development-programming/222-php-gpx-ingest?#routes
- so while support is still minimal, I'd say we're done here.
-----------------------------------------------------------------------------------------
2017-07-04 14:28:40
-----------------------------------------------------------------------------------------
btasker changed status from 'Open' to 'Resolved'
-----------------------------------------------------------------------------------------
2017-07-04 14:28:40
-----------------------------------------------------------------------------------------
btasker added 'Done' to resolution
-----------------------------------------------------------------------------------------
2017-07-04 14:28:44
-----------------------------------------------------------------------------------------
btasker changed status from 'Resolved' to 'Closed'
-----------------------------------------------------------------------------------------
Worklog
========
-----------------------------------------------------------------------------------------
2016-02-21 00:28:19 btasker
25 minutes
-----------------------------------------------------------------------------------------
Initial implementation
-----------------------------------------------------------------------------------------
2016-02-21 06:46:50 btasker
20 minutes
-----------------------------------------------------------------------------------------
Adding retrieval methods, testing and updating docs