Пример #1
0
 public function wunderground()
 {
     global $LAT, $LON, $APPID_WG;
     $xml = NULL;
     $kurikaeshi = 10;
     $sleeptime = 30;
     for ($count = 0; $count < $kurikaeshi; $count++) {
         $req2 = "http://api.wunderground.com/api/" . $APPID_WG . "/conditions/lang:JP/q/" . $LAT . "," . $LON . ".xml";
         $xml = @simplexml_load_file($req2);
         if ($xml) {
             //	var_dump($xml);
             $wg = array();
             $wg["city"] = $xml->current_observation->display_location->city;
             echo "Wunderground City = " . $wg["city"] . "\n";
             $wg["temp_now2"] = round((double) (5 / 9) * ($xml->current_observation->temp_f - 32), 1);
             $wg["temp_now_f"] = $xml->current_observation->temp_f;
             $wg["humidity_now2"] = str_replace("%", "%", $xml->current_observation->relative_humidity);
             $wg["windspeed_now2"] = round(0.44704 * (double) $xml->current_observation->wind_mph, 1);
             $wg["pressure_now2"] = round((double) $xml->current_observation->pressure_in * 33.8639, 1);
             $wg["kazamuki2"] = $this->ryusWehatherWindDigree($xml->current_observation->wind_degrees);
             $wg["kazamuki_degrees"] = $xml->current_observation->wind_degrees;
             $wg["feelslike"] = round((double) (5 / 9) * ($xml->current_observation->feelslike_f - 32), 1);
             $wg["fukai"] = round((double) (0.8100000000000001 * $wg["temp_now2"] + 0.01 * $wg["humidity_now2"] * (0.99 * $wg["temp_now2"] - 14.3) + 46.3), 1);
             $wg["weather"] = $this->trans_condition($xml->current_observation->weather);
             if ($wg["weather"] == "") {
                 $owm = $this->openweathermap();
                 $wg["weather"] = $owm["description"];
             }
             $wg["icon_url"] = $xml->current_observation->icon_url;
             $wg["humidity_now2_X"] = $xml->current_observation->relative_humidity;
             $wg["windspeed_now2_X"] = $xml->current_observation->wind_mph;
             $wg["pressure_now2_X"] = $xml->current_observation->pressure_in;
             $wg["feelslike_X"] = $xml->current_observation->feelslike_f;
             if (strlen($wg["humidity_now2_X"]) == 0) {
                 $wg["humidity_now2"] = "?";
                 $wg["fukai"] = "?";
             }
             if (strlen($wg["windspeed_now2_X"]) == 0) {
                 $wg["windspeed_now2"] = "?";
             }
             if (strlen($wg["pressure_now2_X"]) == 0) {
                 $wg["pressure_now2"] = "?";
             }
             if (strlen($wg["feelslike_X"]) == 0) {
                 $wg["feelslike"] = "?";
             }
             if (strlen($wg["temp_now_f"]) == 0) {
                 $wg["temp_now2"] = "?";
                 $wg["fukai"] = "?";
             }
             if (strlen($wg["kazamuki2"]) == 0) {
                 $wg["kazamuki2"] = "?";
             }
             if (strlen($wg["weather"]) == 0) {
                 $wg["weather"] = "?";
             }
             $filename = strrchr($wg["icon_url"], "/");
             $filename = substr($filename, 1);
             $wg_icon = str_replace('nt_', '', $filename);
             if ($wg_icon == ".gif") {
                 $wg["icon_url"] = "http://linuxparadise.moe.hm/wp-content/uploads/2016/10/question_blue.jpg";
                 $wg["icon_url"] = NULL;
                 return $wg;
             }
             $SunMoon = new Moon_Class();
             $Sun = $SunMoon->SunHatena();
             if (!$Sun) {
                 $wg_icon = "nt_" . $wg_icon;
             }
             $wg["icon_url"] = $this->trans_weather_icon_7("http://icons.wxug.com/i/c/k/" . $wg_icon);
             return $wg;
         } else {
             sleep($sleeptime);
         }
     }
     return NULL;
 }