Ignore:
Timestamp:
Sep 28, 2010, 10:20:33 PM (14 years ago)
Author:
rvelices
Message:
  • allow gps exif metadata synchronisation with high resolution images
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/rv_gmaps/trunk/admin/admin_sync.php

    r3447 r7033  
    1919if ( isset($_POST['submit']) )
    2020  $sync_options = array(
    21 //    'no_overwrite' => isset($_POST['no_overwrite']),
    2221    'simulate' => is_adviser() ? true : isset($_POST['simulate']),
     22                'use_high' => isset($_POST['use_high']),
    2323    'cat_id' => isset($_POST['cat_id']) ? (int)$_POST['cat_id'] : 0,
    2424    'subcats_included' => isset($_POST['subcats_included']),
     
    2626else
    2727  $sync_options = array(
    28 //    'no_overwrite' => true,
    2928    'simulate' => true,
     29                'use_high' => true,
    3030    'cat_id' => 0,
    3131    'subcats_included' => true,
     
    3535if ( isset($_POST['submit']) )
    3636{
     37        include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
     38
    3739  $where_clauses = array();
    3840  if ( $sync_options['cat_id']!=0 )
     
    4850
    4951    $query='
    50 SELECT id,path,lat,lon
     52SELECT id,path,lat,lon,has_high
    5153  FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id
    5254  WHERE category_id IN ('.implode(',', $cat_ids).')
     
    5658  {
    5759    $query='
    58 SELECT id,path,lat,lon
     60SELECT id,path,lat,lon,has_high
    5961  FROM '.IMAGES_TABLE;
    6062  }
     
    6567  foreach ($images as $image)
    6668  {
    67     $exif = @read_exif_data( $image['path'] );
    68     if ( empty($exif) )
    69       continue;
    70     $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude') ) );
    71     if ( count($exif)!=4 )
    72       continue;
    73     if ( !in_array($exif['GPSLatitudeRef'], array('S', 'N') ) )
    74     {
    75       $errors[] = $image['path']. ': GPSLatitudeRef not S or N';
    76       continue;
    77     }
    78     if ( !in_array($exif['GPSLongitudeRef'], array('W', 'E') ) )
    79     {
    80       $errors[] = $image['path']. ': GPSLongitudeRef not W or E';
    81       continue;
    82     }
    83     if (!is_array($exif['GPSLatitude']) or !is_array($exif['GPSLongitude']) )
    84     {
    85       $errors[] = $image['path']. ': GPSLatitude and GPSLongitude are not arrays';
    86       continue;
    87     }
    88     $lat = parse_lat_lon( $exif['GPSLatitude'] );
    89     if ( $exif['GPSLatitudeRef']=='S' )
    90       $lat = -$lat;
    91     $lon = parse_lat_lon( $exif['GPSLongitude'] );
    92     if ( $exif['GPSLongitudeRef']=='W' )
    93       $lon = -$lon;
    94     $datas[] = array (
    95       'id' => $image['id'],
    96       'lat' => $lat,
    97       'lon' => $lon,
    98       );
     69                $filename = $image['path'];
     70                if ($sync_options['use_high'] and $image['has_high']=='true')
     71                        $filename = get_high_path($image);
     72                $exif = @read_exif_data( $filename );
     73                if ( empty($exif) )
     74                        continue;
     75                $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude') ) );
     76                if ( count($exif)!=4 )
     77                        continue;
     78                if ( !in_array($exif['GPSLatitudeRef'], array('S', 'N') ) )
     79                {
     80                        $errors[] = $filename. ': GPSLatitudeRef not S or N';
     81                        continue;
     82                }
     83                if ( !in_array($exif['GPSLongitudeRef'], array('W', 'E') ) )
     84                {
     85                        $errors[] = $filename. ': GPSLongitudeRef not W or E';
     86                        continue;
     87                }
     88                if (!is_array($exif['GPSLatitude']) or !is_array($exif['GPSLongitude']) )
     89                {
     90                        $errors[] = $filename. ': GPSLatitude and GPSLongitude are not arrays';
     91                        continue;
     92                }
     93                $lat = parse_lat_lon( $exif['GPSLatitude'] );
     94                if ( $exif['GPSLatitudeRef']=='S' )
     95                        $lat = -$lat;
     96                $lon = parse_lat_lon( $exif['GPSLongitude'] );
     97                if ( $exif['GPSLongitudeRef']=='W' )
     98                        $lon = -$lon;
     99                $datas[] = array (
     100                        'id' => $image['id'],
     101                        'lat' => $lat,
     102                        'lon' => $lon,
     103                        );
    99104  }
    100105  $template->assign( 'sync_errors', $errors );
     
    135140$template->assign(
    136141    array(
    137       'SUBCATS_INCLUDED_CHECKED' => $sync_options['subcats_included'] ? 'checked="checked"' : ''
     142      'SUBCATS_INCLUDED_CHECKED' => $sync_options['subcats_included'] ? 'checked="checked"' : '',
     143                        'USE_HIGH_CHECKED' => $sync_options['use_high'] ? 'checked="checked"' : ''
    138144    )
    139145  );
Note: See TracChangeset for help on using the changeset viewer.