Remove DB field geofile
This commit is contained in:
@@ -5,11 +5,11 @@
|
||||
*
|
||||
* To convert a gpx file:
|
||||
* 1. Add file <file_name>.gpx to geo/ folder
|
||||
* 2. Assign file to project: UPDATE projects SET geofile = '<file_name>' WHERE id_project = <id_project>;
|
||||
* 2. Assign file to project: UPDATE projects SET codename = '<file_name>' WHERE id_project = <id_project>;
|
||||
* 3. Load any page
|
||||
*
|
||||
* To force gpx rebuild:
|
||||
* ?a=build_geojson&name=<gpx_file_name>
|
||||
* ?a=build_geojson&name=<file_name>
|
||||
*/
|
||||
class Converter extends PhpObject {
|
||||
|
||||
@@ -17,11 +17,9 @@ class Converter extends PhpObject {
|
||||
parent::__construct(__CLASS__, Settings::DEBUG);
|
||||
}
|
||||
|
||||
public static function convertToGeoJson($sFileName) {
|
||||
$sFileName = basename($sFileName, Gpx::EXT);
|
||||
|
||||
$oGpx = new Gpx($sFileName);
|
||||
$oGeoJson = new GeoJson($sFileName);
|
||||
public static function convertToGeoJson($sCodeName) {
|
||||
$oGpx = new Gpx($sCodeName);
|
||||
$oGeoJson = new GeoJson($sCodeName);
|
||||
|
||||
$oGeoJson->buildTracks($oGpx->getTracks());
|
||||
if($oGeoJson->isSimplicationRequired()) $oGeoJson->buildTracks($oGpx->getTracks(), true);
|
||||
@@ -30,10 +28,10 @@ class Converter extends PhpObject {
|
||||
return $oGpx->getLog().'<br />'.$oGeoJson->getLog();
|
||||
}
|
||||
|
||||
public static function isGeoJsonValid($sFileName) {
|
||||
public static function isGeoJsonValid($sCodeName) {
|
||||
$bResult = false;
|
||||
$sGeoJsonFilePath = Geo::getFilePath($sFileName, GeoJson::EXT);
|
||||
if(file_exists($sGeoJsonFilePath) && filemtime($sGeoJsonFilePath) > filemtime(Geo::getFilePath($sFileName, Gpx::EXT))) $bResult = true;
|
||||
$sGeoJsonFilePath = Geo::getFilePath($sCodeName, GeoJson::EXT);
|
||||
if(file_exists($sGeoJsonFilePath) && filemtime($sGeoJsonFilePath) > filemtime(Geo::getFilePath($sCodeName, Gpx::EXT))) $bResult = true;
|
||||
return $bResult;
|
||||
}
|
||||
}
|
||||
@@ -46,14 +44,14 @@ class Geo extends PhpObject {
|
||||
protected $asTracks;
|
||||
protected $sFilePath;
|
||||
|
||||
public function __construct($sFileName) {
|
||||
public function __construct($sCodeName) {
|
||||
parent::__construct(get_class($this), Settings::DEBUG, PhpObject::MODE_HTML);
|
||||
$this->sFilePath = self::getFilePath($sFileName, static::EXT);
|
||||
$this->sFilePath = self::getFilePath($sCodeName, static::EXT);
|
||||
$this->asTracks = array();
|
||||
}
|
||||
|
||||
public static function getFilePath($sFileName, $sExt) {
|
||||
return self::GEO_FOLDER.$sFileName.$sExt;
|
||||
public static function getFilePath($sCodeName, $sExt) {
|
||||
return self::GEO_FOLDER.$sCodeName.$sExt;
|
||||
}
|
||||
|
||||
public function getLog() {
|
||||
@@ -65,8 +63,8 @@ class Gpx extends Geo {
|
||||
|
||||
const EXT = '.gpx';
|
||||
|
||||
public function __construct($sFileName) {
|
||||
parent::__construct($sFileName);
|
||||
public function __construct($sCodeName) {
|
||||
parent::__construct($sCodeName);
|
||||
$this->parseFile();
|
||||
}
|
||||
|
||||
@@ -113,8 +111,8 @@ class GeoJson extends Geo {
|
||||
const MAX_DEVIATION_FLAT = 0.1; //10%
|
||||
const MAX_DEVIATION_ELEV = 0.1; //20%
|
||||
|
||||
public function __construct($sFileName) {
|
||||
parent::__construct($sFileName);
|
||||
public function __construct($sCodeName) {
|
||||
parent::__construct($sCodeName);
|
||||
}
|
||||
|
||||
public function saveFile() {
|
||||
@@ -217,7 +215,7 @@ class GeoJson extends Geo {
|
||||
|
||||
private function isPointValid($asPointA, $asPointO, $asPointB) {
|
||||
/* A----O Calculate angle AO^OB
|
||||
* \ If angle is within [Pi - 10%; Pi + 10%], O can be discarded
|
||||
* \ If angle is within [90% Pi ; 110% Pi], O can be discarded
|
||||
* \ O is valid otherwise
|
||||
* B
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user