--- photobar.module 2006-08-30 16:25:07.000000000 +0300 +++ photobar.module 2006-08-30 16:24:50.000000000 +0300 @@ -167,6 +167,15 @@ } } +function _photobar_convert_to_dec($value) { + $result = ""; + + if (isset($value)) { + eval ("\$result = 1.0*$value;"); + } + return $result; +} + /** * Creates an image node used with a photobar. * @@ -193,9 +202,43 @@ //requires php with exif enabled $exif = exif_read_data($file); + $enable_locations = variable_get('location_image', 0); + + if ($exif && $enable_locations && isset($exif['GPSLatitude'])) { + $deg = _photobar_convert_to_dec($exif['GPSLatitude'][0]); + $min = _photobar_convert_to_dec($exif['GPSLatitude'][1]); + $sec = _photobar_convert_to_dec($exif['GPSLatitude'][2]); + + $latitude = ($min * 60.0 + $sec)/60.0; + $latitude = ($deg*60.0 + $latitude)/60.0; + } + else { + $latitude = -1; + } + + if ($exif && $enable_locations && isset($exif['GPSLongitude'])) { + $deg = _photobar_convert_to_dec($exif['GPSLongitude'][0]); + $min = _photobar_convert_to_dec($exif['GPSLongitude'][1]); + $sec = _photobar_convert_to_dec($exif['GPSLongitude'][2]); + + $longitude = ($min * 60.0 + $sec)/60.0; + $longitude = ($deg*60.0 + $longitude)/60.0; + } + else { + $longitude = -1; + } + + if ($latitude != -1 && $longitude != -1) { + $node->location['latitude'] = $latitude; + $node->location['longitude'] = $longitude; + $node->location['lat'] = $latitude; + $node->location['lon'] = $longitude; + } + if ( $exif && isset($exif['DateTime']) ) { $exif_datetime = $exif['DateTime']; $node->created = strtotime($exif_datetime); + if ( $node->created == 0 ) { list($date, $time) = split(" ", $exif_datetime); list($year, $month, $day) = split(":",$date);