diff --git a/geogallery/geogallery.php b/geogallery/geogallery.php index b97f6bb..ce54ff9 100644 --- a/geogallery/geogallery.php +++ b/geogallery/geogallery.php @@ -283,7 +283,7 @@ class geogallery extends common $latitude = 'Donnée absente'; $longitude = 'Donnée absente'; // Vérifier si les données EXIF contiennent des informations de géolocalisation - if (!empty($exif['GPSLatitude']) && !empty($exif['GPSLongitude'])) { + if (!empty($exif['GPSLatitude']) || !empty($exif['GPSLongitude'])) { // Coordonnées de latitude $latitude = $this->gps_decimal($exif['GPSLatitude'], $exif['GPSLatitudeRef']); @@ -359,15 +359,20 @@ class geogallery extends common // Vérifier si les données EXIF contiennent des informations de géolocalisation if (!empty($exif['GPSLatitude']) || !empty($exif['GPSLongitude'])) { + // Coordonnées de latitude + $latitude = $this->gps_decimal($exif['GPSLatitude'], $exif['GPSLatitudeRef']); + + // Coordonnées de longitude + $longitude = $this->gps_decimal($exif['GPSLongitude'], $exif['GPSLongitudeRef']); // Coordonnées self::$galleries[] = [ - 'lat' => $this->gps_decimal($exif['GPSLatitude'], $exif['GPSLatitudeRef']), - 'long' => $this->gps_decimal($exif['GPSLongitude'], $exif['GPSLatitudeRef']), + 'lat' => $latitude, + 'long' => $longitude, 'img' => $fileInfos->getPath() . '/' . strtolower($fileInfos->getFilename()), 'thumb' => str_replace('source', 'thumb', $fileInfos->getPath()) . '/' . self::THUMBS_SEPARATOR . strtolower($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())]) + '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())]) ]; } } @@ -433,10 +438,10 @@ class geogallery extends common $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 if ($hemisphere == 'S' || $hemisphere == 'W') { $decimal *= -1.0; // Multiplie par -1.0 pour assurer le type flottant @@ -444,7 +449,7 @@ class geogallery extends common return $decimal; } - + private function gps2Num($coordPart) { @@ -456,8 +461,8 @@ class geogallery extends common 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)