Adding elevation chart
This commit is contained in:
@@ -5,19 +5,12 @@ class Converter extends PhpObject {
|
||||
const GPX_EXT = '.gpx';
|
||||
const GEO_EXT = '.geojson';
|
||||
|
||||
/**
|
||||
* Project to convert
|
||||
* @var Project
|
||||
*/
|
||||
private $oProject;
|
||||
|
||||
public function __construct(&$oProject) {
|
||||
public function __construct() {
|
||||
parent::__construct(__CLASS__, Settings::DEBUG);
|
||||
$this->oProject = &$oProject;
|
||||
}
|
||||
|
||||
public function convertToGeoJson() {
|
||||
$sFileName = pathinfo($this->oProject->getGeoFile(), PATHINFO_FILENAME);
|
||||
public function convertToGeoJson($sGeoFile) {
|
||||
$sFileName = pathinfo($sGeoFile, PATHINFO_FILENAME);
|
||||
$sGpxFileName = $sFileName.self::GPX_EXT;
|
||||
$sGeoJsonFileName = $sFileName.self::GEO_EXT;
|
||||
|
||||
@@ -70,7 +63,7 @@ class Gpx extends Geo {
|
||||
$asTrack['points'][] = array(
|
||||
'lon' => (float) $asPoint['lon'],
|
||||
'lat' => (float) $asPoint['lat'],
|
||||
//'ele' => (int) $asPoint->ele
|
||||
'ele' => (int) $asPoint->ele
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -96,7 +89,7 @@ class GeoJson extends Geo {
|
||||
}
|
||||
|
||||
private function getGeoJson() {
|
||||
$asTracks = array();
|
||||
$asTracks = array('features'=>array());
|
||||
foreach($this->asTracks as $asTrackProps) {
|
||||
|
||||
switch($asTrackProps['color']) {
|
||||
@@ -114,15 +107,15 @@ class GeoJson extends Geo {
|
||||
'description' => $asTrackProps['desc']
|
||||
),
|
||||
'geometry' => array(
|
||||
'type' => 'MultiLineString',
|
||||
'type' => 'LineString',
|
||||
'coordinates' => array()
|
||||
)
|
||||
);
|
||||
|
||||
foreach($asTrackProps['points'] as $asPoint) {
|
||||
$asTrack['geometry']['coordinates'][0][] = array_values($asPoint);
|
||||
$asTrack['geometry']['coordinates'][] = array_values($asPoint);
|
||||
}
|
||||
$asTracks[] = $asTrack;
|
||||
$asTracks['features'][] = $asTrack;
|
||||
}
|
||||
|
||||
return $asTracks;
|
||||
|
||||
Reference in New Issue
Block a user