You are here

protected function File::getGpsExif in Geocoder 8.2

Retrieves the latitude and longitude from exif data.

Parameters

string $coordinate: The coordinate.

string $hemisphere: The hemisphere.

Return value

float Return value based on coordinate and Hemisphere.

1 call to File::getGpsExif()
File::geocode in src/Geocoder/Provider/File.php

File

src/Geocoder/Provider/File.php, line 54

Class

File
Provides a file handler to be used by 'file' plugin.

Namespace

Drupal\geocoder\Geocoder\Provider

Code

protected function getGpsExif($coordinate, $hemisphere) {
  for ($i = 0; $i < 3; $i++) {
    $part = explode('/', $coordinate[$i]);
    if (count($part) == 1) {
      $coordinate[$i] = $part[0];
    }
    elseif (count($part) == 2) {
      $coordinate[$i] = floatval($part[0]) / floatval($part[1]);
    }
    else {
      $coordinate[$i] = 0;
    }
  }
  list($degrees, $minutes, $seconds) = $coordinate;
  $sign = $hemisphere == 'W' || $hemisphere == 'S' ? -1 : 1;
  $value = $sign * ($degrees + $minutes / 60 + $seconds / 3600);
  return $value;
}