Changeset 12701 for extensions/rv_gmaps


Ignore:
Timestamp:
Dec 7, 2011, 10:48:16 PM (12 years ago)
Author:
rvelices
Message:

rv_gmaps auto sync gps with exif + towards full maps api v3 migration

Location:
extensions/rv_gmaps/trunk
Files:
1 added
4 deleted
7 edited

Legend:

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

    r12700 r12701  
    11<?php
    2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    33
    44include_once( dirname(__FILE__).'/../include/functions_map.php' );
  • extensions/rv_gmaps/trunk/admin/admin_sync.php

    r8367 r12701  
    11<?php
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    3 
    4 function parse_fract( $f )
    5 {
    6   $nd = explode( '/', $f );
    7   return $nd[0]/$nd[1];
    8 }
    9 
    10 function parse_lat_lon( $arr )
    11 {
    12   $v=0;
    13   $v += parse_fract( $arr[0] );
    14   $v += parse_fract( $arr[1] )/60;
    15   $v += parse_fract( $arr[2] )/3600;
    16   return $v;
    17 }
    183
    194if ( isset($_POST['submit']) )
     
    3621{
    3722        include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
    38 
     23  include_once( dirname(__FILE__).'/../include/functions_metadata.php' );
    3924  $where_clauses = array();
    4025  if ( $sync_options['cat_id']!=0 )
     
    7358                if ( empty($exif) )
    7459                        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') ) )
     60                $ll = exif_to_lat_lon($exif);
     61                if (!is_array($ll))
    7962                {
    80                         $errors[] = $filename. ': GPSLatitudeRef not S or N';
     63                        if (!empty($ll))
     64                                $errors[] = $filename. ': '.$ll;
    8165                        continue;
    8266                }
    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;
     67
    9968                $datas[] = array (
    10069                        'id' => $image['id'],
    101                         'lat' => $lat,
    102                         'lon' => $lon,
     70                        'lat' => $ll[0],
     71                        'lon' => $ll[1],
    10372                        );
    10473  }
  • extensions/rv_gmaps/trunk/main.inc.php

    r12700 r12701  
    11<?php /*
    22Plugin Name: RV Maps&Earth
    3 Version: 2.3.a
     3Version: 2.3.b-alpha
    44Description: Extend your gallery with Google Maps and Google Earth ...
    55Plugin URI: http://piwigo.org/ext/extension_view.php?eid=122
     
    77Author URI: http://www.modusoptimus.com/
    88*/
    9 define( 'RVM_PLUGIN_VERSION', '2.3.a');
    10 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     9define( 'RVM_PLUGIN_VERSION', '2.3.b-alpha');
     10defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    1111
    1212add_event_handler('loc_end_index', 'rvm_end_index' );
     
    2020$rvm_dir = basename( dirname(__FILE__) );
    2121
     22global $conf;
     23if (@$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}
    2229
    2330function rvm_index_cat_thumbs_displayed()
     
    132139}
    133140
     141function rvm_format_exif($exif, $file, $map)
     142{
     143  if (isset($map['lat']))
     144  {
     145                include_once( dirname(__FILE__) .'/include/functions_metadata.php');
     146                $ll = exif_to_lat_lon($exif);
     147                if (is_array($ll))
     148                {
     149                        $exif[$map['lat']] = $ll[0];
     150                        $exif[$map['lon']] = $ll[1];
     151                }
     152  }
     153  return $exif;
     154}
    134155?>
  • extensions/rv_gmaps/trunk/maintain.inc.php

    r3447 r12701  
    6666
    6767  $q = '
    68 DELETE FROM '.CONFIG_TABLE.' WHERE param="gmaps_api_key" LIMIT 1';
     68DELETE FROM '.CONFIG_TABLE.' WHERE param IN("gmaps_api_key","gmaps_auto_sync")';
    6969  pwg_query( $q );
    7070 
  • extensions/rv_gmaps/trunk/template/data_handler.js

    r12700 r12701  
    1212
    1313        google.maps.event.bind( this._map, "click", this, this._onMapClick);
    14         google.maps.event.bind( this._infoWindow, "domready", this, this._onInfoWindowDomReady);
     14        //google.maps.event.bind( this._infoWindow, "domready", this, this._onInfoWindowDomReady);
    1515}
    1616
     
    161161                google.maps.event.removeListener(h);
    162162
     163        google.maps.event.addListenerOnce( this._infoWindow, "domready", pwgBind(this, this._onInfoWindowDomReady) );
    163164        this._infoWindow.setContent( content );
    164165        this._infoWindow.setPosition( marker.getPosition() );
  • extensions/rv_gmaps/trunk/template/data_loader.js

    r12700 r12701  
    55                {
    66                        reload_data_timeout: 200,
    7                         rectangle_of_confusion: new google.maps.Size(32,16)
     7                        rectangle_of_confusion: new google.maps.Size(16,32)
    88                }
    99                , opts || {} );
     
    7575_loadData: function()
    7676{
    77         var bounds = this._map.getBounds();
    78 
     77        var bounds = new google.maps.LatLngBounds( this._map.getBounds().getSouthWest(), this._map.getBounds().getNorthEast() );
     78       
     79        //bug as of v 3.7 -
     80        var isOver = false;
     81        if (bounds.getSouthWest().lng() < bounds.getNorthEast().lng())
     82        {
     83                if ( this._map.getCenter().lng()<bounds.getSouthWest().lng() || this._map.getCenter().lng()>bounds.getNorthEast().lng() )
     84                {
     85                        isOver = true;
     86                }
     87        }
     88        else if ( this._map.getCenter().lng()>bounds.getNorthEast().lng() && this._map.getCenter().lng()<bounds.getSouthWest().lng() )
     89        {
     90                isOver = true;
     91        }
     92       
     93        if (isOver)
     94                bounds = new google.maps.LatLngBounds( new google.maps.LatLng(this._map.getBounds().getSouthWest().lat(),-179.9), new google.maps.LatLng(this._map.getBounds().getNorthEast().lat(), 179.9) );
     95        //end bug
     96       
     97       
    7998        var latRange = bounds.toSpan().lat();
    8099        var latPrec = latRange * this.options.rectangle_of_confusion.height / this._map.getDiv().offsetHeight;
  • extensions/rv_gmaps/trunk/template/map.tpl

    r12700 r12701  
    5151        if (console)
    5252        {
    53                 console.debug(msg + " b="+map.getBounds().toUrlValue() + " c="+map.getCenter().toUrlValue() + " z="+map.getZoom() );
     53                console.log(msg + " b="+map.getBounds().toUrlValue() + " c="+map.getCenter().toUrlValue() + " z="+map.getZoom() );
    5454        }
    5555}
     
    163163                if (lang_str == undefined)
    164164                {
    165                         if (document.is_debug) google.maps.Log.write("Language string undefined '"+ str+"'");
     165                        if (document.is_debug) glog("Language string undefined '"+ str+"'");
    166166                        return str;
    167167                }
Note: See TracChangeset for help on using the changeset viewer.