Changeset 169 for trunk/globals


Ignore:
Timestamp:
09/04/2006 02:50:13 PM (5 years ago)
Author:
cirrus
Message:

add: XML statistics
change: gmap API v2 used (custom map support is currently broken)

Location:
trunk/globals
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/globals/classes/srtm.php

    r129 r169  
    2929         
    3030        function get_elevation($lat, $lon, $round=TRUE) { 
    31         $y = $lat; 
    32         $x = $lon; 
     31                $y = $lat; 
     32                $x = $lon; 
    3333         
    34         $filename = $this->data_path.'N'.(integer)$lat.'E'.((integer)$lon<100?'0'.(integer)$lon:(integer)$lon).'.hgt'; 
     34                $filename = $this->data_path.'N'.(integer)$lat.'E'.((integer)$lon<100?'0'.(integer)$lon:(integer)$lon).'.hgt'; 
    3535         
    36         if ($lat == '' || $lon == '' || !file_exists($filename)) return FALSE; 
     36                if ($lat == '' || $lon == '' || !file_exists($filename)) 
     37                        return FALSE; 
    3738         
    38         $file = fopen($filename, 'r'); 
    39         $offset = ( (integer)(($x - (integer)$x) * 1200) * 2 + (1200 - (integer)(($y - (integer)$y) * 1200)) * 2402 ); 
    40         fseek($file, $offset); 
    41         $h1 = bytes2int(strrev(fread($file, 2))); 
    42         $h2 = bytes2int(strrev(fread($file, 2))); 
    43         fseek($file, $offset-2402); 
    44         $h3 = bytes2int(strrev(fread($file, 2))); 
    45         $h4 = bytes2int(strrev(fread($file, 2))); 
    46         fclose($file); 
     39                $file = fopen($filename, 'r'); 
     40                $offset = ( (integer)(($x - (integer)$x) * 1200) * 2 + (1200 - (integer)(($y - (integer)$y) * 1200)) * 2402 ); 
     41                fseek($file, $offset); 
     42                $h1 = bytes2int(strrev(fread($file, 2))); 
     43                $h2 = bytes2int(strrev(fread($file, 2))); 
     44                fseek($file, $offset-2402); 
     45                $h3 = bytes2int(strrev(fread($file, 2))); 
     46                $h4 = bytes2int(strrev(fread($file, 2))); 
     47                fclose($file); 
    4748         
    48         $m = max($h1, $h2, $h3, $h4); 
    49         for($i=1;$i<=4;$i++) { 
    50                 $c = 'h'.$i; 
    51                 if ($$c == -32768) $$c = $m; 
     49                $m = max($h1, $h2, $h3, $h4); 
     50                for($i=1;$i<=4;$i++) { 
     51                        $c = 'h'.$i; 
     52                        if ($$c == -32768) 
     53                                $$c = $m; 
     54                } 
     55         
     56                $fx = ($lon - (integer)($lon * 1200) / 1200) * 1200; 
     57                $fy = ($lat - (integer)($lat * 1200) / 1200) * 1200; 
     58         
     59                // normalizing data 
     60                $elevation = ($h1 * (1 - $fx) + $h2 * $fx) * (1 - $fy) + ($h3 * (1 - $fx) + $h4 * $fx) * $fy; 
     61                if ($round) 
     62                        $elevation = round($elevation); 
     63                return $elevation; 
    5264        } 
    53          
    54         $fx = ($lon - (integer)($lon * 1200) / 1200) * 1200; 
    55         $fy = ($lat - (integer)($lat * 1200) / 1200) * 1200; 
    56          
    57         // normalizing data 
    58         $elevation = ($h1 * (1 - $fx) + $h2 * $fx) * (1 - $fy) + ($h3 * (1 - $fx) + $h4 * $fx) * $fy; 
    59         if ($round) $elevation = round($elevation); 
    60         return $elevation; 
    61         } 
    62          
     65 
    6366} 
    6467 
  • trunk/globals/functions.php

    r166 r169  
    9696        global $qs_vars; 
    9797        $o = array(); 
     98        if(get('show_map') == "no") $o = array_merge($o,array("show_map" => "no")); 
    9899        if ($cur_qs == TRUE) { 
    99100                parse_str(get_qs(), $qs); 
     
    344345        if ($gmap_key == '') return FALSE; 
    345346 
    346         $main->html->head->add_script("text/javascript", "http://".$vars['gmap']['server']."/maps?file=api&v=1&key=".$gmap_key); 
     347        $main->html->head->add_script("text/javascript", "http://".$vars['gmap']['server']."/maps?file=api&v=2&key=".$gmap_key); 
    347348        $main->html->head->add_script("text/javascript", $javascript); 
    348349        $main->html->head->add_extra( 
Note: See TracChangeset for help on using the changeset viewer.