private function ExifPHPExtension::exifReformatGps in Exif 8
Same name and namespace in other branches
- 8.2 src/ExifPHPExtension.php \Drupal\exif\ExifPHPExtension::exifReformatGps()
Helper function to change GPS co-ords into decimals.
Parameters
mixed $value: Raw value as array or string.
string $ref: Direction as a char (S/N/E/W)
Return value
float Calculated decimal value
1 call to ExifPHPExtension::exifReformatGps()
- ExifPHPExtension::reformat in src/
ExifPHPExtension.php - Helper function to reformat fields where required.
File
- src/
ExifPHPExtension.php, line 484
Class
- ExifPHPExtension
- Class ExifPHPExtension Parser implementation base d on PHP Exif extension.
Namespace
Drupal\exifCode
private function exifReformatGps($value, $ref) {
if (!is_array($value)) {
$value = [
$value,
];
}
$dec = 0;
$granularity = 0;
foreach ($value as $element) {
$parts = explode('/', $element);
$dec += (double) ((double) $parts[0] / (double) $parts[1] / pow(60, $granularity));
$granularity++;
}
if ($ref == 'S' || $ref == 'W') {
$dec *= -1;
}
return $dec;
}