Use track's comment to store geojson generation options
This commit is contained in:
@@ -41,6 +41,7 @@ class Converter extends PhpObject {
|
||||
class Geo extends PhpObject {
|
||||
|
||||
const GEO_FOLDER = 'geo/';
|
||||
const OPT_SIMPLE = 'simplification';
|
||||
|
||||
protected $asTracks;
|
||||
protected $sFilePath;
|
||||
@@ -83,6 +84,7 @@ class Gpx extends Geo {
|
||||
$asTrack = array(
|
||||
'name' => (string) $aoTrack->name,
|
||||
'desc' => str_replace("\n", '', ToolBox::fixEOL((strip_tags($aoTrack->desc)))),
|
||||
'cmt' => ToolBox::fixEOL((strip_tags($aoTrack->cmt))),
|
||||
'color' => (string) $aoTrack->extensions->children('gpxx', true)->TrackExtension->DisplayColor,
|
||||
'points'=> array()
|
||||
);
|
||||
@@ -142,6 +144,7 @@ class GeoJson extends Geo {
|
||||
|
||||
$this->asTracks = array();
|
||||
foreach($asTracks as $asTrackProps) {
|
||||
$asOptions = $this->parseOptions($asTrackProps['cmt']);
|
||||
|
||||
//Color mapping
|
||||
switch($asTrackProps['color']) {
|
||||
@@ -149,7 +152,7 @@ class GeoJson extends Geo {
|
||||
$sType = 'main';
|
||||
break;
|
||||
case 'Magenta':
|
||||
if($bSimplify) {
|
||||
if($bSimplify && $asOptions[self::OPT_SIMPLE]!='keep') {
|
||||
$this->addNotice('Ignoring Track "'.$asTrackProps['name'].' (off-track)');
|
||||
continue 2; //discard tracks
|
||||
}
|
||||
@@ -204,6 +207,14 @@ class GeoJson extends Geo {
|
||||
if($bSimplify) $this->addNotice('Total: '.$iGlobalInvalidPointCount.'/'.$iGlobalPointCount.' points removed ('.round($iGlobalInvalidPointCount / $iGlobalPointCount * 100, 1).'%)');
|
||||
}
|
||||
|
||||
private function parseOptions($sComment){
|
||||
$asOptions = array(self::OPT_SIMPLE=>'');
|
||||
foreach(explode("\n", $sComment) as $sLine) {
|
||||
$asOptions[mb_strtolower(trim(mb_strstr($sLine, ':', true)))] = mb_strtolower(trim(mb_substr(mb_strstr($sLine, ':'), 1)));
|
||||
}
|
||||
return $asOptions;
|
||||
}
|
||||
|
||||
private function isPointValid($asPointA, $asPointO, $asPointB) {
|
||||
/* A----O Calculate angle AO^OB
|
||||
* \ If angle is within [Pi - 10%; Pi + 10%], O can be discarded
|
||||
|
||||
Reference in New Issue
Block a user