Changeset 27136 for extensions/exif_view
- Timestamp:
- Feb 2, 2014, 8:59:01 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/exif_view/main.inc.php
r23534 r27136 82 82 83 83 /** 84 * GPS function stolen from plugin rv_gmaps85 */86 function ev_parse_fract( $f )87 {88 $nd = explode( '/', $f );89 return $nd[0]/$nd[1];90 }91 92 function ev_parse_lat_lon( $arr )93 {94 $v=0;95 $v += ev_parse_fract( $arr[0] );96 $v += ev_parse_fract( $arr[1] )/60;97 $v += ev_parse_fract( $arr[2] )/3600;98 return $v;99 }100 101 function ev_exif_to_lat_lon( $exif )102 {103 $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude') ) );104 if ( count($exif)!=4 )105 return '';106 if ( !in_array($exif['GPSLatitudeRef'], array('S', 'N') ) )107 return 'GPSLatitudeRef not S or N';108 if ( !in_array($exif['GPSLongitudeRef'], array('W', 'E') ) )109 return 'GPSLongitudeRef not W or E';110 if (!is_array($exif['GPSLatitude']) or !is_array($exif['GPSLongitude']) )111 return 'GPSLatitude and GPSLongitude are not arrays';112 113 $lat = ev_parse_lat_lon( $exif['GPSLatitude'] );114 if ( $exif['GPSLatitudeRef']=='S' )115 $lat = -$lat;116 $lon = ev_parse_lat_lon( $exif['GPSLongitude'] );117 if ( $exif['GPSLongitudeRef']=='W' )118 $lon = -$lon;119 120 return array ($lat,$lon);121 }122 123 /**124 84 * EXIF translation. 125 85 * … … 404 364 loadLang(); 405 365 406 // extract latitude/longitude407 $latlon = ev_exif_to_lat_lon($exif);408 409 if (!empty($latlon))410 {411 $exif['GPSLatitude'] = sprintf('%.6f', $latlon[0]);412 $exif['GPSLongitude'] = sprintf('%.6f', $latlon[1]);413 }414 415 366 foreach ($exif as $key => $value) { 416 367 $exif[$key] = exif_key_translation($key, $value);
Note: See TracChangeset
for help on using the changeset viewer.