Skip to content
Permalink
Browse files

GPXIN-23 Move calcDistance out of experimental and enable by default

* Can be suppressed using 'calcdistance'
* Adds 'distanceTravelled' attribute to trackpoints (measured in feet)

Also means that auto-speed calculation (implemented in GPXIN-13) will be used if speed has not been declared within the GPX file
  • Loading branch information...
bentasker committed Jul 4, 2017
1 parent 5a69243 commit 88d7f93ab6c0088005b7bbc2d6dcacfe2ee013b1
Showing with 13 additions and 9 deletions.
  1. +13 −9 src/GPXIngest/GPXIngest.php
@@ -28,6 +28,7 @@ class GPXIngest{
private $trackduration;
private $smarttrack=true;
private $smarttrackthreshold = 3600;
private $suppresscalcdistance = false;
private $suppresslocation = false;
private $suppressspeed = false;
private $suppresselevation = false;
@@ -46,7 +47,7 @@ class GPXIngest{
private $tracklons;
private $ingest_version = 1.02;
private $entryperiod = 0;
private $experimentalFeatures = array('calcDistance', 'calcElevationGain'); // See GPXIN-17
private $experimentalFeatures = array('calcElevationGain'); // See GPXIN-17
private $featuretoggle = array();
private $waypoints;
@@ -300,7 +301,7 @@ public function ingest(){
// If speed is not available (and we're not calculating anything which can be used) suppress speed
// Will need updating in GPXIN-20
if (!$trkpt->desc && !$this->expisenabled('calcDistance')){
if (!$trkpt->desc && $this->$suppresscalcdistance){
$this->suppress('speed'); // Prevent warnings if speed is not available - See GPXIN-16
}
@@ -399,7 +400,7 @@ public function ingest(){
$this->journey->metadata->AutoCalc['speed'] = true;
}
$this->journey->journeys->$jkey->segments->$segkey->points->$key->distanceTravelled = $dist;
$this->lastpos = array($lat,$lon); // update the reference array
// Update the stats arrays
@@ -1110,12 +1111,6 @@ private function writeTrackStats($jkey){
* @return distance travelled (feet)
*/
protected function calculateTravelledDistance($old,$new){
if (!$this->expisenabled('calcDistance')){ // This functionality is currently considered experimental
return 0;
}
// Array mapping (for ease of reference)
// lat1 - old[0]
// lat2 - new[0]
@@ -1562,6 +1557,11 @@ public function suppress($ele){
$this->suppresssuppresswptele = true;
break;
case 'calcdistance':
$this->suppresscalcdistance = true;
break;
}
}
@@ -1596,6 +1596,10 @@ public function unsuppress($ele){
case 'wptele':
$this->suppresssuppresswptele = false;
break;
case 'calcdistance':
$this->suppresscalcdistance = false;
break;
}
}

0 comments on commit 88d7f93

Please sign in to comment.
You can’t perform that action at this time.