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;
|
||||
|
||||
@@ -100,7 +100,13 @@ class Project extends PhpObject {
|
||||
case 1: $asProject['mode'] = self::MODE_BLOG; break;
|
||||
case 2: $asProject['mode'] = self::MODE_HISTO; break;
|
||||
}
|
||||
$asProject['geofile'] = Spot::addTimestampToFilePath(self::GEO_FOLDER.$asProject['geofile']);
|
||||
|
||||
$sGeoFile = self::GEO_FOLDER.$asProject['geofile'];
|
||||
if(!file_exists($sGeoFile)) {
|
||||
(new Converter())->convertToGeoJson($asProject['geofile']);
|
||||
}
|
||||
|
||||
$asProject['geofile'] = Spot::addTimestampToFilePath($sGeoFile);
|
||||
$asProject['codename'] = $sCodeName;
|
||||
$asProject['timezone_desc'] = Spot::getTimeZoneDesc($asProject['timezone']);
|
||||
}
|
||||
|
||||
13
inc/spot.php
13
inc/spot.php
@@ -48,7 +48,8 @@ class Spot extends Main
|
||||
$asClasses = array(
|
||||
array('name'=>'project', 'project'=>true),
|
||||
array('name'=>'picture', 'project'=>true),
|
||||
array('name'=>'cacher', 'project'=>true)
|
||||
array('name'=>'cacher', 'project'=>true),
|
||||
array('name'=>'converter', 'project'=>true)
|
||||
);
|
||||
parent::__construct($oClassManagement, $sProcessPage, $asClasses);
|
||||
|
||||
@@ -140,6 +141,7 @@ class Spot extends Main
|
||||
'index',
|
||||
array(
|
||||
'filepath_css' => self::addTimestampToFilePath('style/spot.css'),
|
||||
'filepath_js_d3' => self::addTimestampToFilePath('script/d3.min.js'),
|
||||
'filepath_js_leaflet' => self::addTimestampToFilePath('script/leaflet.min.js'),
|
||||
'filepath_js_jquery' => self::addTimestampToFilePath('script/jquery.min.js'),
|
||||
'filepath_js_jquery_mods' => self::addTimestampToFilePath('script/jquery.mods.js'),
|
||||
@@ -436,6 +438,10 @@ class Spot extends Main
|
||||
$sToken = Settings::IGN_FR_KEY;
|
||||
$sReferer = 'https://www.visugpx.com/yfJDwfuTlf';
|
||||
break;
|
||||
case 'opentopomap':
|
||||
$sPattern = 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png';
|
||||
$asDomains = array('a', 'b', 'c');
|
||||
break;
|
||||
case 'static':
|
||||
$sPattern = 'https://api.mapbox.com/v4/mapbox.satellite/url-https%3A%2F%2Fspot.lutran.fr%2Fimages%2Ffootprint_mapbox.png({x},{y})/{x},{y},{z}/400x300.png?access_token={token}';
|
||||
$sToken = Settings::MAPBOX_KEY;
|
||||
@@ -455,9 +461,8 @@ class Spot extends Main
|
||||
}
|
||||
|
||||
public function convertGpxToGeoJson() {
|
||||
$this->oClassManagement->incClass('converter', true);
|
||||
$oConverter = new Converter($this->oProject);
|
||||
return $oConverter->convertToGeoJson();
|
||||
$oConverter = new Converter();
|
||||
return $oConverter->convertToGeoJson($this->oProject->getGeoFile());
|
||||
}
|
||||
|
||||
public static function DecToDMS($dValue, $sType='lat') {
|
||||
|
||||
Reference in New Issue
Block a user