@@ -63,12 +63,16 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | public function openweathermap($latitude,$longitude) { |
| 65 | 65 | global $globalOpenWeatherMapKey; |
| 66 | - if ($globalOpenWeatherMapKey == '') return array(); |
|
| 66 | + if ($globalOpenWeatherMapKey == '') { |
|
| 67 | + return array(); |
|
| 68 | + } |
|
| 67 | 69 | $Common = new Common(); |
| 68 | 70 | $url = 'http://api.openweathermap.org/data/2.5/weather?lat='.$latitude.'&lon='.$longitude.'&units=metric&appid='.$globalOpenWeatherMapKey; |
| 69 | 71 | //echo $url."\n"; |
| 70 | 72 | $weatherdata = json_decode($Common->getData($url),true); |
| 71 | - if (!isset($weatherdata['main']['temp']) || !isset($weatherdata['weather'][0]['id'])) return array(); |
|
| 73 | + if (!isset($weatherdata['main']['temp']) || !isset($weatherdata['weather'][0]['id'])) { |
|
| 74 | + return array(); |
|
| 75 | + } |
|
| 72 | 76 | $dew = $weatherdata['main']['temp'] - ((100-$weatherdata['main']['humidity'])/5); |
| 73 | 77 | $cumulus_base = 122.0 * ($weatherdata['main']['temp'] - $dew); |
| 74 | 78 | $stratus_base = 100.0 * (100.0 * $weatherdata['main']['humidity'])*0.3048; |
@@ -104,7 +108,9 @@ discard block |
||
| 104 | 108 | |
| 105 | 109 | public function nomad_wind($hour = '') { |
| 106 | 110 | global $globalWindsPath; |
| 107 | - if ($hour == '') $hour = date('G'); |
|
| 111 | + if ($hour == '') { |
|
| 112 | + $hour = date('G'); |
|
| 113 | + } |
|
| 108 | 114 | if (isset($globalWindsPath) && $globalWindsPath != '') { |
| 109 | 115 | $grib2json = $globalWindsPath['grib2json']; |
| 110 | 116 | $windpathsrc = $globalWindsPath['source']; |
@@ -142,7 +148,9 @@ discard block |
||
| 142 | 148 | system($grib2json.' --data --output '.$windpathdest.' --names --compact '.$windpathsrc); |
| 143 | 149 | } else { |
| 144 | 150 | // if not try previous run |
| 145 | - if ($hour == date('G')) $this->nomad_wind(date('G')-6); |
|
| 151 | + if ($hour == date('G')) { |
|
| 152 | + $this->nomad_wind(date('G')-6); |
|
| 153 | + } |
|
| 146 | 154 | } |
| 147 | 155 | } |
| 148 | 156 | |
@@ -11,7 +11,9 @@ discard block |
||
| 11 | 11 | header('Content-Type: text/javascript'); |
| 12 | 12 | $latitude = filter_input(INPUT_GET,'latitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 13 | 13 | $longitude = filter_input(INPUT_GET,'longitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 14 | -if ($latitude == '' || $longitude == '') return ''; |
|
| 14 | +if ($latitude == '' || $longitude == '') { |
|
| 15 | + return ''; |
|
| 16 | +} |
|
| 15 | 17 | //echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
| 16 | 18 | $airports = $Spotter->closestAirports($latitude,$longitude,300); |
| 17 | 19 | //print_r($airports); |
@@ -20,7 +22,9 @@ discard block |
||
| 20 | 22 | $i = 0; |
| 21 | 23 | $ew = true; |
| 22 | 24 | $dtf = false; |
| 23 | -if (empty($airports)) $ew = false; |
|
| 25 | +if (empty($airports)) { |
|
| 26 | + $ew = false; |
|
| 27 | +} |
|
| 24 | 28 | while($ew) { |
| 25 | 29 | $met = $METAR->getMETAR($airports[$i]['icao']); |
| 26 | 30 | //print_r($met); |
@@ -43,8 +47,12 @@ discard block |
||
| 43 | 47 | } |
| 44 | 48 | } |
| 45 | 49 | $i++; |
| 46 | - if ($i >= count($airports)) $ew = false; |
|
| 50 | + if ($i >= count($airports)) { |
|
| 51 | + $ew = false; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | +if ($dtf === false) { |
|
| 55 | + echo json_encode($Weather->openweathermap($latitude,$longitude)); |
|
| 47 | 56 | } |
| 48 | -if ($dtf === false) echo json_encode($Weather->openweathermap($latitude,$longitude)); |
|
| 49 | 57 | |
| 50 | 58 | ?> |
| 51 | 59 | \ No newline at end of file |