Ignore:
Timestamp:
Sep 10, 2011, 5:02:19 PM (13 years ago)
Author:
cljosse
Message:

[extensions] edit_gmaps add functions

File:
1 edited

Legend:

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

    r9412 r12126  
    11<?php
    2   //
    3   // DECIMAL TO FRACTION
    4   //
     2
     3function base_to_meta($image){
     4      $info_meta['lat']=$image['lat'];
     5      $info_meta['lon']=$image['lon'];
     6      $info_meta['alt']=$image['alt'];
     7      //===========================================================================
     8      $info_meta['latRef'] = ($image['lat']<0)? 'S' : "N" ;
     9      $info_meta['GPSLatitudeRef'] = ($image['lat']<0)? 'S' : "N" ;
     10      $p1=dec2dms($image['lat']);
     11 
     12      $info_meta['latDMS']=$p1[0]['Numerator']  . "/" .
     13            $p1[0]['Denominator'] ." ".
     14            $p1[1]['Numerator'] . "/" .
     15            $p1[1]['Denominator'] ." ".
     16            $p1[2]['Numerator'] . "/" .
     17            $p1[2]['Denominator'] ;
     18
     19      $info_meta['GPSLatitude']=array(
     20            $p1[0]['Numerator']  . "/" .
     21            $p1[0]['Denominator'] ,
     22            $p1[1]['Numerator'] . "/" .
     23            $p1[1]['Denominator'] ,
     24            $p1[2]['Numerator'] . "/" .
     25            $p1[2]['Denominator']
     26            );
     27
     28      //===========================================================================
     29      $info_meta['GPSLongitudeRef']  = ($image['lon']<0)? 'W' : "E" ;
     30      $info_meta['lonRef']  = ($image['lon']<0)? 'W' : "E" ;
     31      $p1=dec2dms($image['lon']);
     32      $info_meta['lonDMS']=$p1[0]['Numerator']  . "/" .
     33            $p1[0]['Denominator'] ." ".
     34            $p1[1]['Numerator'] . "/" .
     35            $p1[1]['Denominator'] ." ".
     36            $p1[2]['Numerator'] . "/" .
     37            $p1[2]['Denominator'] ;
     38      $info_meta['GPSLongitude']=array(
     39            $p1[0]['Numerator']  . "/" .
     40            $p1[0]['Denominator'] ,
     41            $p1[1]['Numerator'] . "/" .
     42            $p1[1]['Denominator'] ,
     43            $p1[2]['Numerator'] . "/" .
     44            $p1[2]['Denominator']
     45            );
     46      //===========================================================================
     47        $info_meta['GPSAltitudeRef'] = "0";
     48        $p1= round( $image['alt'] * 5000000000 );
     49        $info_meta['GPSAltitude']= $p1.'/'."500000000000";
     50        $info_meta['altDMS']= $p1.'/'."500000000000";
     51        $info_meta['altRef']= "0";
     52  return $info_meta ;
     53}
     54
     55/**********************************
     56* DECIMAL TO FRACTION             *
     57**********************************/
    558  function dec2frac( $decimal ) {
    659    $decimal = (string)$decimal;
     
    1063
    1164    // find least reduced fractional form of number
    12     for( $i = 0, $ix = strlen( $decimal ); $i < $ix; $i++ )
    13     {
     65    for( $i = 0, $ix = strlen( $decimal ); $i < $ix; $i++ ){
    1466     // build the denominator as we 'shift' the decimal to the right
    1567     if( $dec ) $den *= 10;
     
    4294  }
    4395
    44  
     96/**********************************
     97* Decimal vers Deg Min Sec        *
     98**********************************/
    4599function dec2dms($value) {
    46100        $value= abs($value);
     
    59113        $ret[2]['Denominator']=$sec->Denominator;
    60114  $ret[3]= " Deg: " . $degrees . " Min: " . $minutes . " Sec: " . $seconds."  " ;
    61        
     115        $ret[4]= " " . $degrees . "/1 " . $minutes . "/1 " . $sec->Numerator."/".$sec->Denominator ;
    62116return( $ret);
    63117
    64118}
    65119
    66 
    67 /*
    68 //Array (
    69 [GPSLatitudeRef] => S
    70 [GPSLatitude] =>
    71 Array ( [0] => 41/1
    72 [1] => 54/1
    73 [2] => 26543/3238 )
    74 [GPSLongitudeRef] => E
    75 [GPSLongitude] => Array (
    76 [0] => 146/1
    77 [1] => 21/1
    78 [2] => 61393/1729 ) )
    79 */
    80120
    81121function toFraction($number){
     
    108148return ($denominator > 0) ? $numerator . '/' . $denominator : false;
    109149}
    110 
    111  function Parse_Fract( $f )
    112 {
     150//==============================================
     151 function Parse_Fract( $f ){
    113152  $nd = explode( '/', $f );
    114153  return $nd[0]/$nd[1];
Note: See TracChangeset for help on using the changeset viewer.