array( 'method'=>"GET", 'max_redirects'=>1 ) ); $context = stream_context_create($opts); $localImage = IPS_GetKernelDir()."\\webfront\\radar.gif"; $remoteImage = "http://alarm.meteocentrale.ch/images/map/".$area."_index.png"; $data = @file_get_contents($remoteImage, false, $context); if($data === false) { //Altes Bild laden $dateline -= 15*60; $remoteImage = "http://alarm.meteocentrale.ch/images/map/".$area."_index.png"; $data = @file_get_contents($remoteImage, false, $context); if($data === false) { return; } } if((strpos($http_response_header[0], "200") === false)) { return; } file_put_contents($localImage, $data); //Radarbild auswerten $im = ImageCreateFromPNG ($localImage); imagetruecolortopalette($im, true, 256); $halfwhite = imagecolorclosest($im, 251, 252, 251); $white = imagecolorat($im, 0, 0); imagecolorset($im, $halfwhite, 33, 51, 69); //macht weiss dunkelblau imagecolorset($im, $white, 33, 51, 69); //macht weiss dunkelblau //Stärken $regen[6] = imagecolorresolve ($im, 255, 0, 255); $regen[5] = imagecolorresolve ($im, 252, 2, 252); // violett $regen[4] = imagecolorresolve ($im, 237, 2, 4); //rot $regen[3] = imagecolorresolve ($im, 252, 182, 4); //orange $regen[2] = imagecolorresolve ($im, 252, 254, 4); //gelb $regen[1] = imagecolorresolve ($im, 252, 254, 4); //gelb //Pixel durchgehen $regenmenge = 0; for($x=$homeX-$homeRadius; $x<=$homeX+$homeRadius; $x++) { for($y=$homeY-$homeRadius; $y<=$homeY+$homeRadius; $y++) { $found = array_search(imagecolorat($im, $x, $y), $regen); if(!($found === FALSE)) { $regenmenge+=$found; } } } // Bereich zeichnen $schwarz = ImageColorAllocate ($im, 0, 0, 0); $rot = ImageColorAllocate ($im, 255, 0, 0); imagerectangle($im, $homeX-$homeRadius, $homeY-$homeRadius, $homeX+$homeRadius, $homeY+$homeRadius, $rot); imagesetpixel($im, $homeX, $homeY, $rot); imagegif($im, $localImage); imageJPEG($im, IPS_GetKernelDir()."webfront/ig/images/weather/radar.jpg"); imagedestroy($im); //Legende $unwetter = $regenmenge; if ($unwetter < 10) $uwlegende = "es ist kein Unwetter in Sicht"; if (($unwetter >10) && ($unwetter < 1610)) $uwlegende = "die Vorwarnung für ein Unwetter ist aktiv"; if (($unwetter >1610) && ($unwetter <2900)) $uwlegende = "es gibt eine Warnung für mässig starkes Unwetter"; SetValue(28350 /*[Wetter\Wetter\Variablen\Regenvorhersage]*/, $uwlegende); //aktuell http://api.wunderground.com/api/xxxxxxxxxx/geolookup/conditions/lang:DL/q/DL/SIGRISWIL.json //Vorhersage http://api.wunderground.com/api/xxxxxxxx/forecast/lang:DL/q/Switzerland/Grindelwald.json //Astro http://api.wunderground.com/api/xxxxxxxxx/astronomy/q/Switzerland/Sigriswil.json //aktuelles Wetter $json_string = file_get_contents("http://api.wunderground.com/api/$api/geolookup/conditions/lang:DL/q/DL/$ort.json"); $parsed_json = json_decode($json_string); $iconh = $parsed_json->{'current_observation'}->{'icon'}; $temp_c = $parsed_json->{'current_observation'}->{'temp_c'}; $min_temp = $parsed_json->{'current_observation'}->{'dewpoint_c'}; $humid = $parsed_json->{'current_observation'}->{'relative_humidity'}; $wind_speed = $parsed_json->{'current_observation'}->{'wind_kph'}; $wind_dir = utf8_decode($parsed_json->{'current_observation'}->{'wind_dir'}); $luftdruck = $parsed_json->{'current_observation'}->{'pressure_mb'}; $wetter = $parsed_json->{'current_observation'}->{'weather'}; $sichtweite = $parsed_json->{'current_observation'}->{'visibility_km'}; $regen = $parsed_json->{'current_observation'}->{'precip_today_metric'}; $regenstd = $parsed_json->{'current_observation'}->{'precip_1hr_metric'}; $solar = $parsed_json->{'current_observation'}->{'solarradiation'}; $uv = $parsed_json->{'current_observation'}->{'UV'}; // Vorhersage $json_fc_string = file_get_contents("http://api.wunderground.com/api/$api/forecast/lang:DL/q/Switzerland/$ort.json"); $parsed_fc_json = json_decode($json_fc_string); $prognose = $parsed_fc_json->{'forecast'}->{'simpleforecast'}->{'forecastday'}; //heute $icon0 = ($prognose[0]->icon) . "\n"; $high0 = ($prognose[0]->high->celsius) . "\n"; $low0 = ($prognose[0]->low->celsius) . "\n"; $conditions0 = utf8_decode($prognose[0]->conditions) . "\n"; $regenws0 = utf8_decode($prognose[0]->pop) . "\n"; //morgen $tag1 = ($prognose[1]->date->weekday); $icon1 = ($prognose[1]->icon) . "\n";; $high1 = ($prognose[1]->high->celsius) . "\n";; $low1 = ($prognose[1]->low->celsius) . "\n";; $conditions1 = utf8_decode($prognose[1]->conditions) . "\n"; //übermorgen $tag2 = ($prognose[2]->date->weekday); $icon2 = ($prognose[2]->icon) . "\n"; $high2 = ($prognose[2]->high->celsius) . "\n"; $low2 = ($prognose[2]->low->celsius) . "\n"; $conditions2 = utf8_decode($prognose[2]->conditions) . "\n"; //in 3 Tagen $tag3 = ($prognose[3]->date->weekday); $icon3 = ($prognose[3]->icon) . "\n"; $high3 = ($prognose[3]->high->celsius) . "\n"; $low3 = ($prognose[3]->low->celsius) . "\n"; $conditions3 = utf8_decode($prognose[3]->conditions) . "\n"; //Alarm /*$json_al_string = file_get_contents("http://api.wunderground.com/api/$api/alerts/q/zmw:00000.1.16172.json"); $parsed_al_json = json_decode($json_al_string); $alarm = $parsed_al_json->{'alerts'}; var_dump($alarm);*/ // echo "Mondbeleuchtung: $alarm\n"; // echo "Alarm: ${parsed_al_json}%\n"; //Astronomie $json_ast_string = file_get_contents("http://api.wunderground.com/api/$api/astronomy/q/Switzerland/$ort.json"); $parsed_ast_json = json_decode($json_ast_string); $mondbel = $parsed_ast_json->{'moon_phase'}->{'percentIlluminated'}; //% Mondbeleuchtung $mondage = $parsed_ast_json->{'moon_phase'}->{'ageOfMoon'}; //% Mondbeleuchtung $sunriseh = $parsed_ast_json->{'moon_phase'}->{'sunrise'}->{'hour'}; // Sonnenaufgang Stunde $sunrisem = $parsed_ast_json->{'moon_phase'}->{'sunrise'}->{'minute'}; //% Sonnenaufgang Minute $sunseth = $parsed_ast_json->{'moon_phase'}->{'sunset'}->{'hour'}; // Sonnenaufgang Stunde $sunsetm = $parsed_ast_json->{'moon_phase'}->{'sunset'}->{'minute'}; //% Sonnenaufgang Minute //Thunersee $xml = simplexml_load_file(utf8_encode("http://www.hydrodaten.admin.ch/lhg/SMS.xml")); // Messstation Thunersee $res = $xml->xpath("//MesPar[@StrNr='2093']"); $name = $res[0]->Name; //$datumZeit = $res[0]->Datum . " " . $res[0]->Zeit; $zeit = $res[0]->Zeit; $standakt = $res[0]->Wert[0]; $wert1 = $res[0]->Wert[2]; // Messstation Ringgenberg $resinterl = $xml->xpath("//MesPar[@StrNr='2457']"); $nameinterl = $resinterl[0]->Name; //$datumZeit = $res[0]->Datum . " " . $res[0]->Zeit; $zeitinterl = $resinterl[0]->Zeit; $standaktinterl = $resinterl[0]->Wert[0]; $wert1interl = $resinterl[0]->Wert[2]; // Messstation Thun $resaare = $xml->xpath("//MesPar[@StrNr='2030']"); $nameaare = $resaare[0]->Name; //$datumZeit = $res[0]->Datum . " " . $res[0]->Zeit; $zeitaare = $resaare[0]->Zeit; $standaktaare = $resaare[0]->Wert[0]; $wert1aare = $resaare[0]->Wert[2]; //Mittelwerte $tempaare1 = preg_replace("/,/", ".", $standaktaare); //$tempaare1 = round($standaktaare, 2, ',', '.'); $tempaare2 = preg_replace("/,/", ".", $standaktinterl); $tempaare = $tempaare1 + $tempaare2; $tempaare = $tempaare /100*50; $tempaare = sprintf("%.2f",$tempaare); //Ausgabe Gunten $heute = "
Aktuell
".$wetter."
Temperatur ".$temp."°C
Luftfeuchte ".$humid."
Luftdruck ".$luftdruck." HPa
Wind ".$wind_speed." Km/h
Windrichtung ".$wind_dir."
Regenmenge ".$regen." mm
Heute
Minimal ".$low1."°C
Maximal ".$high1." °C

".$tag1."
Minimal ".$low1."°C
Maximal ".$high1." °C
".$conditions1."
$tag2
Minimal ".$low2."°C
Maximal ".$high2." °C
".$conditions2."
$tag3
Minimal ".$low3."°C
Maximal ".$high3." °C
".$conditions3."
"; SetValue(30698 /*[Wetter\Wetter\Variablen\Heute und die nächsten 3 Tage]*/ , $heute); $vorhersage = "

".$uwlegende."

Thunersee

Seespiegel
letzte Messung: ".$zeit."
Seehöhe ".$standakt." M.
Differenz ".$wert1." M.

Temperatur
letzte Messung ".$zeitinterl."
Temperatur ".$tempaare." °C
Differenz ".$wert1interl." °C
Wetterprognose
".$vorhersage."
"; SetValue(23144 /*[Wetter\Wetter\Variablen\Übersicht]*/ , $vorhersage); $astro = "


Beleuchtung ".$mondbel."%
Alter ".$mondage." Tage
Neumond am ".$neumond."
Vollmond am ".$vollmond."

Aufgang ".$sunriseh.":".$sunrisem." Uhr
Untergang ".$sunseth.":".$sunsetm." Uhr

Fernsicht ".$sichtweite." Km.
Strahlung ".$uv." von max. 16
"; SetValue(46178 /*[Wetter\Wetter\Variablen\Astrologische Daten]*/ , $astro); $heutejuerg = "
Aktuell
".$wetter."
Temperatur ".$temp."°C
Luftfeuchte ".$humid."
Luftdruck ".$luftdruck." HPa
Wind ".$wind_speed." Km/h
Windrichtung ".$wind_dir."
Regenmenge ".$regenstd." mm

"; SetValue(24295 /*[Wetter\Wetter\Variablen\Wetterausgabe Juerg]*/ , $heutejuerg); SetValue(24139 /*[Wetter\Wetter\Variablen\Wetter Fumoir]*/, "$wetter, $temp °C, $humid, Regen $regenstd mm"); //Wetteranzeige Fumoir TTS_GenerateFile(44654 /*[Hinweise\TTS Player\Text To Speech]*/, "die jetztige Aussentemperatur beträgt $temp Grad. Für heute sagt das Wetter $wetter. $uwlegende. Der See ist heute $tempaare Grad warm", "/Ansagen/wetterheute.wav", 32); ?>