You are here

function ExifPHPExtension::_exif_reformat_DMS2D in Exif 7

Helper function to change GPS co-ords into decimals.

1 call to ExifPHPExtension::_exif_reformat_DMS2D()
ExifPHPExtension::_reformat in ./ExifPHPExtension.php
Helper function to reformat fields where required.

File

./ExifPHPExtension.php, line 251

Class

ExifPHPExtension

Namespace

Drupal\exif

Code

function _exif_reformat_DMS2D($value, $ref) {
  if (!is_array($value)) {
    $value = array(
      $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;
}