Blog Hoch
Mar 2020·1 tup leghDe'wI' ghItlhta'

NASA Hoch'ap De' legh

#hgt#nasa#srtm

NASA Hoch'ap De' legh snippet mach. De' naDev tu'lu': https://lpdaac.usgs.gov/products/srtmgl3v003/

script server Daq load. HTTP server meta file ghItlh chaw' ghaj. wa'DIch Qu' meta file chenmoH, legh Dun 'ej tlhoy' render vaD. meta file Daq Hoch'ap mach 'ej Hoch'ap tIn Dung. visualization Dun yIchoH. color Dun real vaD ideas ghaj, srtm@devdave.de Daq ghItlh yIngu' :-) yItlhIch.

<?php
$filename = 'N49E008.hgt';
$gd = imagecreatetruecolor(1201, 1201);
header('Content-Type: image/png');
$minRendered = $maxRendered = 0;
if (file_exists($filename . ".meta")) {
  $createMeta = false;
  list($minH, $maxH) = explode(";", file_get_contents($filename . ".meta"));
} else {
  $createMeta = true;
  $minH = 0;
  $maxH = 2000;
}
$r = $g = $b = 0;
$range = 255 / (($maxH - $minH) / 3);
for ($i = $minH; $i < $maxH; $i++) {
  switch (0) {
    case $i % 3: $r += $range;
    case $i % 2: $g += $range;
    case $i % 1: $b += $range;
  }
  $color[$i] = imagecolorallocate($gd, $r, $g, $b);
}
$fh = fopen($filename, 'rb');
for ($y = 0; $y < 1201; $y++)
for ($x = 0; $x < 1201; $x++) {
  $h = unpack("s", strrev(fread($fh, 2)))[1];
  if ($h == "-32768") continue;
  if ($createMeta) {
    if ($h < $minRendered) $minRendered = $h;
    if ($h > $maxRendered) $maxRendered = $h;
  }
  imagesetpixel($gd, $x, $y, $color[$h]);
}
fclose($fh);
imagepng($gd);
if ($createMeta) file_put_contents($filename . ".meta", $minRendered . ";" . $maxRendered);
?>
chu'Simultanschachqanyoutube-dl: MP3 nom download