Changeset 26331


Ignore:
Timestamp:
Dec 29, 2013, 3:14:42 PM (10 years ago)
Author:
rvelices
Message:

rv_gmaps compatible with nez latitude/longitude fields in piwigo core 2.6

Location:
extensions/rv_gmaps/trunk
Files:
2 deleted
12 edited

Legend:

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

    r17286 r26331  
    1414$tabsheet = new tabsheet();
    1515$tabsheet->add( 'config', 'Configuration', add_url_params( $my_base_url, array('tab'=>'config') ) );
    16 $tabsheet->add( 'sync', 'Synchronize', add_url_params( $my_base_url, array('tab'=>'sync') ) );
    1716$tabsheet->select($page['tab']);
    1817
  • extensions/rv_gmaps/trunk/admin/admin_boot.php

    r18951 r26331  
    3131{
    3232        if ($prefilter==="geotagged")
    33                 $query = 'lat IS NOT NULL AND lon IS NOT NULL';
     33                $query = 'latitude IS NOT NULL AND longitude IS NOT NULL';
    3434        elseif ($prefilter==="not geotagged")
    35                 $query = 'lat IS NULL OR lon IS NULL';
     35                $query = 'latitude IS NULL OR longitude IS NULL';
    3636
    3737        if ( isset($query) )
     
    7474                if ( (double)$lat<=90 and (double)$lat>=-90
    7575                                and (double)$lon<=180 and (double)$lon>=-180 )
    76                         $update_query = 'lat='.$lat.', lon='.$lon;
     76                        $update_query = 'latitude='.$lat.', longitude='.$lon;
    7777                else
    7878                        $page['errors'][] = 'Invalid lat or lon value';
    7979        }
    8080        elseif ( strlen($lat)==0 and strlen($lon)==0 )
    81                 $update_query = 'lat=NULL, lon=NULL';
     81                $update_query = 'latitude=NULL, longitude=NULL';
    8282        else
    8383                $page['errors'][] = 'Both lat/lon must be empty or not empty';
     
    124124    $data = array(
    125125      'id' => $row['id'],
    126       'lat' => trim($_POST['lat-'.$row['id']]),
    127       'lon' => trim($_POST['lon-'.$row['id']])
     126      'latitude' => trim($_POST['lat-'.$row['id']]),
     127      'longitude' => trim($_POST['lon-'.$row['id']])
    128128    );
    129129
    130     if ( strlen($data['lat'])>0 and strlen($data['lon'])>0 )
     130    if ( strlen($data['latitude'])>0 and strlen($data['longitude'])>0 )
    131131    {
    132       if ( (double)$data['lat']>90 or (double)$data['lat']<-90
    133           or (double)$data['lon']>180 or (double)$data['lon']<-180 )
     132      if ( (double)$data['latitude']>90 or (double)$data['latitude']<-90
     133          or (double)$data['longitude']>180 or (double)$data['longitude']<-180 )
    134134        $error = true;
    135135    }
    136     elseif ( strlen($data['lat'])==0 and strlen($data['lon'])==0 )
     136    elseif ( strlen($data['latitude'])==0 and strlen($data['longitude'])==0 )
    137137    {
    138138      // nothing
     
    153153    array(
    154154      'primary' => array('id'),
    155       'update' => array('lat', 'lon')
     155      'update' => array('latitude', 'longitude')
    156156      ),
    157157    $datas
     
    183183      <td>
    184184        <label>{\'Latitude\'|@translate}
    185           <input type="text" size="8" name="lat-{$element.id}" value="{$element.lat}">
     185          <input type="text" size="8" name="lat-{$element.id}" value="{$element.latitude}">
    186186        </label>
    187187        <label>{\'Longitude\'|@translate}
    188           <input type="text" size="9" name="lon-{$element.id}" value="{$element.lon}">
     188          <input type="text" size="9" name="lon-{$element.id}" value="{$element.longitude}">
    189189        </label>
    190190      </td>
  • extensions/rv_gmaps/trunk/admin/admin_config.php

    r23083 r26331  
    1717  }
    1818
    19   if (isset($_POST['gmaps_auto_sync']))
    20   {
    21     conf_update_param('gmaps_auto_sync', "1");
    22     $conf['gmaps_auto_sync']=1;
    23   }
    24   else
    25   {
    26     $query = 'DELETE FROM '.CONFIG_TABLE.' WHERE param="gmaps_auto_sync"';
    27     pwg_query($query);
    28     unset($conf['gmaps_auto_sync']);
    29   }
    30  
    3119  $gm_config = rvm_get_config();
    3220
     
    5240}
    5341
    54 $query = 'SELECT COUNT(*) FROM '.IMAGES_TABLE.' WHERE lat IS NOT NULL';
     42$query = 'SELECT COUNT(*) FROM '.IMAGES_TABLE.' WHERE latitude IS NOT NULL';
    5543list($nb_geotagged) = pwg_db_fetch_array( pwg_query($query) );
    5644
     
    5947      'NB_GEOTAGGED' => $nb_geotagged,
    6048      'GMAPS_API_KEY' => $conf['gmaps_api_key'],
    61       'GMAPS_AUTO_SYNC' => isset($conf['gmaps_auto_sync']) ? 1:0,
    6249      'NB_MARKERS' => rvm_get_config_var('nb_markers',40),
    6350      'NB_IMAGES_PER_MARKER' => rvm_get_config_var('nb_images_per_marker',20),
  • extensions/rv_gmaps/trunk/admin/admin_config.tpl

    r23083 r26331  
    1616        <br/> -->
    1717
    18         <li>
     18        <!--<li>
    1919         <label>
    2020                Automatically sync from exif
     
    2323                <br/><small>When metadata is synchronized, tour manual set coordinates might be overriden.</small>
    2424        </li>
    25         <br/>
     25        <br/> -->
    2626
    2727  <li>
  • extensions/rv_gmaps/trunk/include/functions.php

    r23519 r26331  
    2929  $query = '
    3030SELECT id FROM '.IMAGES_TABLE.'
    31 WHERE lat IS NOT NULL
     31WHERE latitude IS NOT NULL
    3232  AND id IN ('.implode(',', $items).')
    3333ORDER BY NULL
  • extensions/rv_gmaps/trunk/include/functions_map.php

    r22180 r26331  
    129129  if ( !isset($b) or empty($b) )
    130130    return null;
    131   $sql_where = 'i.lat BETWEEN '.$b['s'].' AND '.($b['n']);
     131  $sql_where = 'i.latitude BETWEEN '.$b['s'].' AND '.($b['n']);
    132132  $sql_where .= ' AND ';
    133133  if ($b['e'] >= $b['w'])
    134     $sql_where .= 'i.lon BETWEEN '.$b['w'].' AND '.($b['e']);
     134    $sql_where .= 'i.longitude BETWEEN '.$b['w'].' AND '.($b['e']);
    135135  else
    136     $sql_where .= 'i.lon NOT BETWEEN '.($b['e']+1e-7).' AND '.($b['w']-1e-7);
     136    $sql_where .= 'i.longitude NOT BETWEEN '.($b['e']+1e-7).' AND '.($b['w']-1e-7);
    137137  return $sql_where;
    138138}
     
    172172  if ($bounds['e']>180) $bounds['e']-=360;
    173173  $where_sql = rvm_bounds_to_sql( $bounds );
    174   $order_by = 'ORDER BY POW('.$ll['lat'].'-i.lat,2)+POW('.$cos_lat.'*('.$ll['lon'].'-i.lon),2)';
     174  $order_by = 'ORDER BY POW('.$ll['lat'].'-i.latitude,2)+POW('.$cos_lat.'*('.$ll['lon'].'-i.longitude),2)';
    175175  return $where_sql;
    176176}
     
    300300
    301301  $query = '
    302 SELECT category_id cat_id, uppercats, MAX(lat) AS n, MIN(lat) AS s, MAX(lon) AS e, MIN(lon) AS w, COUNT(i.id) count, MIN(i.date_creation) min_date, MAX(i.date_creation) max_date
     302SELECT category_id cat_id, uppercats, MAX(latitude) AS n, MIN(latitude) AS s, MAX(longitude) AS e, MIN(longitude) AS w, COUNT(i.id) count, MIN(i.date_creation) min_date, MAX(i.date_creation) max_date
    303303  FROM
    304304    '.CATEGORIES_TABLE.' as c
     
    369369
    370370  if (empty($where_sql))
    371     $where_sql .= 'i.lat IS NOT NULL';
     371    $where_sql .= 'i.latitude IS NOT NULL';
    372372  $where_sql_images_only = $where_sql;
    373373  $where_sql .= get_sql_condition_FandF(
  • extensions/rv_gmaps/trunk/include/picture_map.inc.php

    r24745 r26331  
    3636                        'MAP_TYPE' => rvm_get_config_var('map_type', 'ROADMAP'),
    3737      'U_NO_MAP' => duplicate_picture_url(),
    38       'U_BLOWUP' => rvm_make_blowup_url( array('ll'=>$picture), array('start','box') ),
     38      'U_BLOWUP' => rvm_make_blowup_url( array('ll'=> array('lat'=>$picture['latitude'],'lon'=>$picture['longitude'])), array('start','box') ),
    3939      'COMMENT_IMG' => trigger_event('render_element_description', $picture['comment'])
    4040    )
    4141  );
    42   if ( isset($picture['lat']) )
     42  if ( isset($picture['latitude']) )
    4343  {
    4444    $template->assign( 'coordinates',
    4545        array(
    46           'LAT' => $picture['lat'],
    47           'LON' => $picture['lon'],
     46          'LAT' => $picture['latitude'],
     47          'LON' => $picture['longitude'],
    4848        )
    4949      );
  • extensions/rv_gmaps/trunk/kml.php

    r20461 r26331  
    4444
    4545
    46 $img_fields = ' i.id,i.representative_ext,i.name,i.comment,i.file,i.path,i.lat,i.lon,i.date_creation';
     46$img_fields = ' i.id,i.representative_ext,i.name,i.comment,i.file,i.path,i.latitude AS lat,i.longitude AS lon,i.date_creation';
    4747
    4848rvm_build_section_items($img_fields, $where_sql, RVM_BUILD_ARRAY, $order_by);
  • extensions/rv_gmaps/trunk/main.inc.php

    r25367 r26331  
    2121
    2222global $conf;
    23 if (@$conf['gmaps_auto_sync'])
    24 {
    25   $conf['use_exif_mapping']['lat'] = 'lat';
    26   $conf['use_exif_mapping']['lon'] = 'lon';
    27   add_event_handler('format_exif_data', 'rvm_format_exif', EVENT_HANDLER_PRIORITY_NEUTRAL, 3);
    28 }
    2923
    3024function rvm_index_cat_thumbs_displayed()
     
    9084function rvm_picture_pictures_data($pictures)
    9185{
    92         if ( isset($pictures['current']['lat']) and isset($pictures['current']['lon']) )
     86        if ( isset($pictures['current']['latitude']) and isset($pictures['current']['longitude']) )
    9387        {
    9488                global $template;
    95                 $template->append('head_elements', '<meta name=geo.position content='.$pictures['current']['lat'].';'.$pictures['current']['lon'].'>' );
     89                $template->append('head_elements', '<meta name=geo.position content='.$pictures['current']['latitude'].';'.$pictures['current']['longitude'].'>' );
    9690                include_once( dirname(__FILE__) .'/include/functions.php');
    9791                rvm_load_language();
     
    132126}
    133127
    134 function rvm_format_exif($exif, $file, $map)
    135 {
    136   if (isset($map['lat']))
    137   {
    138                 include_once( dirname(__FILE__) .'/include/functions_metadata.php');
    139                 $ll = exif_to_lat_lon($exif);
    140                 if (is_array($ll))
    141                 {
    142                         $exif[$map['lat']] = $ll[0];
    143                         $exif[$map['lon']] = $ll[1];
    144                 }
    145   }
    146   return $exif;
    147 }
    148 
    149128if (defined('IN_ADMIN')) {
    150129        include_once(dirname(__FILE__).'/admin/admin_boot.php');
  • extensions/rv_gmaps/trunk/maintain.inc.php

    r16974 r26331  
    11<?php
     2function rvgm_drop_old_columns()
     3{
     4  $q = '
     5ALTER TABLE '.IMAGES_TABLE.' DROP COLUMN `lat`';
     6  pwg_query( $q );
     7
     8  $q = '
     9ALTER TABLE '.IMAGES_TABLE.' DROP COLUMN `lon`';
     10  pwg_query( $q );
     11}
     12
    213function plugin_install()
    314{
    4   $q = '
    5 ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN `lat` DOUBLE(8,6)';
    6   pwg_query($q);
    7  
    8   $q = '
    9 ALTER TABLE '.IMAGES_TABLE.' ADD INDEX images_lat(`lat`)';
    10   pwg_query($q);
    11 
    12   $q = '
    13 ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN `lon` DOUBLE(9,6)';
    14   pwg_query($q);
    15  
    1615  $q = '
    1716INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
     
    2524{
    2625  global $conf;
     26
     27  $query = 'SHOW COLUMNS FROM '. IMAGES_TABLE .' LIKE "latitude";';
     28
     29  if (pwg_db_num_rows(pwg_query($query)))
     30                rvgm_drop_old_columns();
     31        pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN("gmaps_auto_sync")');
    2732
    2833  if (!isset($conf['rv_gmaps_add_map.php']) or $conf['rv_gmaps_add_map.php'])
     
    6873function plugin_uninstall()
    6974{
    70   $q = '
    71 ALTER TABLE '.IMAGES_TABLE.' DROP COLUMN `lat`';
    72   pwg_query( $q );
    73 
    74   $q = '
    75 ALTER TABLE '.IMAGES_TABLE.' DROP COLUMN `lon`';
    76   pwg_query( $q );
     75  rvgm_drop_old_columns();
    7776
    7877  $q = '
  • extensions/rv_gmaps/trunk/map.php

    r25922 r26331  
    5050if ( !isset($_GET['ll']) /*and ($page['section']!='categories' or isset($page['category']) )*/ )
    5151{
    52   $img_fields = 'MIN(i.lat) s, MIN(i.lon) w, MAX(i.lat) n, MAX(i.lon) e';
     52  $img_fields = 'MIN(i.latitude) s, MIN(i.longitude) w, MAX(i.latitude) n, MAX(i.longitude) e';
    5353  $page['flat']=true;
    5454  rvm_build_section_items($img_fields, null, RVM_BUILD_AGGREGATE);
  • extensions/rv_gmaps/trunk/map_data.php

    r25792 r26331  
    3131$where_sql = rvm_bounds_to_sql( $page['box'] );
    3232
    33 $img_fields = ' i.id,i.representative_ext,i.name,i.comment,i.file,i.path,i.lat,i.lon,i.width,i.height,i.rotation';
     33$img_fields = ' i.id,i.representative_ext,i.name,i.comment,i.file,i.path,i.latitude AS lat,i.longitude AS lon,i.width,i.height,i.rotation';
    3434
    3535$was_flat = @$page['flat'];
Note: See TracChangeset for help on using the changeset viewer.