@@ -28,7 +28,9 @@ discard block |
||
| 28 | 28 | private $openedFiles = []; |
| 29 | 29 | |
| 30 | 30 | public function __construct($htgFilesDestination = '', $resolution = 3) { |
| 31 | - if ($htgFilesDestination == '') $htgFilesDestination = dirname(__FILE__).'/../data/'; |
|
| 31 | + if ($htgFilesDestination == '') { |
|
| 32 | + $htgFilesDestination = dirname(__FILE__).'/../data/'; |
|
| 33 | + } |
|
| 32 | 34 | $this->htgFilesDestination = $htgFilesDestination; |
| 33 | 35 | $this->resolution = $resolution; |
| 34 | 36 | switch ($resolution) { |
@@ -149,8 +151,11 @@ discard block |
||
| 149 | 151 | |
| 150 | 152 | $d = -$n1 * $a1 - $n2 * $a2 - $n3 * $a3; |
| 151 | 153 | $zN = (-$n1 * $Xn - $n2 * $Yn - $d) / $n3; |
| 152 | - if ($zN > 10000) return 0; |
|
| 153 | - else return $zN; |
|
| 154 | + if ($zN > 10000) { |
|
| 155 | + return 0; |
|
| 156 | + } else { |
|
| 157 | + return $zN; |
|
| 158 | + } |
|
| 154 | 159 | } |
| 155 | 160 | |
| 156 | 161 | private function getDeg($deg, $numPrefix) { |
@@ -189,16 +194,26 @@ discard block |
||
| 189 | 194 | $fileName = $latd.$lond.".hgt"; |
| 190 | 195 | if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName)) { |
| 191 | 196 | $Common = new Common(); |
| 192 | - if ($debug) echo 'Downloading '.$fileName.'.gz ...'; |
|
| 197 | + if ($debug) { |
|
| 198 | + echo 'Downloading '.$fileName.'.gz ...'; |
|
| 199 | + } |
|
| 193 | 200 | $Common->download('https://s3.amazonaws.com/elevation-tiles-prod/skadi/'.$latd.'/'.$fileName.'.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz'); |
| 194 | 201 | if (!file_exists($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz')) { |
| 195 | - if ($debug) echo "File '{$fileName}.gz' not exists."; |
|
| 202 | + if ($debug) { |
|
| 203 | + echo "File '{$fileName}.gz' not exists."; |
|
| 204 | + } |
|
| 196 | 205 | return false; |
| 197 | 206 | } |
| 198 | - if ($debug) echo 'Done'."\n"; |
|
| 199 | - if ($debug) echo 'Decompress '.$fileName.' ....'; |
|
| 207 | + if ($debug) { |
|
| 208 | + echo 'Done'."\n"; |
|
| 209 | + } |
|
| 210 | + if ($debug) { |
|
| 211 | + echo 'Decompress '.$fileName.' ....'; |
|
| 212 | + } |
|
| 200 | 213 | $Common->gunzip($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz',$this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName); |
| 201 | - if ($debug) echo 'Done'."\n"; |
|
| 214 | + if ($debug) { |
|
| 215 | + echo 'Done'."\n"; |
|
| 216 | + } |
|
| 202 | 217 | unlink($this->htgFilesDestination . DIRECTORY_SEPARATOR . $fileName . '.gz'); |
| 203 | 218 | } |
| 204 | 219 | return true; |