diff --git a/calendar/enum.json b/calendar/enum.json index 92bb663..4805710 100644 --- a/calendar/enum.json +++ b/calendar/enum.json @@ -1 +1 @@ -{"name":"geolocation","realName":"Géolocalisation","version":"0.5","update":"0.0","delete":true,"dataDirectory":"site\/data\/geolocation\/"} \ No newline at end of file +{"name":"calendar","realName":"Calendrier","version":"0.2","update":"0.0","delete":true,"dataDirectory":""} \ No newline at end of file diff --git a/geogallery/changes.md b/geogallery/changes.md index 87c37ef..08bad9f 100644 --- a/geogallery/changes.md +++ b/geogallery/changes.md @@ -1,2 +1,5 @@ -# Version 0.1 +# Version 0.10 +- Corrige un affichage incorrect lorsque l'étiquette est vide (null dans la popup). +- Supprimer le stockage des positions dans modules.json +# Version 0.9 - GeoGallery est basé sur le module gallery 4.1 \ No newline at end of file diff --git a/geogallery/geogallery.php b/geogallery/geogallery.php index 661a6b2..b97f6bb 100644 --- a/geogallery/geogallery.php +++ b/geogallery/geogallery.php @@ -154,8 +154,7 @@ class geogallery extends common 'name' => $this->getInput('galleryAddName'), 'directory' => $this->getInput('galleryAddDirectory', helper::FILTER_STRING_SHORT, true), ], - 'legend' => [], - 'position' => [] + 'legend' => [] ] ]); $success = true; @@ -234,13 +233,6 @@ class geogallery extends common foreach ($legend as $file => $data) { $legends[str_replace('.', '', $file)] = empty($data) ? $file : helper::filter($data, helper::FILTER_STRING_SHORT); } - // Données géographique - foreach ($legend as $file => $data) { - $geo[str_replace('.', '', $file)] = [ - 'long' => $this->getInput('gpslong[' . $file . ']', helper::FILTER_FLOAT), - 'lat' => $this->getInput('gpslat[' . $file . ']', helper::FILTER_FLOAT) - ]; - } // Sauvegarder $this->setData([ 'module', @@ -253,9 +245,7 @@ class geogallery extends common 'name' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'name']), 'directory' => $this->getData(['module', $this->getUrl(0), 'content', $this->getUrl(2), 'config', 'directory']), ], - 'legend' => $legends, - //'geo' => $geo, - 'position' => $geo + 'legend' => $legends ] ]); // Valeurs en sortie @@ -375,22 +365,16 @@ class geogallery extends common 'long' => $this->gps_decimal($exif['GPSLongitude'], $exif['GPSLatitudeRef']), 'img' => $fileInfos->getPath() . '/' . strtolower($fileInfos->getFilename()), 'thumb' => str_replace('source', 'thumb', $fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()), - 'label' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'legend', str_replace('.', '', $fileInfos->getFilename())]) - ]; - } else { - self::$galleries[] = [ - 'lat' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'position', 'directory', str_replace('.', '', $fileInfos->getFilename())]), - 'long' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'position', 'directory', str_replace('.', '', $fileInfos->getFilename())]), - 'img' => $fileInfos->getPath() . '/' . strtolower($fileInfos->getFilename()), - 'thumb' => str_replace('source', 'thumb', $fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($fileInfos->getFilename()), - 'label' => $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'legend', str_replace('.', '', $fileInfos->getFilename())]) + 'label' => is_null($this->getData(['module', $this->getUrl(0), 'content', $gallery, 'legend', str_replace('.', '', $fileInfos->getFilename())])) + ? '' + : $this->getData(['module', $this->getUrl(0), 'content', $gallery, 'legend', str_replace('.', '', $fileInfos->getFilename())]) ]; } } } } } - // Calcul du point central + // Calculer le centre géographique $totalLat = 0; @@ -443,33 +427,37 @@ class geogallery extends common } - // Fonction pour convertir les coordonnées GPS au format décimal private function gps_decimal($coordinate, $hemisphere) { - // Extrait les degrés, minutes et secondes - $degrees = count($coordinate) > 0 ? $this->gps2Num($coordinate[0]) : 0; - $minutes = count($coordinate) > 1 ? $this->gps2Num($coordinate[1]) : 0; - $seconds = count($coordinate) > 2 ? $this->gps2Num($coordinate[2]) : 0; - - // Convertit les degrés, minutes et secondes en décimal - $decimal = $degrees + ($minutes / 60) + ($seconds / 3600); - + // Extrait les degrés, minutes et secondes et force la conversion en flottant + $degrees = count($coordinate) > 0 ? (float)$this->gps2Num($coordinate[0]) : 0.0; + $minutes = count($coordinate) > 1 ? (float)$this->gps2Num($coordinate[1]) : 0.0; + $seconds = count($coordinate) > 2 ? (float)$this->gps2Num($coordinate[2]) : 0.0; + + // Convertit les degrés, minutes et secondes en décimal (assure le type flottant) + $decimal = $degrees + ($minutes / 60.0) + ($seconds / 3600.0); + // Si l'hémisphère est au Sud ou à l'Ouest, les coordonnées sont négatives - $decimal *= ($hemisphere == 'S' || $hemisphere == 'W') ? -1 : 1; - + if ($hemisphere == 'S' || $hemisphere == 'W') { + $decimal *= -1.0; // Multiplie par -1.0 pour assurer le type flottant + } + return $decimal; } + - // Fonction pour convertir les coordonnées GPS en nombre private function gps2Num($coordPart) { $parts = explode('/', $coordPart); - if (count($parts) <= 0) - return 0; - if (count($parts) == 1) - return $parts[0]; - return floatval($parts[0]) / floatval($parts[1]); + if (count($parts) <= 0) { + return 0.0; // Retourne 0.0 explicitement en flottant + } + if (count($parts) == 1) { + return (float)$parts[0]; // Convertit en flottant même s'il y a un seul élément + } + return floatval($parts[0]) / floatval($parts[1]); // Résultat de la division en flottant } + // Fonction pour calculer la distance entre deux points géographiques private function haversineGreatCircleDistance($latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo, $earthRadius = 6371) diff --git a/geogallery/view/index/index.js.php b/geogallery/view/index/index.js.php index 565f581..b8ce13c 100644 --- a/geogallery/view/index/index.js.php +++ b/geogallery/view/index/index.js.php @@ -18,8 +18,9 @@ $(document).ready(function () { const jsonOptions = ''; const objOptions = JSON.parse(jsonOptions); + // Initialisation de la carte - var map = L.map('map').setView([objOptions.lat, objOptions.long], objOptions.zoom - 1); + const map = L.map('map').setView([objOptions.lat, objOptions.long], objOptions.zoom - 1); // Ajouter une couche de tuiles OpenStreetMap L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { @@ -34,7 +35,7 @@ $(document).ready(function () { // Ajouter les marqueurs à la carte obj.forEach(function (location) { - var marker = L.marker([location.lat, location.long], { + const marker = L.marker([location.lat, location.long], { title: location.label }); marker.addTo(map);