GPXIN-6: Distance calculations



Issue Information

Issue Type: Improvement
 
Priority: Major
Status: Closed

Reported By:
Ben Tasker
Assigned To:
Ben Tasker
Project: PHP GPXIngest (GPXIN)
Resolution: Done (2015-04-15 10:07:18)
Target version: 1.02,

Created: 2013-11-17 17:46:28
Time Spent Working


Description
This may have a severe performance impact (potentially), but it'd be pretty awesome if we could calculate the distance travelled using Greater Circle on the lat/lons.

GPX track files normally contain a capture every 5 seconds or so, the usual inaccuracy with using greater circle shouldn't apply quite as dramatically here.


Issue Links

Design Notes
Toggle State Changes

Activity


btasker added '1.02' to Fix Version
btasker changed status from 'Open' to 'Closed'
btasker added 'Done' to resolution
Re-Opening as have found a use-case for this (received an email which appears to be asking if it's possible)
btasker removed 'Done' from resolution
btasker changed status from 'Closed' to 'Reopened'
btasker added 'Ben Tasker' to assignee
Still a little concerned about the processing overhead, but I think the work-around is to have it disabled by default and to expose a method which will allow it to be enabled (GPXIN-17).
GPXIN-17 has been implemented, so this functionality can now be implemented as an experimental feature
As noted in the design notes (see Links section), the experimental key for this functionality is calcDistance
Basic calculations have been implemented (though currently only tested with one dataset). Example usage is

<?php
require_once('GPXIngest.class.php');
$gpx = new GPXIngest();
$gpx->loadFile('gpxtestfile.gpx');
$gpx->enableExperimental('calcDistance');
$gpx->ingest();
$tpts = $gpx->getTrackPointNames('journey0','seg0');
print_r($gpx->getTrackPoint('journey0','seg0',$tpts[3]));
print_r($gpx->getTrackPoint('journey0','seg0',$tpts[4]));


The returned distance travelled was then calculated manually and using online calculators. Looks like the calculations are correct.

Commit 0312b20 refers.

Still need to push the distance out to an array of some form so that stats can be used/updated for each Segment/Track.

If the functionality is not enabled, the method calculateTravelledDistance will return _0_ which might get confusing somewhere down the line - it's probably worth having a list of which experimental features are enabled pushed to the metadata (have raised GPXIN-18 for implementation).

Repo: PHP-GPX-Ingest
Commit: 0312b20464d628b671ce1c70b867e737321c9946
Author: Ben Tasker <github@<Domain Hidden>>

Date: Tue Jan 13 11:29:24 2015 +0000
Commit Message: Added basic Distance calculations for GPXIN-6



Modified (-)(+)
-------
GPXIngest.class.php




Webhook User-Agent

GitHub-Hookshot/2f00e0f


View Commit

Commit ea35449 pushes the distance travelled to the stats objects, example implementation

<?php
require_once('GPXIngest.class.php');
$gpx = new GPXIngest();

$gpx->loadFile('testgpx.gpx');
$gpx->enableExperimental('calcDistance');
$gpx->ingest();
$tpts = $gpx->getTrackPointNames('journey0','seg0');

echo "\n\nJourney\n";
print_r($gpx->getJourneyStats());

echo "\n\nTracks\n";
print_r($gpx->getStats('journey0'));

echo "\n\nSegment\n";
print_r($gpx->getStats('journey0','seg0'));

echo "\n\nTrackpoints\n";
print_r($gpx->getTrackPoint('journey0','seg0',$tpts[4]));
print_r($gpx->getTrackPoint('journey0','seg0',$tpts[5]));


It also incorporates a minor bugfix - when the location hadn't moved, the distance calculations were returning NAN. Have added a check so that 0 is returned in this instance.

Repo: PHP-GPX-Ingest
Commit: ea35449fa2a2266a097ad56dec0c5445b4e2136b
Author: Ben Tasker <github@<Domain Hidden>>

Date: Tue Jan 13 12:50:47 2015 +0000
Commit Message: Pushed distance travelled to the stats objects. See GPXIN-6



Modified (-)(+)
-------
GPXIngest.class.php




Webhook User-Agent

GitHub-Hookshot/2f00e0f


View Commit

Needs further testing, but does appear to be working correctly.

The resources required for the calculations aren't as high as originally expected either, so once stable and tested, this can be moved out of experimental features.
An issue with the processing was raised on Github (https://github.com/bentasker/PHP-GPX-Ingest/issues/2) and fixed on 19 Jan.

Other than that, seems to work OK so closing FR.
btasker changed status from 'Reopened' to 'Resolved'
btasker added 'Done' to resolution
btasker changed status from 'Resolved' to 'Closed'