Changeset 9377 for extensions


Ignore:
Timestamp:
Feb 25, 2011, 12:44:14 PM (13 years ago)
Author:
cljosse
Message:

[edit_gmaps] adding support to the altitude.

Location:
extensions/edit_gmaps
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • extensions/edit_gmaps/admin/admin.php

    r8501 r9377  
    33include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
    44
     5$colonnes = cl_get_columns_of(IMAGES_TABLE);
     6$key = array_search('alt', $colonnes[IMAGES_TABLE]);
     7if (!$key){
     8    $q = 'ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN `alt` DOUBLE(9,6)';
     9    pwg_query($q);     
     10}               
     11/**
     12* list all columns of each given table
     13*
     14* @return array of array
     15*/
     16function cl_get_columns_of($table)
     17{
     18    $columns_of = array();
     19    $query = 'DESC '.$table.';';
     20    $result = mysql_query($query);     
     21    $columns_of[$table] = array();   
     22
     23    if ($result)   
     24        while ($row = mysql_fetch_row($result))
     25           array_push($columns_of[$table], $row[0]);
     26       
     27    return $columns_of;
     28}
     29
     30
    531$template->set_filename('plugin_admin_content', dirname(__FILE__).'/admin.tpl');
    632
    733if (!isset($_GET['tab']))
    8   $page['tab'] = 'config';
     34  $page['tab'] = 'edit';
    935else
    1036  $page['tab'] = $_GET['tab'];
    11   $page['tab'] =   'edit';
     37
    1238$my_base_url = get_admin_plugin_menu_link(__FILE__);
    1339
    1440$tabsheet = new tabsheet();
    1541$tabsheet->add( 'edit', 'Edit', add_url_params( $my_base_url, array('tab'=>'edit') ) );
     42//$tabsheet->add( 'edit_meta', 'Edit_meta', add_url_params( $my_base_url, array('tab'=>'edit_meta') ) );
    1643$tabsheet->select($page['tab']);
    1744$tabsheet->assign();
     
    2451$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
    2552
    26 
    2753?>
  • extensions/edit_gmaps/admin/admin_edit.php

    r8960 r9377  
    1414include (dirname(__FILE__).'\element_set.php');
    1515
     16
     17                               
     18if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     19
     20
     21/***********************************************************************************/
     22  if (!defined('TOOL_KIT_PATH')) define(  'TOOL_KIT_PATH',   EDIT_RV_PATH."admin/");
     23  if (!defined('INCLUDE_PATH')) define(  'INCLUDE_PATH',   TOOL_KIT_PATH.'include/' );                     
     24  $Toolkit_Dir =INCLUDE_PATH           ;   
     25
     26   include $Toolkit_Dir . 'fonctions.php';
     27/***********************************************************************************/
     28
     29 
    1630$template->concat('TABSHEET_TITLE', ' '.l10n_dec('%d image', '%d images', count($page['cat_elements_id'])).' - '.$page['title']);
    17 if ( isset($_POST['submit']) and !is_adviser() )
     31
     32
     33if ( isset($_POST['submit'])  )
    1834{
    1935  $collection = array();
    2036  if( !isset ($_POST['target']))
    2137  {
    22   $_POST['submit'] == l10n('Submit') ;
    23   $_POST['target']='selection';
    24     $collection = $_POST['selection'];
     38        $_POST['submit'] == l10n('Submit') ;
     39        $_POST['target']='selection';
     40        $collection = $_POST['selection'];
    2541
    2642  }
     
    3753        $collection = $_POST['selection'];
    3854      break;
    39   }
    40  
     55  }
    4156
    4257  // test si mise à jour (valider)
     
    4762                $lat = trim($_POST['lat']);
    4863                $lon = trim($_POST['lon']);
    49 
     64        $alt = trim($_POST['alt']);
     65 
    5066                if ( strlen($lat)>0 and strlen($lon)>0 )
    5167                {
     
    6177                  $page['errors'][] = 'Both lat/lon must be empty or not empty';
    6278
     79        if ( strlen($alt)==0)
     80             $update_query .= ', alt=NULL';
     81          else
     82             $update_query .= ', alt=' .$alt ;
     83
     84
     85
    6386                if (isset($update_query))
    6487                {
     
    6790                        WHERE id IN ('.implode(',',$collection).')';
    6891                  pwg_query($update_query);
    69                   clm_invalidate_cache();
     92                  cl_meta_invalidate_cache();
    7093                }
    7194          }
     
    127150{
    128151  $query='
    129 SELECT id,tn_ext,name,path,file,lat,lon FROM '.IMAGES_TABLE.'
     152SELECT id,tn_ext,name,path,file,lat,lon,alt FROM '.IMAGES_TABLE.'
    130153  WHERE id IN ('.implode(',',$page['cat_elements_id']).')
    131154  '.$conf['order_by'].'
     
    157180
    158181//==========================================================
    159         if (!defined('EDIT_RV_ROOT')) define(  'EDIT_RV_ROOT',  PHPWG_PLUGINS_PATH.'edit_gmaps/admin/' );
     182        if (!defined('EDIT_RV_PATH')) define(  'EDIT_RV_PATH',  EDIT_RV_PATH .'admin/' );
    160183        $path = EDIT_RV_PATH;
    161184    $plg_data = implode( '', file($path.'main.inc.php') );
    162185         if (preg_match("|Version: (.*)|", $plg_data, $val))
    163           { $edit_rv_plugin['version'] = trim($val[1]);  } 
    164     $edit_rv_plugin = array_map('htmlspecialchars', $edit_rv_plugin);
    165         $version= $edit_rv_plugin['version'] ;
    166         $icon_path = 'themes/default/icon/help.png';
    167         $path_js=  'themes/default/js/' ;
     186          { $EDIT_RV_PATH_plugin['version'] = trim($val[1]);  } 
     187            $EDIT_RV_PATH_plugin = array_map('htmlspecialchars', $EDIT_RV_PATH_plugin);
     188            $version= $EDIT_RV_PATH_plugin['version'] ;
     189            $icon_path = 'themes/default/icon/help.png';
     190            $path_js=  'themes/default/js/' ;
    168191
    169192//==================================================================================
    170193$match=""; 
    171 if ( isset($_POST['submit']) and !is_adviser() )
     194if ( isset($_POST['submit'])   )
    172195{       
    173196
     
    191214$src="";
    192215$template->assign(
    193     array(      'EDIT_RV_ROOT' => EDIT_RV_ROOT,
     216    array(      'EDIT_RV_PATH' => EDIT_RV_PATH,
    194217                'path_js' => $path_js,
    195218            'VERSION'=> $version,
    196             'EDIT_RV_ROOT_ABS' => dirname(__FILE__).'/',
     219            'EDIT_RV_PATH_ABS' => dirname(__FILE__).'/',
    197220              )
    198221  );
     
    209232                                                                                 'ADRESSE' => $adresse,
    210233                                                                                 'ZOOM' => 18,
     234                                         'ALT' => 0
     235                                                                                )
     236                                                                        );
     237                                    $filename ="";
     238
     239if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' ))
     240{
     241    if (isset($collection))     
     242        {  $lat =1000;
     243            foreach ($collection as $id_0)  {
     244                        foreach ($images as $image)  {
     245                                if (array_search($id_0,$image)) {
     246                                    $_POST['selection'] = $collection ;   
     247                     
     248                        $infos_gps=  Get_exif_gps( $image['path'],$image) ;   
     249                        if( $image['lat'] == ''){ 
     250                                $image['lat']=$infos_gps['lat'];
     251                                $image['lon']=$infos_gps['lon'];
     252                                $image['alt']=$infos_gps['alt'];
     253                            }else {
     254                                $image['lat']=$infos_gps['lat'];
     255                                $image['lon']=$infos_gps['lon'];
     256                                $image['alt']=$infos_gps['alt'];
     257                            }       
     258      $filename=  $image;
     259   
     260         
     261                if ($lat==1000) {
     262                            $lat= ($image['lat'] <> '') ? $image['lat'] : '100'  ;
     263                                $lon= ($image['lon']  <> '') ? $image['lon'] : '3.0'  ;
     264                $alt= ($image['alt']  <> '') ? $image['alt'] : '0'  ;
     265                                if($lat != '100') $lat=$image['lat'];
     266                                //=====================================================
     267                                $template->assign( 'coordinates',
     268                                                   array('LAT' =>   $lat  ,
     269                                                                                 'LON' =>   $lon  ,
     270                                                                                 'ADRESSE' =>  $adresse ,
     271                                                                                 'ZOOM' => 4,
     272                                         'ALT' =>   $alt ,
    211273                                                                                )
    212274                                                                        );
    213 if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' ))
    214 {
    215 
    216 if (isset($collection))
    217 {   
    218     $lat =1000;
    219   foreach ($collection as $id_0)  {
    220                 foreach ($images as $image)  {
    221                         if (array_search($id_0,$image)) {
    222                           $_POST['selection'] = $collection ;
    223 
    224                           if ($lat==1000) {
    225                             $lat1= ($image['lat'] <> '') ? $image['lat'] : '100'  ;
    226                                 $lon1= ($image['lon']  <> '') ? $image['lon'] : '3.0'  ;
    227                                 if($lat1 != '100') $lat=$image['lat'];
    228                                
    229                                 $template->assign( 'coordinates',
    230                                                    array('LAT' =>   $lat1  ,
    231                                                                                  'LON' =>   $lon1  ,
    232                                                                                  'ADRESSE' =>  $adresse ,
    233                                                                                  'ZOOM' => 4,
    234                                                                                 )
    235                                                                         );
    236 
    237275                                }
    238 
    239                          $tpl_var = array_merge(
     276                $lonDMS= dec2dms($lon) ;
     277                $latDMS= dec2dms($lat) ;
     278                if ($infos_gps['lat']=="")
     279                  $icon='icon/minus.png';
     280                  else $icon='icon/minus.png';
     281
     282                            $tpl_var = array_merge(
    240283                                    $image,
    241284                                        array(
    242                                                    'lat'  =>   $image['lat']    ,
    243                                                    'lon' =>  $image['lon']    ,
     285                           'icon' => $icon ,
     286                                                   'lat'  =>    $image['lat']    ,
     287                                                   'lon' =>     $image['lon']    ,
     288                           'alt' =>     $image['alt']    ,
     289                           'latDMS' =>    $latDMS[3]     ,
     290                           'lonDMS' =>   $lonDMS[3]     ,
    244291                                                   'adresse' =>  $adresse   ,
    245292                                                'U_TN' => get_thumbnail_url($image),
     
    260307        }
    261308  }
    262 }
    263 
     309
     310}
     311
     312
     313 if ( !empty($filename))
     314 {
     315// document.Envoie.latDMS.value
     316        $image= $filename ;
     317        $filename= $filename['path'] ;
     318        $Val_exif="";
     319        $Val_XMP="";   
     320          // error_reporting ( 0 );
     321  // Hide any unknown EXIF tags
     322/*
     323 $GLOBALS['HIDE_UNKNOWN_TAGS'] = FALSE;
     324   include $Toolkit_Dir . 'Toolkit_Version.php';          // Change: added as of version 1.11
     325   include $Toolkit_Dir . 'JPEG.php';                     // Change: Allow this example file to be easily relocatable - as of version 1.11
     326   include $Toolkit_Dir . 'JFIF.php';
     327   include $Toolkit_Dir . 'PictureInfo.php';
     328   include $Toolkit_Dir . 'XMP.php';
     329   include $Toolkit_Dir . 'Photoshop_IRB.php';
     330   include $Toolkit_Dir . 'EXIF.php';
     331 
     332        $jpeg_header_data = get_jpeg_header_data($filename );
     333     */   
     334     if (!empty($infos_gps))
     335     $Position = $infos_gps ;
     336
     337     else  $Position =  Get_exif_gps($filename,$image) ;
     338
     339
     340
     341     $template->assign( array(
     342      'filename_abs' =>   $filename ,
     343      'filename' => $filename,
     344     'datas'    =>    array(
     345     /*     'Val_JPEG_APP'=> Generate_JPEG_APP_Segment_HTML( $jpeg_header_data ),
     346        'Val_intrinsic'=> Interpret_intrinsic_values_to_HTML( get_jpeg_intrinsic_values( $jpeg_header_data ) ),
     347        'Val_Comment'=> Interpret_Comment_to_HTML( $jpeg_header_data ),
     348        'Val_JFIF'=> Interpret_JFIF_to_HTML( get_JFIF( $jpeg_header_data ), $filename ),
     349        'Val_JFXX'=>Interpret_JFXX_to_HTML( get_JFXX( $jpeg_header_data ), $filename ),
     350        'Val_App12' => Interpret_App12_Pic_Info_to_HTML( $jpeg_header_data ),         
     351        'Val_IRB' => Interpret_IRB_to_HTML( get_Photoshop_IRB( $jpeg_header_data ), $filename ),
     352
     353        'Val_exif'=>  Interpret_EXIF_to_HTML( get_EXIF_JPEG( $filename ), $filename),
     354        'Val_XMP' =>  Interpret_XMP_to_HTML( read_XMP_array_from_text( get_XMP_text( $jpeg_header_data) ) ),
     355          */
     356     //
     357         ),
     358 'Datadase' =>  ($Position) ,
     359          ) );
     360}
     361
     362function Memo_vars($variables)
     363{
     364                ob_start();
     365                echo '<pre>';
     366                print_r($variables);
     367                echo '</pre>';
     368                $m= ob_get_contents();
     369
     370        ob_end_clean();
     371                return $m;
     372               
     373}
    264374  //=======================================================================
    265375function cl_make_map_picture_url($params)
     
    271381        return add_url_params($map_url, array('map'=>null) );
    272382}
    273 ?>
     383$v1=0;
     384
     385
     386function Get_exif_gps($filename,$image)
     387{
     388 error_reporting ( 1 );
     389  $datas = array();
     390  $errors = array();
     391        //     
     392
     393     // $Exif_array =    get_EXIF_JPEG( $filename );     
     394     //  if ( empty($Exif_array) ) return;
     395
     396     $exif = @read_exif_data( $filename ); 
     397 
     398
     399      if ( empty($exif) ) return;
     400         $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) );
     401 
     402
     403       error_reporting ( 1 );
     404       /*
     405 if ( count($exif)<4)
     406                        return;
     407 
     408
     409     if ( !in_array($exif['GPSLatitudeRef'], array('S', 'N') ) )
     410                {
     411                        $errors[] = $filename. ': GPSLatitudeRef not S or N';
     412                        return;
     413                }
     414                if ( !in_array($exif['GPSLongitudeRef'], array('W', 'E') ) )
     415                {
     416                        $errors[] = $filename. ': GPSLongitudeRef not W or E';
     417                        return;
     418                }
     419                if (!is_array($exif['GPSLatitude']) or !is_array($exif['GPSLongitude']) )
     420                {
     421                        $errors[] = $filename. ': GPSLatitude and GPSLongitude are not arrays';
     422                        return;
     423                }       
     424*/
     425
     426
     427    $lat = $image['lat'] ;         
     428    $lon = $image['lon'] ;
     429    $alt=$image['alt'];
     430
     431if ($lat =="")
     432{
     433  $lat = Parse_Lat_Lon( $exif['GPSLatitude'] ); 
     434  if ( $exif['GPSLatitudeRef']=='S' )$lat = -$lat;
     435     $latDMS=$exif['GPSLatitude'][0] . " | " . $exif['GPSLatitude'][1]. " | " . $exif['GPSLatitude'][2] ;
     436
     437}else{
     438
     439    if($lat<0)      $exif['GPSLatitudeRef']='S' ;
     440        else        $exif['GPSLatitudeRef']='N' ;
     441        $latDMS=dec2dms($lat);
     442        $exif['GPSLatitude']= $latDMS ;
     443}         
     444global $errors;
     445if (!is_array($exif['GPSLatitude']) or !is_array($exif['GPSLongitude']) )
     446                {
     447                        $errors[] = $filename. ': GPSLatitude and GPSLongitude are not arrays';
     448                        //return;
     449                }       
     450
     451      if ($lon =="") {
     452       
     453            $lon = parse_lat_lon( $exif['GPSLongitude'] );
     454            $lonDMS= $exif['GPSLongitude'][0] . " | " . $exif['GPSLongitude'][1] . " | " . $exif['GPSLongitude'][2] ;
     455  if ( $exif['GPSLongitudeRef']=='W' ) $lon = -$lon;
     456           }else{
     457             if ($lon<0) $exif['GPSLongitudeRef'] ='W' ;
     458             else $exif['GPSLongitudeRef'] ='E' ;
     459              $lonDMS=dec2dms($lon);
     460                 $exif['GPSLongitude']=$lonDMS ;
     461           }
     462
     463           
     464
     465//=======================================================================         
     466           $altref = 0;
     467
     468if (!is_array($exif['GPSAltitude']) or !is_array($exif['GPSAltitudeRef']) )
     469                {
     470                         $exif['GPSAltitude']=$alt;
     471             $exif['GPSAltitudeRef']=0;
     472                }       else {
     473                $alt =           $exif['GPSAltitude'];
     474            $altref = $exif['GPSAltitudeRef'];
     475        }
     476 //========================================================================           
     477
     478                $datas[] = array (
     479            ' filename=' => $filename ,
     480                        'id' =>    $image['id'] ,
     481                        'lat' =>   $lat ,
     482                        'lon' =>   $lon ,
     483                        'latDMS' =>     $exif['GPSLatitude'][0]['Numerator']  . "/" .
     484                            $exif['GPSLatitude'][0]['Denominator'] . " " .   
     485                            $exif['GPSLatitude'][1]['Numerator'] . "/" .
     486                            $exif['GPSLatitude'][1]['Denominator']. " " .   
     487                            $exif['GPSLatitude'][2]['Numerator'] . "/" .
     488                            $exif['GPSLatitude'][2]['Denominator'],
     489                        'lonDMS' =>     $exif['GPSLongitude'][0]['Numerator']  . "/" .
     490                            $exif['GPSLongitude'][0]['Denominator'] . " " .   
     491                            $exif['GPSLongitude'][1]['Numerator'] . "/" .
     492                            $exif['GPSLongitude'][1]['Denominator']. " " .   
     493                            $exif['GPSLongitude'][2]['Numerator'] . "/" .
     494                            $exif['GPSLongitude'][2]['Denominator'],
     495            'altref' => $exif['GPSAltitudeRef'],
     496            'alt' =>   $exif['GPSAltitude'] ,
     497
     498                        ); 
     499
     500return $datas[0] ;
     501}
     502?>
  • extensions/edit_gmaps/admin/admin_edit.tpl

    r8960 r9377  
    22{* $Id: admin_edit.tpl  2011-01-03   *}
    33{if PHPWG_VERSION < 2.2 } {include
    4 file=$EDIT_RV_ROOT_ABS|@cat:'header_2_1.tpl'} {else} {include file= $EDIT_RV_ROOT_ABS|@cat:'header_2_2.tpl'}
     4file=$EDIT_RV_PATH_ABS|@cat:'header_2_1.tpl'} {else} {include file= $EDIT_RV_PATH_ABS|@cat:'header_2_2.tpl'}
    55{/if}
    66
     
    1414                 LON:'{$coordinates.LON}',
    1515                 ADRESSE:'{$coordinates.ADRESSE}',
    16                  ZOOM:18
     16                 ZOOM:18,
     17                                 ALT:'{$coordinates.ALT}'
    1718                 };
    1819                 {else}
     
    2122                 LON:' ',
    2223                 ADRESSE:'{$coordinates.ADRESSE}',
    23                  ZOOM:4
     24                 ZOOM:4,
     25                                 ALT:' '
    2426                 };
    2527           {/if}           
     
    2931                });
    3032
    31     // Event.observe(window, 'load', onLoad );
     33 
    3234
    3335            </script>
     
    166168
    167169        <label>{'Form'|@translate}</label>
    168         <table>
     170        <table >
    169171        <td >
    170172 
     
    173175        <input class="cluetip" title="{'lieu'|@translate}|{'hlp_line5'|@translate}." type="text" size="70"   value="{$match}"  name="match"   id="match"    />
    174176        </td>
    175         <tr> 
    176         <td>
     177                <table >
     178        <tr>   <input type="text" size="15" value="{$filename}"  name="filename" />
     179        <td >
    177180        <label>Latitude (-90=S to 90=N)</label>
    178         <input type="text" size="8" value="{$lat}"  name="lat" />
     181        <input type="text" size="15" value="{$lat}"  name="lat" />
    179182        </td>
    180183        <td>         
    181184        <label>Longitude (-180=E to 180=W) </label>
    182         <input type="text" size="9"value="{$lon}"  name="lon"  />         
    183         </td>
    184         </tr><tr>
    185 
    186         <td><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" {$tag_input_enabled} /></td>
     185        <input type="text" size="15"value="{$lon}"  name="lon"  />         
     186        </td>
     187        <td>         
     188        <label>Altitude </label>
     189                <input type="hidden" size="2"value="0"  name="altRef"  />
     190        <input type="text" size="15"value="{$alt}"  name="alt"  /> <label> m </label>         
     191        </td>
     192        </tr>
     193                </table>
     194                <tr>
     195                <table >
     196        <tr> 
     197        <td >
     198        <label>Latitude DMS</label><input type="text" size="3" value="{$latRef}"  name="latRef" />
     199        <input type="text" size="25" value="{$latDMS}"  name="latDMS" />
     200        </td>
     201        <td>         
     202        <label>Longitude DMS </label><input type="text" size="3" value="{$lonRef}"  name="lonRef" />
     203        <input type="text" size="25"value="{$lonDMS}"  name="lonDMS"  />         
     204        </td>
     205
     206        </tr>
     207                </table>
     208                <tr>
     209
     210        <td>
     211                <input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" {$tag_input_enabled} /></td>
    187212        </td></tr>
    188213        </table>
     
    198223    </fieldset>
    199224  </fieldset>
    200 
    201225</form>
     226
     227 <fieldset style="display:none">
     228<form name="EditJPEG" id="EditJPEG" action="{$EDIT_RV_PATH}Write_File_Info_Gps.php" method="post">
     229  <input name="filename" size="60" id="filename" name="filename" type="test" value="../../../{$filename}"  />
     230  <table>
     231    <tr>
     232        <td>
     233            Latitude Ref
     234        </td>
     235        <td>
     236              <input size="60" id="latRef" name="GPSLatitudeRef" type="text" value="{$latRef}">
     237        </td>
     238     
     239        <td>
     240            Latitude
     241        </td>
     242        <td>
     243             <input size="60" id="latDMS" name="GPSLatitude" type="text" value="{$latDMS}">   
     244        </td>
     245    </tr>
     246        <tr>
     247        <td>
     248            Longitude Ref
     249        </td>
     250        <td>
     251            <input size="60" id="lonRef" name="GPSLongitudeRef" type="text" value="{$lonRef}">
     252        </td>
     253 
     254        <td>
     255            Longitude
     256        </td>
     257        <td>
     258<input size=60 id="lonDMS" name="GPSLongitude" type=\"text\" value="{$lonDMS}">
     259        </td>
     260    </tr>
     261        <tr>
     262                       <td>
     263            Altitude Ref
     264        </td>
     265        <td>
     266<input size=60 id="altRef" name="GPSAltitudeRef" type=\"text\" value="{$altRef}">
     267        </td>
     268        <td>
     269            Altitude
     270        </td>
     271        <td>
     272<input size=60 id="alt" name="GPSAltitude" type=\"text\" value="{$alt}">
     273        </td>
     274    </tr>
     275</table>
     276<br>
     277<input type="submit" value="Update!">
     278</form>
     279</fieldset>
  • extensions/edit_gmaps/admin/header_2_1.tpl

    r8960 r9377  
    33{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/ui.core.js"}
    44{known_script id="jquery.ui.resizable" src=$ROOT_URL|@cat:"themes/default/js/ui/ui.resizable.js"}
    5 {known_script id="EDIT_RV_script" src=$EDIT_RV_ROOT|@cat:"js/JScript.js"}
    6 {known_script id="fieldset" src=$EDIT_RV_ROOT|@cat:"js/fieldset.js"}
     5{known_script id="EDIT_RV_script" src=$EDIT_RV_PATH|@cat:"admin/js/JScript.js"}
     6{known_script id="fieldset" src=$EDIT_RV_PATH|@cat:"admin/js/fieldset.js"}
  • extensions/edit_gmaps/admin/header_2_2.tpl

    r8960 r9377  
    77
    88
    9 {combine_script id="EDIT_RV_script" path=$EDIT_RV_ROOT|@cat:"js/JScript.js" require="jquery"}
    10 {combine_script id="fieldset" path=$EDIT_RV_ROOT|@cat:"js/fieldset.js" require="jquery"}
     9{combine_script id="EDIT_RV_script" path=$EDIT_RV_PATH|@cat:"admin/js/JScript.js" require="jquery"}
     10{combine_script id="fieldset" path=$EDIT_RV_PATH|@cat:"admin/js/fieldset.js" require="jquery"}
  • extensions/edit_gmaps/admin/js/JScript.js

    r8501 r9377  
    8080
    8181            google.maps.event.addListener(marker,
    82         'dragend',
    83         function () {
    84             updateMarkerStatus('Drag ended');
    85             geocodePosition(marker.getPosition());
    86            
    87             }
     82                                            'dragend',
     83                                            function () {
     84
     85                                             
     86                                     
     87                                              // getElevation({ latLng: marker.getPosition() });
     88                                                geocodePosition(marker.getPosition());
     89                                                updateMarkerStatus('Drag ended');
     90                                                getElevation({ 'latLng': marker.getPosition() });
     91                                                document.Envoie.alt.value = coordinates.ALT;
     92
     93                                            }
    8894        );
    8995
    90 
    91 
    92                         // Update current position info.   
     96       // styleIcon = new StyledIcon(StyledIconTypes.BUBBLE, { color: "#cccccc", text: "Drag Me!" });
     97       // var styleMaker1 = new StyledMarker({ styleIcon: styleIcon, position: new google.maps.LatLng(37.383477473067, -121.880502070713), map: map, draggable: true });
     98
     99       // google.maps.event.addDomListener(styleMaker1, "dragend", getElevation);
     100                                            // Update current position info.   
     101
    93102                       updateMarkerPosition(LatLng);
    94103                       geocodePosition(LatLng);
    95              
     104                       getElevation({ 'latLng': marker.getPosition() });
     105                       document.Envoie.alt.value = coordinates.ALT;
    96106                  return false;
    97107   
     
    109119                document.Envoie.lat.value=latLng.lat() ;
    110120                document.Envoie.lon.value = latLng.lng();
    111                
    112                
     121                dms_frac = dec2dms(latLng.lng());
     122                if (dms_frac.Degre < 0)
     123                    document.Envoie.lonRef.value = "W";
     124                else
     125                    document.Envoie.lonRef.value = "E";
     126                document.Envoie.lonDMS.value = Math.abs(dms_frac.Degre) +"/1" + " " + dms_frac.Minute +"/1" + " " +    dms_frac.Numerator + "/" + dms_frac.Denominator;
     127                dms_frac = dec2dms(latLng.lat());
     128                if (dms_frac.Degre < 0)
     129                    document.Envoie.latRef.value = "S";
     130                else
     131                    document.Envoie.latRef.value = "N";
     132                document.Envoie.latDMS.value = Math.abs(dms_frac.Degre) + "/1" + " " + dms_frac.Minute + "/1" + " " + dms_frac.Numerator + "/" + dms_frac.Denominator;
     133                update_datas();
     134            }
     135
     136
     137                function update_datas() {
     138                n= jQuery(document.EditJPEG);
     139
     140                jQuery.each(n[0], function (i) {
     141
     142
     143                    n00 = this;
     144                    n0 = n00.id;
     145                    n1 = n00.name;
     146                    n2 = jQuery(n00).val();
     147                    try {
     148                        if (n0 == "alt") {
     149                            n3 = dec2frac(document.Envoie[n0].value);
     150                            n3 = n3.Numerator + "/" + n3.Denominator;
     151                            jQuery(this).val(n3);
     152                        }
     153                        else {
     154                            n3 = document.Envoie[n0].value;
     155                            jQuery(this).val(n3);
     156                        }
     157                    }
     158                    catch (e) {
     159                        n3 = n0;
     160                    }
     161
     162
     163
     164                }
     165                )
     166
     167                   
     168
    113169                }
    114170           
     
    119175            }
    120176
    121 
    122        
    123 
    124 
    125         function geocodePosition(pos) {
    126             geocoder.geocode({ 'latLng': pos },
    127                function (results, status) {
     177            function getElevation(event) {
     178                var elevator = new google.maps.ElevationService();
     179                var locations = [];
     180
     181                // Retrieve the clicked location and push it on the array
     182                var clickedLocation = event.latLng;
     183                locations.push(clickedLocation);
     184
     185                // Create a LocationElevationRequest object using the array's one value
     186                var positionalRequest = {
     187                    'locations': locations
     188                }
     189
     190                // Initiate the location request
     191                if (elevator) {
     192                    elevator.getElevationForLocations(positionalRequest, function (results, status) {
     193                        if (status == google.maps.ElevationStatus.OK) {
     194
     195                            // Retrieve the first result
     196                            if (results[0]) {
     197                                coordinates.ALT = results[0].elevation;
     198                                document.Envoie.alt.value = coordinates.ALT;
     199                                update_datas();
     200                                   //styleIcon.set("text", "Elevation: " + results[0].elevation + "m");
     201                            } else {
     202                               // alert("No results found");
     203                            }
     204                        } else {
     205                            alert("Elevation service failed due to: " + status);
     206                        }
     207                    });
     208                }
     209            }
     210
     211
     212
     213            function geocodePosition(pos) {
     214                     geocoder.geocode({ 'latLng': pos },
     215                    function (results, status) {
    128216                   /* Si le géocodage inversé a réussi */
    129217                   if (status == google.maps.GeocoderStatus.OK) {
     
    198286
    199287        coordinates = { ADRESSE: jQuery("#match").val(),
    200                         LAT:0,LON:0,ZOOM: 18
     288                        LAT:0,LON:0,ZOOM: 18 ,ALT:0
    201289                       };
    202290        codeAddress();
     
    212300        if (Code != 13) return true;
    213301        coordinates = { ADRESSE: jQuery("#match").val(),
    214                         LAT:0,LON:0,ZOOM: 18
     302            LAT: 0, LON: 0, ZOOM: 18, ALT: 0
    215303                       };
    216304        codeAddress();
     
    221309});
    222310
     311
     312
     313
     314  // DECIMAL TO FRACTION
     315  //
     316  function dec2frac( valeur_decimal ) {
     317     decimal = valeur_decimal.toString() ;
     318      num = '';
     319      den = 1;
     320      dec = false;
     321
     322      // find least reduced fractional form of number
     323      for( i = 0, ix =   decimal.length  ; i < ix; i++ )
     324      {
     325      // build the denominator as we 'shift' the decimal to the right
     326      if( dec ) den *= 10;
     327
     328      // find the decimal place/ build the numberator
     329      if( decimal.charAt(i) == '.' ) dec = true;
     330      else num += decimal.charAt(i);
     331      }
     332      num = parseInt(num);
     333 
     334      // whole number, just return it
     335      if( den == 1 ) return num;
     336
     337      num2 = num;
     338      den2 = den;
     339      rem  = 1;
     340      // Euclid's Algorithm (to find the gcd)
     341      while( num2 % den2 ) {
     342      rem = num2 % den2;
     343      num2 = den2;
     344      den2 = rem;
     345      }
     346      if( den2 != den ) rem = den2;
     347      ret1 = { Numerator: (num / rem), Denominator: (den / rem) };
     348      // new Array()
     349    // ret1->Numerator =(num / rem ) ;
     350    // ret1->Denominator=(den / rem);
     351
     352      // now $rem holds the gcd of the numerator and denominator of our fraction
     353      return ret1;
     354     
     355  }
     356
     357function dec2dms(l) {
     358    sign = 1;
     359    if (l < 0) { sign = -1; }
     360    l = Math.abs(Math.round(l * 1000000.))
     361    d = Math.floor(l / 1000000) * sign;
     362    m = Math.floor(((l / 1000000) - Math.floor(l / 1000000)) * 60);
     363    s = Math.floor(((((l / 1000000) - Math.floor(l / 1000000)) * 60) - Math.floor(((l / 1000000) - Math.floor(l / 1000000)) * 60)) * 100000) * 60 / 100000;
     364    frac_s = dec2frac(s);
     365    s2 = (frac_s.Numerator / frac_s.Denominator);
     366    return { dms: d + "° " + m + "' " + s + "''",
     367        Degre:d, Minute:m,Sec:s,
     368        Numerator: frac_s.Numerator,
     369        Denominator:frac_s.Denominator};
     370}
     371
  • extensions/edit_gmaps/include/functions.php

    r8918 r9377  
    11<?php
    22
    3 function clm_get_cache_file_name()
     3function cl_meta_get_cache_file_name()
    44{
    55        global $conf;
     
    88}
    99
    10 function clm_invalidate_cache()
     10function cl_meta_invalidate_cache()
    1111{
    12         @unlink(  clm_get_cache_file_name() );
     12        @unlink(  cl_meta_get_cache_file_name() );
    1313}
    1414
    15 function clm_load_language()
     15function cl_meta_load_language()
    1616{
    1717        global $lang,$lang_info,$conf;
     
    2121}
    2222
    23 function clm_items_have_latlon($items)
     23function cl_meta_items_have_latlon($items)
    2424{
    2525  $query = '
     
    3434}
    3535
    36 function clm_make_map_picture_url($params)
     36function cl_meta_make_map_picture_url($params)
    3737{
    3838        global $conf;
     
    4343}
    4444
    45 function clm_duplicate_map_picture_url()
     45function cl_meta_duplicate_map_picture_url()
    4646{
    4747        global $conf;
     
    5252}
    5353
    54 function clm_make_map_index_url($params=array())
     54function cl_meta_make_map_index_url($params=array())
    5555{
    56         global $conf, $clm_dir;
     56        global $conf, $cl_meta_dir;
    5757        if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' )
    5858                return "";
     
    6767}
    6868
    69 function clm_duplicate_map_index_url($redefined=array(), $removed=array())
     69function cl_meta_duplicate_map_index_url($redefined=array(), $removed=array())
    7070{
    71         return clm_make_map_index_url(
     71        return cl_meta_make_map_index_url(
    7272                params_for_duplication($redefined, $removed)
    7373                );
    7474}
    7575
    76 function clm_duplicate_kml_index_url($redefined=array(), $removed=array())
     76function cl_meta_duplicate_kml_index_url($redefined=array(), $removed=array())
    7777{
    78         return clm_make_kml_index_url(
     78        return cl_meta_make_kml_index_url(
    7979                params_for_duplication($redefined, $removed)
    8080                );
    8181}
    8282
    83 function clm_make_kml_index_url($params)
     83function cl_meta_make_kml_index_url($params)
    8484{
    85         global $conf, $clm_dir;
    86         $url = get_root_url().'plugins/'.$clm_dir.'/kml.php';
     85        global $conf, $cl_meta_dir;
     86        $url = get_root_url().'plugins/'.$cl_meta_dir.'/kml.php';
    8787        if ($conf['question_mark_in_urls'])
    8888                $url .= '?';
  • extensions/edit_gmaps/main.inc.php

    r8918 r9377  
    22/*
    33Plugin Name: Edit Maps&Earth
    4 Version: 2.1.4
     4Version: auto
    55Description:  Editor for rv gmaps
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=330
     
    1717{
    1818        include_once( dirname(__FILE__) .'/include/functions.php');
    19         add_event_handler('invalidate_user_cache', 'clm_invalidate_cache' );
     19        add_event_handler('invalidate_user_cache', 'cl_meta_invalidate_cache' );
    2020        array_push($menu,
    2121                        array(                 
  • extensions/edit_gmaps/maintain.inc.php

    r8918 r9377  
    22function plugin_install()
    33{
    4 
     4  $q = '
     5ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN `alt` DOUBLE(9,6)';
     6  pwg_query($q);
    57}
    68
     
    1416{
    1517 
    16   clm_invalidate_cache();
     18  cl_meta_invalidate_cache();
    1719}
    1820
    1921function plugin_uninstall()
    2022{
     23  $q = '
     24ALTER TABLE '.IMAGES_TABLE.' DROP COLUMN `alt`';
     25  pwg_query( $q );
    2126}
    2227?>
Note: See TracChangeset for help on using the changeset viewer.