Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
nmbgeek committed Sep 6, 2024
1 parent 4f68c6d commit ebc323d
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions lib/Listener/ExifMetadataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,40 +109,40 @@ public function handle(Event $event): void {
* @param array|string $coordinates
*/
private function gpsDegreesToDecimal($coordinates, ?string $hemisphere): float {
if (is_null($coordinates)) {
throw new \Exception('Coordinates are null');
}
if (is_null($coordinates)) {
throw new \Exception('Coordinates are null');
}

if (is_string($coordinates)) {
$coordinates = array_map("trim", explode(",", $coordinates));
}
if (is_string($coordinates)) {
$coordinates = array_map("trim", explode(",", $coordinates));
}

if (!is_array($coordinates) || count($coordinates) !== 3) {
throw new \Exception('Invalid coordinate format: ' . json_encode($coordinates));
}
if (!is_array($coordinates) || count($coordinates) !== 3) {
throw new \Exception('Invalid coordinate format: ' . json_encode($coordinates));
}

[$degrees, $minutes, $seconds] = array_map(fn ($rawDegree) => $this->parseGPSData($rawDegree), $coordin>
[$degrees, $minutes, $seconds] = array_map(fn ($rawDegree) => $this->parseGPSData($rawDegree), $coordin>

$sign = ($hemisphere === 'W' || $hemisphere === 'S') ? -1 : 1;
return $sign * ($degrees + $minutes / 60 + $seconds / 3600);
$sign = ($hemisphere === 'W' || $hemisphere === 'S') ? -1 : 1;
return $sign * ($degrees + $minutes / 60 + $seconds / 3600);
}

private function parseGPSData($rawData): float {
if (is_array($rawData)) {
// Assuming the values represent degrees, minutes, and seconds
if (count($rawData) === 3) {
return floatval($rawData[0]) + floatval($rawData[1]) / 60 + floatval($rawData[2]) / 3600;
} else {
return 0; // Handle unexpected array structure
}
}
$parts = explode('/', $rawData);

if ($parts[1] === '0') {
return 0;
}

return floatval($parts[0]) / floatval($parts[1] ?? 1);
if (is_array($rawData)) {
if (count($rawData) === 3) {
return floatval($rawData[0]) + floatval($rawData[1]) / 60 + floatval($rawData[2]) / 3600;
} else {
return 0; // Handle unexpected array structure
}
}

$parts = explode('/', $rawData);

if ($parts[1] === '0') {
return 0;
}

return floatval($parts[0]) / floatval($parts[1] ?? 1);
}

/**
Expand Down

0 comments on commit ebc323d

Please sign in to comment.