diff --git a/composer.lock b/composer.lock
index 76c40f6..f42984d 100644
--- a/composer.lock
+++ b/composer.lock
@@ -12,7 +12,7 @@
"source": {
"type": "git",
"url": "https://git.lutran.fr/franzz/objects",
- "reference": "af7d0f4c86564995f1c8149df98a183d33fab767"
+ "reference": "b8a2220701a43b6695f3010257d5bf62c77d81c2"
},
"type": "library",
"autoload": {
@@ -21,7 +21,7 @@
}
},
"description": "Objects",
- "time": "2026-05-29T23:29:34+00:00"
+ "time": "2026-07-27T13:46:58+00:00"
},
{
"name": "phpmailer/phpmailer",
diff --git a/config/apache-localhost.conf b/config/apache-localhost.conf
index 4875a75..c2bacb4 100644
--- a/config/apache-localhost.conf
+++ b/config/apache-localhost.conf
@@ -12,5 +12,43 @@
Options FollowSymLinks
AllowOverride None
Require all granted
+
+ AddType application/geo+json .geojson
+
+
+
+ Header set Cache-Control "public, max-age=31536000, immutable"
+
+
+
+
+ AddOutputFilterByType BROTLI_COMPRESS \
+ text/html \
+ text/plain \
+ text/css \
+ text/javascript \
+ text/xml \
+ application/javascript \
+ application/json \
+ application/geo+json \
+ application/manifest+json \
+ application/xml \
+ image/svg+xml
+
+
+
+ AddOutputFilterByType DEFLATE \
+ text/html \
+ text/plain \
+ text/css \
+ text/javascript \
+ text/xml \
+ application/javascript \
+ application/json \
+ application/geo+json \
+ application/manifest+json \
+ application/xml \
+ image/svg+xml
+
diff --git a/lib/Controller.php b/lib/Controller.php
index ce53495..b0293e8 100644
--- a/lib/Controller.php
+++ b/lib/Controller.php
@@ -20,8 +20,7 @@ class Controller extends PhpObject
'add_position',
'admin_set',
'admin_create',
- 'admin_delete',
- 'build_geojson'
+ 'admin_delete'
);
private Spot $oSpot;
@@ -130,7 +129,6 @@ class Controller extends PhpObject
return match($sAction) {
'markers' => $this->oSpot->getMarkers(),
'last_update' => $this->oSpot->getLastUpdate(),
- 'geojson' => $this->oSpot->getProjectGeoJson(),
'next_feed' => $this->oSpot->getNextFeed($this->asReq['id']),
'new_feed' => $this->oSpot->getNewFeed($this->asReq['id']),
'add_post' => $this->oSpot->addPost($this->asReq['name'], $this->asReq['content']),
@@ -158,7 +156,6 @@ class Controller extends PhpObject
'admin_create' => $this->oSpot->createAdminSettings($this->asReq['type']),
'admin_delete' => $this->oSpot->deleteAdminSettings($this->asReq['type'], $this->asReq['id_entity']),
'sql' => $this->oSpot->getDbBuildScript(),
- 'build_geojson' => $this->oSpot->buildGeoJSON($this->asReq['name']),
default => Spot::getJsonResult(false, Spot::NOT_FOUND)
};
}
diff --git a/lib/Converter.php b/lib/Converter.php
index be65d4f..3c72fbc 100644
--- a/lib/Converter.php
+++ b/lib/Converter.php
@@ -10,9 +10,6 @@ use Franzz\Objects\PhpObject;
* 1. Add file .gpx to geo/ folder
* 2. Assign file to project: UPDATE projects SET codename = '' WHERE id_project = ;
* 3. Load any page
- *
- * To force gpx rebuild:
- * ?a=build_geojson&name=
*/
class Converter extends PhpObject {
diff --git a/lib/Project.php b/lib/Project.php
index 64c151a..74c449a 100644
--- a/lib/Project.php
+++ b/lib/Project.php
@@ -138,7 +138,15 @@ class Project extends PhpObject {
if($bSpecificProj) $asInfo['constraint'] = array(Db::getId(self::PROJ_TABLE)=>$iProjectId);
$asProjects = $this->oDb->selectRows($asInfo, 'codename');
- foreach($asProjects as $sCodeName=>&$asProject) {
+ foreach($asProjects as $sCodeName => &$asProject) {
+ //Update Geo JSON
+ if($sCodeName != '' && (!Converter::isGeoJsonValid($sCodeName) || !$asProject['latitude'] && !$asProject['longitude'])) {
+ $aiCenter = Converter::convertToGeoJson($sCodeName)['center'];
+ $this->oDb->updateRow(self::PROJ_TABLE, $asProject['id'], ['latitude' => $aiCenter[1], 'longitude' => $aiCenter[0]]);
+ $asProject['latitude'] = $aiCenter[1];
+ $asProject['longitude'] = $aiCenter[0];
+ }
+
switch($asProject['mode']) {
case 0: $asProject['mode'] = self::MODE_PREVIZ; break;
case 1: $asProject['mode'] = self::MODE_BLOG; break;
@@ -146,21 +154,13 @@ class Project extends PhpObject {
}
$asProject['editable'] = $this->isModeEditable($asProject['mode']);
$asProject['gpxfilepath'] = Spot::addTimestampToFilePath(Gpx::getFrontendFilePath($sCodeName));
+ $asProject['geofilepath'] = Spot::addTimestampToFilePath(GeoJson::getFrontendFilePath($sCodeName));
$asProject['codename'] = $sCodeName;
$asProject['default'] = ($sCodeName == $sDefaultProjectCodeName);
}
return $bSpecificProj?$asProject:$asProjects;
}
- public function getGeoJson() {
- if($this->sCodeName != '' && !Converter::isGeoJsonValid($this->sCodeName)){
- $aiCenter = Converter::convertToGeoJson($this->sCodeName)['center'];
- $this->oDb->updateRow(self::PROJ_TABLE, $this->iProjectId, ['latitude' => $aiCenter[1], 'longitude' => $aiCenter[0]]);
- }
-
- return json_decode(file_get_contents(GeoJson::getBackendFilePath($this->sCodeName)), true);
- }
-
public function getProject() {
return $this->getProjects($this->getProjectId());
}
diff --git a/lib/Spot.php b/lib/Spot.php
index cab461f..c2f9b1c 100755
--- a/lib/Spot.php
+++ b/lib/Spot.php
@@ -256,10 +256,6 @@ class Spot extends Main
$this->oProject->setProjectId($iProjectId);
}
- public function getProjectGeoJson() {
- return self::getJsonResult(true, '', $this->oProject->getGeoJson());
- }
-
public function updateProject() {
$bNewMsg = false;
$bSuccess = true;
@@ -859,10 +855,6 @@ class Spot extends Main
return self::getJsonResult($bSuccess, $sDesc, $asResult);
}
- public function buildGeoJSON($sCodeName) {
- return Converter::convertToGeoJson($sCodeName)['logs'];
- }
-
public static function decToDms($dValue, $sType) {
if($sType=='lat') $sDirection = ($dValue >= 0)?'N':'S'; //Latitude
else $sDirection = ($dValue >= 0)?'E':'W'; //Longitude
diff --git a/lib/User.php b/lib/User.php
index 16266a1..b879bc6 100644
--- a/lib/User.php
+++ b/lib/User.php
@@ -179,8 +179,6 @@ class User extends PhpObject {
$sDesc = 'lang:account.logged_in';
}
else $sDesc = 'lang:account.invalid_credentials';
-
- //die(print_r(['provided_pass'=>$sPassword, 'db_pass'=>$asDBUser['password']], true));
}
else {
$bSuccess = true;
diff --git a/src/components/project.vue b/src/components/project.vue
index 53423ba..431943b 100644
--- a/src/components/project.vue
+++ b/src/components/project.vue
@@ -204,7 +204,7 @@ export default {
this.track
] = await Promise.all([
this.api.get('markers', {id_project: this.project.id}),
- this.api.get('geojson', {id_project: this.project.id})
+ this.api.getAsset(this.project.geofilepath)
]);
await this.initMap();
diff --git a/src/scripts/api.js b/src/scripts/api.js
index 906b2ff..50aa86a 100644
--- a/src/scripts/api.js
+++ b/src/scripts/api.js
@@ -14,6 +14,16 @@ export default class Api {
return response.data;
}
+ async getAsset(sAssetPath) {
+ const oRequest = await fetch(sAssetPath, {headers: {'Accept': 'application/geo+json'}});
+
+ if(!oRequest.ok) {
+ throw new Error('Error HTTP ' + oRequest.status + ': ' + oRequest.statusText);
+ }
+
+ return oRequest.json();
+ }
+
async post(sAction, asParams = {}) {
const response = await this.request(sAction, asParams, 'POST');
return response.data;