Same name and namespace in other branches
  1. 8.x-2.x src/ExifPHPExtension.php \Drupal\exif\ExifPHPExtension::exifReformatGps() 1 comment

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\exif

Code

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;
}