Changeset 169 for trunk/globals
- Timestamp:
- 09/04/2006 02:50:13 PM (5 years ago)
- Location:
- trunk/globals
- Files:
-
- 2 edited
-
classes/srtm.php (modified) (1 diff)
-
functions.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/globals/classes/srtm.php
r129 r169 29 29 30 30 function get_elevation($lat, $lon, $round=TRUE) { 31 $y = $lat;32 $x = $lon;31 $y = $lat; 32 $x = $lon; 33 33 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'; 35 35 36 if ($lat == '' || $lon == '' || !file_exists($filename)) return FALSE; 36 if ($lat == '' || $lon == '' || !file_exists($filename)) 37 return FALSE; 37 38 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); 47 48 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; 52 64 } 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 63 66 } 64 67 -
trunk/globals/functions.php
r166 r169 96 96 global $qs_vars; 97 97 $o = array(); 98 if(get('show_map') == "no") $o = array_merge($o,array("show_map" => "no")); 98 99 if ($cur_qs == TRUE) { 99 100 parse_str(get_qs(), $qs); … … 344 345 if ($gmap_key == '') return FALSE; 345 346 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); 347 348 $main->html->head->add_script("text/javascript", $javascript); 348 349 $main->html->head->add_extra(
Note: See TracChangeset
for help on using the changeset viewer.
