You are here

function geocoder_exif in Geocoder 7

Plugin callback.

1 call to geocoder_exif()
geocoder_exif_field in plugins/geocoder_handler/exif.inc
Plugin callback.
1 string reference to 'geocoder_exif'
exif.inc in plugins/geocoder_handler/exif.inc

File

plugins/geocoder_handler/exif.inc, line 19

Code

function geocoder_exif($uri, $options = array()) {

  // Invoke hook_file_download to check permissions
  // We are essentially duplicating the logic found in file.inc file_download()
  foreach (module_implements('file_download') as $module) {
    $function = $module . '_file_download';
    $result = $function($uri);
    if ($result === -1) {
      throw new Exception(t('You do not have permission to access this file'));
    }
  }

  // The user has permission to access the file. Geocode it.
  geophp_load();
  if ($data = exif_read_data(drupal_realpath($uri))) {
    if (!isset($data['GPSLatitudeRef'])) {
      return FALSE;
    }
    $lat = geocoder_exif_from($data['GPSLatitudeRef'], $data['GPSLatitude']);
    $lon = geocoder_exif_from($data['GPSLongitudeRef'], $data['GPSLongitude']);
    $point = new Point($lon, $lat);
    return $point;
  }
  return FALSE;
}