You are here

protected function File::getGpsExif in Geocoder 8.3

Retrieves the latitude and longitude from exif data.

Parameters

array $coordinate: The coordinate.

string $hemisphere: The hemisphere.

Return value

float Return value based on coordinate and Hemisphere.

1 call to File::getGpsExif()
File::geocodeQuery in modules/geocoder_field/src/Geocoder/Provider/File.php

File

modules/geocoder_field/src/Geocoder/Provider/File.php, line 62

Class

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

Namespace

Drupal\geocoder_field\Geocoder\Provider

Code

protected function getGpsExif(array $coordinate, string $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;
}