id_city; $Cities[$count][1] = $row->longitude; $Cities[$count][2] = $row->latitude; $Cities[$count][3] = $row->altitude; $Cities[$count][4] = $row->id_wmo; $Cities[$count][5] = $row->name; $Cities[$count][6] = $row->country; $Cities[$count][7] = $row->id_image; $count++; // echo "$row->id_city\t$row->longitude\t$row->latitude\t$row->altitude\n"; // Test } mysql_free_result($rs_cities); } function GetTime($year,$month,$day) { global $Times; // $time=time()+60*60*24; // $time=time(); // $datetime=getdate($time); // $year=$datetime["year"]; // $month=$datetime["mon"]; // $day=$datetime["mday"]; $sdate=sprintf("%04d-%02d-%02d",$year,$month,$day); echo "$sdate\n"; $hour=12; $shour=sprintf("%02d:00:00",$hour); $sql="SELECT date FROM time WHERE date>='$sdate' AND hour='$shour' order by date"; //Test // echo "$sql\n"; $rs_time = query($sql); $count=0; while ($row = mysql_fetch_object($rs_time)) { $sdate=$row->date; $Times[$count]["year"]=substr($sdate,0,4); $Times[$count]["month"]=substr($sdate,5,2); $Times[$count]["day"]=substr($sdate,8,2); $count++; echo "$sdate\n"; //Test } mysql_free_result($rs_time); } function ConvertWeatherTypeToSymbol($wt) { $symbol=0; switch ($wt) { case 1: $symbol=0; break; case 2: $symbol=2; break; case 3: $symbol=3; break; case 4: $symbol=8; break; case 5: $symbol=5; break; case 6: $symbol=10; break; case 7: $symbol=3; break; case 8: $symbol=7; break; case 9: $symbol=6; break; case 10: $symbol=12; break; case 11: $symbol=11; break; case 12: $symbol=14; break; } // return $symbol; //if ($wt==0) $wt=1; return $wt; } function LoadDataModelHourly($model,$city,$year,$month,$day,$hour) { global $weatherdata; $sdate=sprintf("%04d-%02d-%02d",$year,$month,$day); $shour=sprintf("%02d:00:00",$hour); $sql="SELECT id_weather_type, temp, pressure, windspeed, winddir, prec, id_prec_type, humid, "; $sql.="clouds_high, clouds_mid, clouds_low, cko "; $sql.="FROM hourly_forecasts hs, time t "; $sql.="WHERE hs.id_forecasttime=t.id_time AND t.date='$sdate' AND t.hour='$shour' AND id_city=$city AND model='$model'"; $rs_weather = query($sql); if ($row = mysql_fetch_object($rs_weather)) { if (isset($row->id_weather_type)) $weatherdata[0]=ConvertWeatherTypeToSymbol($row->id_weather_type); if (isset($row->temp)) $weatherdata[2]=$row->temp; if (isset($row->pressure)) $weatherdata[3]=$row->pressure; if (isset($row->windspeed)) $weatherdata[5]=$row->windspeed; if (isset($row->winddir)) $weatherdata[6]=$row->winddir; if (isset($row->prec)) $weatherdata[9]=$row->prec; if (isset($row->id_prec_type)) $weatherdata[10]=$row->id_prec_type; if (isset($row->humid)) $weatherdata[11]=$row->humid; if (isset($row->clouds_high)) $weatherdata[12]=$row->clouds_high; if (isset($row->clouds_mid)) $weatherdata[13]=$row->clouds_mid; if (isset($row->clouds_low)) $weatherdata[14]=$row->clouds_low; if (isset($row->cko)) $weatherdata[15]=$row->cko; } mysql_free_result($rs_weather); } function LoadDataHourly($city,$year,$month,$day,$hour) { global $weatherdata; $sdate=sprintf("%04d-%02d-%02d",$year,$month,$day); $shour=sprintf("%02d:00:00",$hour); $sql="SELECT id_weather_type, temp, pressure, windspeed, winddir, prec, id_prec_type, humid, "; $sql.="clouds_high, clouds_mid, clouds_low, cko "; $sql.="FROM hourly_subjective_cg hs, time t "; $sql.="WHERE hs.id_forecasttime=t.id_time AND t.date='$sdate' AND t.hour='$shour' AND id_city=$city "; $rs_weather = query($sql); if ($row = mysql_fetch_object($rs_weather)) { if (isset($row->id_weather_type)) $weatherdata[0]=ConvertWeatherTypeToSymbol($row->id_weather_type); if (isset($row->temp)) $weatherdata[2]=$row->temp; if (isset($row->pressure)) $weatherdata[3]=$row->pressure; if (isset($row->windspeed)) $weatherdata[5]=$row->windspeed; if (isset($row->winddir)) $weatherdata[6]=$row->winddir; if (isset($row->prec)) $weatherdata[9]=$row->prec; if (isset($row->id_prec_type)) $weatherdata[10]=$row->id_prec_type; if (isset($row->humid)) $weatherdata[11]=$row->humid; if (isset($row->clouds_high)) $weatherdata[12]=$row->clouds_high; if (isset($row->clouds_mid)) $weatherdata[13]=$row->clouds_mid; if (isset($row->clouds_low)) $weatherdata[14]=$row->clouds_low; if (isset($row->cko)) $weatherdata[15]=$row->cko; mysql_free_result($rs_weather); } } function LoadDataModel($model,$city,$year,$month,$day) { global $weatherdata; $sdate=sprintf("%04d-%02d-%02d",$year,$month,$day); $hour=12; $shour=sprintf("%02d:00:00",$hour); $sql="SELECT id_weather_type, temp_min, temp_max, pressure, pressure_trend, "; $sql.="windspeed, winddir, prec, id_prec_type, humid, clouds_high, clouds_mid, clouds_low, cko "; $sql.="FROM daily_forecasts ds, time t "; $sql.="WHERE ds.id_forecasttime=t.id_time AND t.date='$sdate' AND t.hour='$shour' AND id_city=$city AND model='$model'"; // echo "\n\n$sql\n\n"; $rs_weather = query($sql); if ($row = mysql_fetch_object($rs_weather)) { if (isset($row->id_weather_type)) $weatherdata[0]=ConvertWeatherTypeToSymbol($row->id_weather_type); if (isset($row->temp_min)) $weatherdata[1]=$row->temp_min; if (isset($row->temp_max)) $weatherdata[2]=$row->temp_max; if (isset($row->pressure)) $weatherdata[3]=$row->pressure; if (isset($row->pressure_trend)) $weatherdata[4]=$row->pressure_trend; if (isset($row->windspeed)) $weatherdata[5]=$row->windspeed; if (isset($row->winddir)) $weatherdata[6]=$row->winddir; if (isset($row->windspeed_trend)) $weatherdata[7]=$row->windspeed_trend; if (isset($row->winddir_trend)) $weatherdata[8]=$row->winddir_trend; if (isset($row->prec)) $weatherdata[9]=$row->prec; if (isset($row->id_prec_type)) $weatherdata[10]=$row->id_prec_type; if (isset($row->humid)) $weatherdata[11]=$row->humid; if (isset($row->clouds_high)) $weatherdata[12]=$row->clouds_high; if (isset($row->clouds_mid)) $weatherdata[13]=$row->clouds_mid; if (isset($row->clouds_low)) $weatherdata[14]=$row->clouds_low; if (isset($row->cko)) $weatherdata[15]=$row->cko; // echo "$city $sdate "; //Test // for ($k=0;$k<=15;$k++) echo "$weatherdata[$k] "; // echo "\n"; } mysql_free_result($rs_weather); } function LoadDataBio($city,$year,$month,$day) { global $weatherdata; $sdate=sprintf("%04d-%02d-%02d",$year,$month,$day); $hour=12; $shour=sprintf("%02d:00:00",$hour); $sql="SELECT symbol, quality+100 quality, description "; $sql.="FROM daily_bio ds, time t "; $sql.="WHERE ds.id_forecasttime=t.id_time AND t.date='$sdate' AND t.hour='$shour' AND id_city=$city"; $rs_weather = query($sql); if ($row = mysql_fetch_object($rs_weather)) { if (isset($row->quality)) $weatherdata[17]=$row->quality; if (isset($row->description)) $weatherdata[18]=$row->description; } mysql_free_result($rs_weather); } function LoadDataWarning($city,$year,$month,$day) { global $weatherdata; $sdate=sprintf("%04d-%02d-%02d",$year,$month,$day); $hour=12; $shour=sprintf("%02d:00:00",$hour); $sql="SELECT symbol+200 symbol, description "; $sql.="FROM daily_warning ds, time t "; $sql.="WHERE ds.id_forecasttime=t.id_time AND t.date='$sdate' AND t.hour='$shour' AND id_city=$city"; $rs_weather = query($sql); if ($row = mysql_fetch_object($rs_weather)) { if (isset($row->symbol)) $weatherdata[19]=$row->symbol; if (isset($row->description)) $weatherdata[20]=$row->description; } mysql_free_result($rs_weather); } function LoadData($city,$year,$month,$day) { global $weatherdata; $sdate=sprintf("%04d-%02d-%02d",$year,$month,$day); $hour=12; $shour=sprintf("%02d:00:00",$hour); $sql="SELECT id_weather_type, temp_min, temp_max, pressure, pressure_trend, "; $sql.="windspeed, winddir, prec, id_prec_type, humid, clouds_high, clouds_mid, clouds_low, cko, temp_water, waves+0 waves "; $sql.="FROM daily_subjective_cg ds, time t "; $sql.="WHERE ds.id_forecasttime=t.id_time AND t.date='$sdate' AND t.hour='$shour' AND id_city=$city"; // echo "$sql\n"; $rs_weather = query($sql); if ($row = mysql_fetch_object($rs_weather)) { if (isset($row->id_weather_type) && ($row->id_weather_type>0)) $weatherdata[0]=ConvertWeatherTypeToSymbol($row->id_weather_type); if (isset($row->temp_min)) $weatherdata[1]=$row->temp_min; if (isset($row->temp_max)) $weatherdata[2]=$row->temp_max; if (isset($row->pressure)) $weatherdata[3]=$row->pressure; if (isset($row->pressure_trend)) $weatherdata[4]=$row->pressure_trend; if (isset($row->windspeed)) $weatherdata[5]=$row->windspeed; if (isset($row->winddir)) $weatherdata[6]=$row->winddir; if (isset($row->windspeed_trend)) $weatherdata[7]=$row->windspeed_trend; if (isset($row->winddir_trend)) $weatherdata[8]=$row->winddir_trend; if (isset($row->prec)) $weatherdata[9]=$row->prec; if (isset($row->id_prec_type)) $weatherdata[10]=$row->id_prec_type; if (isset($row->humid)) $weatherdata[11]=$row->humid; if (isset($row->clouds_high)) $weatherdata[12]=$row->clouds_high; if (isset($row->clouds_mid)) $weatherdata[13]=$row->clouds_mid; if (isset($row->clouds_low)) $weatherdata[14]=$row->clouds_low; if (isset($row->cko)) $weatherdata[15]=$row->cko; if (isset($row->temp_water)) $weatherdata[21]=$row->temp_water; if (isset($row->waves)) $weatherdata[22]=$row->waves; // echo "$city $sdate "; //Test // for ($k=0;$k<=15;$k++) echo "$weatherdata[$k] "; // echo "\n"; } mysql_free_result($rs_weather); // SetWeatherData(); } function LoadLastOBS($idclient,$id_city,$wmo,&$year,&$month,&$day,&$hour,&$minute) { global $weatherdata; $sdate=sprintf("%04d-%02d-%02d",$year,$month,$day); $shour=sprintf("%02d:00:00",$hour); $sql="select i.sdate, i.stime, sc.id_image, c.id_city, c.id_wmo, d.sentence, i.sdate, i.stime, d2.sentence wt, i.id_weather_type wt, i.temp, i.ws, i.wd, i.p pmsl, i.rh "; $sql.=" from sic sc, interweather i, weather_types wt, cities c, dictionary d, dictionary d2 "; $sql.=" where c.id_wmo='$wmo' AND sc.id_client=$idclient and sc.id_city=c.id_city and d2.id_language=2 and d2.id_sentence=id_sentence_weather_type and "; $sql.=" (i.id_weather_type=wt.id_weather_type or (i.id_weather_type is null and wt.id_weather_type=0)) "; $sql.=" and i.id_city=c.id_city and c.id_sentence_city=d.id_sentence and d.id_language=2 "; $rs_weather = query($sql); $found=false; if ($row = mysql_fetch_object($rs_weather)) { $dt=MakeLocalDateTime($row->sdate,$row->stime); if (isset($row->sdate)) // 2010-04-25 { // yyyy-mm-dd //$sdate=$dt[0]; $sdate=$row->sdate; $year=substr($sdate,0,4); $month=substr($sdate,5,2); $day=substr($sdate,8,2); } if (isset($row->stime)) // hh:mm:ss { //$stime=$dt[1]; $stime=$row->stime; $hour=substr($stime,0,2); $minute=substr($stime,3,2); } if (isset($row->temp)) $weatherdata[1]=round($row->temp); if (isset($row->temp)) $weatherdata[2]=round($row->temp); if (isset($row->pmsl) && ($row->pmsl>0)) $weatherdata[3]=$row->pmsl; if (isset($row->ws) && ($row->ws>=0) && ($row->ws<300)) $weatherdata[5]=$row->ws; if (isset($row->wd) && ($row->wd>=0) && ($row->wd<=360)) $weatherdata[6]=$row->wd; if (isset($row->rh) && ($row->rh>0) && ($row->rh<=100)) $weatherdata[11]=$row->rh; if (isset($row->wt)) $wt=$row->wt; if (isset($wt)) $weatherdata[0]=ConvertWeatherTypeToSymbol($wt); mysql_free_result($rs_weather); $found=true; } return $found; } function LoadOBS($id_city,$wmo,&$year,&$month,&$day,&$hour,&$minute) { global $weatherdata; $sdate=sprintf("%04d-%02d-%02d",$year,$month,$day); $shour=sprintf("%02d:00:00",$hour); $sql="select sdate, stime, id_wmo, weather_type, temp, rh, ws, wd, pmsl, snow_cover, clouds, ccl, ccm, cch, v "; $sql.="from meteos_synop.synops s, meteos_synop.weather w "; $sql.="where sdate='$sdate' and stime='$shour' and w.id_wmo='$wmo' and s.id_synop=w.id_synop "; $rs_weather = query($sql); $found=false; if ($row = mysql_fetch_object($rs_weather)) { echo "test $row->sdate,$row->stime\t"; $dt=MakeLocalDateTime($row->sdate,$row->stime); if (isset($row->sdate)) // 2010-04-25 { // yyyy-mm-dd // 0123 56 89 //$sdate=$dt[0]; $sdate=$row->sdate; $year=substr($sdate,0,4); $month=substr($sdate,5,2); $day=substr($sdate,8,2); } if (isset($row->stime)) // hh:mm:ss { // hh:mm:ss // 01 34 67 $stime=$dt[1]; $stime=$row->stime; $hour=substr($stime,0,2); // Izmeniti doraditi prema UTC-u $minute=substr($stime,3,2); } echo "$sdate $stime\n"; if (isset($row->temp)) $weatherdata[1]=round($row->temp); if (isset($row->temp)) $weatherdata[2]=round($row->temp); if (isset($row->pmsl) && ($row->pmsl>0)) $weatherdata[3]=$row->pmsl; if (isset($row->ws) && ($row->ws>=0) && ($row->ws<300)) $weatherdata[5]=$row->ws; if (isset($row->wd) && ($row->wd>=0) && ($row->wd<=360)) $weatherdata[6]=$row->wd; if (isset($row->rh) && ($row->rh>0) && ($row->rh<=100)) $weatherdata[11]=$row->rh; $wt=WeatherTypeFromSynop($row->weather_type,$row->temp,$row->clouds,$row->ccl,$row->ccm,$row->cch,$row->v); // if (isset($row->wt)) $wt=$row->wt; if (isset($wt)) $weatherdata[0]=ConvertWeatherTypeToSymbol($wt); // if (isset($row->snow_cover) && ($row->snow_cover>0)) $weatherdata[16]=$row->snow_cover; mysql_free_result($rs_weather); $found=true; } return $found; } //function InsertWeatherForCities($filename); function InsertWeatherForCities($year,$month,$day,$hour) { global $fp; global $fpobs; global $Cities; global $Times; global $weatherdata; global $wttocg; global $swd; global $sww; $firstcountry=true; $n=count($Cities); $nTime=count($Times); // $n=2; $oldcountry=""; $sdata=sprintf("\n",'"','"','"','"'); fwrite($fp,$sdata); fwrite($fpobs,$sdata); fwrite($fp,"\n"); fwrite($fpobs,"\n"); $PGcount=0; for ($i=0; $i<$n; $i++) { $city=$Cities[$i][0]; $wmo=$Cities[$i][4]; $country=$Cities[$i][6]; // if (strcmp($oldcountry,$country)!=0) // { // if ($firstcountry) $firstcountry=false; // else { fwrite($fp,"\t\n"); fwrite($fpobs,"\t\n"); } // $sdata=sprintf("\t\n",'"',$country,'"'); fwrite($fp,$sdata); fwrite($fpobs,$sdata); // } // $sdata=sprintf("\t\t\t%3.2f\n",$Cities[$i][2]); fwrite($fp,$sdata); fwrite($fpobs,$sdata); // $sdata=sprintf("\t\t\t%3.2f\n",$Cities[$i][1]); fwrite($fp,$sdata); fwrite($fpobs,$sdata); // $sdata=sprintf("\t\t\t%d\n",$Cities[$i][3]); fwrite($fp,$sdata); fwrite($fpobs,$sdata); // fwrite($fp,"\t\t\t\n"); fwrite($fpobs,"\t\t\t\n"); // $hs=0; // for ($hs=6; $hs<=18; $hs++) // { // ClearWeatherData(); //// $datetime=getdate(gmtime()-$hs*60*60); // $datetime=getdate(time()); // $year=$datetime["year"]; // $month=$datetime["mon"]; // $day=$datetime["mday"]; //// $hour=$datetime["hours"]; // $hour=$hs; // $minute=0; //// echo "$year-$month-$day $hour\n"; // if (LoadOBS($city,$wmo,$year,$month,$day,$hour,$minute)) // { // fwrite($fp,"\t\t\t\t\n"); fwrite($fpobs,"\t\t\t\t\n"); //// $sdata=sprintf("\t\t\t\t\tOBS\n"); fwrite($fp,$sdata); // $sdata=sprintf("\t\t\t\t\t%04d%02d%02d%02d%02d00\n",$year,$month,$day,$hour,$minute); fwrite($fp,$sdata); fwrite($fpobs,$sdata); // if (isset($weatherdata[2])) { $sdata=sprintf("\t\t\t\t\t%d\n",$weatherdata[2]); fwrite($fp,$sdata); fwrite($fpobs,$sdata); } // if (isset($weatherdata[3])) { $sdata=sprintf("\t\t\t\t\t%d\n",$weatherdata[3]); fwrite($fp,$sdata); fwrite($fpobs,$sdata); } // if (isset($weatherdata[5])) { $sdata=sprintf("\t\t\t\t\t%d\n",$weatherdata[5]); fwrite($fp,$sdata); fwrite($fpobs,$sdata); } // if (isset($weatherdata[6])) { $sdata=sprintf("\t\t\t\t\t%d\n",$weatherdata[6]); fwrite($fp,$sdata); fwrite($fpobs,$sdata); } // if (isset($weatherdata[0])) { $sdata=sprintf("\t\t\t\t\t%d\n",$weatherdata[0]); fwrite($fp,$sdata); fwrite($fpobs,$sdata); } // if (isset($weatherdata[11])) { $sdata=sprintf("\t\t\t\t\t%d\n",$weatherdata[11]); fwrite($fp,$sdata); fwrite($fpobs,$sdata); } // if (isset($weatherdata[16])) { $sdata=sprintf("\t\t\t\t\t%d\n",$weatherdata[16]); fwrite($fp,$sdata); fwrite($fpobs,$sdata); } // fwrite($fp,"\t\t\t\t\n"); fwrite($fpobs,"\t\t\t\t\n"); // } // } // fwrite($fp,"\t\t\t\n"); fwrite($fpobs,"\t\t\t\n"); // fwrite($fp,"\t\t\t\n"); $nTimeCity = $Cities[$i][7]; $nTimeCity = $nTimeCity<=$nTime ? $nTimeCity : $nTime; for ($iTime=0; $iTime<$nTimeCity; $iTime++) { ClearWeatherData(); $year=$Times[$iTime]["year"]; $month=$Times[$iTime]["month"]; $day=$Times[$iTime]["day"]; $hour=12; //LoadDataModel("eta",$city,$year,$month,$day); LoadData($city,$year,$month,$day); //LoadDataBio($city,$year,$month,$day); //LoadDataWarning($city,$year,$month,$day); if ($Cities[$i][4]=='13462') $PGcount++; if (isset($weatherdata[0]) || isset($weatherdata[1]) || isset($weatherdata[2]) || isset($weatherdata[6])) { if (($Cities[$i][4]!='13462') || (($Cities[$i][4]=='13462') && $PGcount<=1)) { fwrite($fp,"\t\n"); fwrite($fpobs,"\t\n"); $sdata=sprintf("\t\t%s\n",$Cities[$i][4]); fwrite($fp,$sdata); fwrite($fpobs,$sdata); $sdata=sprintf("\t\t%s\n",$Cities[$i][5]); fwrite($fp,$sdata); fwrite($fpobs,$sdata); $sdata=sprintf("\t\t%04d-%02d-%02d\n",$year,$month,$day); fwrite($fp,$sdata); if (isset($weatherdata[0])) { $sdata=sprintf("\t\t%d\n",$wttocg[$weatherdata[0]]); fwrite($fp,$sdata); } if (isset($weatherdata[2])) { $sdata=sprintf("\t\t%d\n",$weatherdata[2]); fwrite($fp,$sdata); } if (isset($weatherdata[1])) { $sdata=sprintf("\t\t%d\n",$weatherdata[1]); fwrite($fp,$sdata); } if (isset($weatherdata[6])) { $sdata=sprintf("\t\t%s\n",$s=$swd[floor((($weatherdata[6]+22.5)%360)/45)]); fwrite($fp,$sdata); } // $sdata=sprintf("\t\t\t\t\t%d\n",$weatherdata[0]); fwrite($fp,$sdata); //if (isset($weatherdata[21])) { $sdata=sprintf("\t\t%s\n",$weatherdata[21]); fwrite($fp,$sdata); } //if (isset($weatherdata[22])) { $sdata=sprintf("\t\t%s\n",$sww[$weatherdata[22]]); fwrite($fp,$sdata); } fwrite($fp,"\t\n"); fwrite($fpobs,"\t\n"); } } } // fwrite($fp,"\t\t\t\n"); // fwrite($fp,"\t\t\t\n"); // for ($iTime=0; $iTime<$nTimeCity; $iTime++) // { // ClearWeatherData(); // $year=$Times[$iTime]["year"]; $month=$Times[$iTime]["month"]; $day=$Times[$iTime]["day"]; // for ($hour=0; $hour<24; $hour+=3) // { // LoadDataModelHourly("eta",$city,$year,$month,$day,$hour); // LoadDataHourly($city,$year,$month,$day,$hour); // if (isset($weatherdata[0]) && isset($weatherdata[2])) // { // fwrite($fp,"\t\t\t\t\n"); // $sdate = sprintf("%04d-%02d-%02d",$year,$month,$day); // $stime = sprintf("%02d:00:00",$hour); // $dt=MakeLocalDateTime($sdate,$stime); // if (isset($row->sdate)) // 2010-04-25 // { // yyyy-mm-dd // // 0123 56 89 // //$sdate=$dt[0]; // $sdate=$row->sdate; // $year=substr($sdate,0,4); // $month=substr($sdate,5,2); // $day=substr($sdate,8,2); // } // if (isset($row->stime)) // hh:mm:ss // { // hh:mm:ss // // 01 34 67 // //$stime=$dt[1]; // $stim=$row->stime; // $hour=substr($stime,0,2); // $minute=substr($stime,3,2); // } // $sdatetime = sprintf("%04d%02d%02d%02d%02d%02d",$year,$month,$day,$hour,0,0); // $sdata=sprintf("\t\t\t\t\t%s\n",$sdatetime); fwrite($fp,$sdata); // if (isset($weatherdata[2])) // { // $sdata=sprintf("\t\t\t\t\t%3.1f\n",$weatherdata[2]); // fwrite($fp,$sdata); // } // if (isset($weatherdata[3])) // { // $sdata=sprintf("\t\t\t\t\t%5.1f\n",$weatherdata[3]); // fwrite($fp,$sdata); // } // if (isset($weatherdata[5])) // { // $sdata=sprintf("\t\t\t\t\t%d\n",$weatherdata[5]); // fwrite($fp,$sdata); // } // if (isset($weatherdata[6])) // { // $sdata=sprintf("\t\t\t\t\t%d\n",$weatherdata[6]); // fwrite($fp,$sdata); // } // if (isset($weatherdata[0])) // { // $sdata=sprintf("\t\t\t\t\t%d\n",$weatherdata[0]); // fwrite($fp,$sdata); // } // if (isset($weatherdata[9])) // { // $sdata=sprintf("\t\t\t\t\t%3.1f\n",$weatherdata[9]); // fwrite($fp,$sdata); // } // if (isset($weatherdata[10])) // { // $sdata=sprintf("\t\t\t\t\t%d\n",$weatherdata[10]); // fwrite($fp,$sdata); // } // fwrite($fp,"\t\t\t\t\n"); // } // } // } // fwrite($fp,"\t\t\t\n"); // fwrite($fp,"\t\t\n"); fwrite($fpobs,"\t\t\n"); $oldcountry=$country; } fwrite($fp,"\n"); fwrite($fpobs,"\n"); } function InsertWeatherForTimes() { global $Times; global $fp; $n=count($Times); $fp=fopen("pointweather.xml","w"); for ($i=0; $i<$n; $i++) { echo "i=$i\n"; InsertWeatherForCities($Times[$i]["year"],$Times[$i]["month"],$Times[$i]["day"],12); } fclose($fp); } include ('/home/meteos/projects/common/baseutil.php'); connecttodb(); if (!isset($idclient)) $idclient=75; GetCities($idclient); echo "$argc\t"; for ($i=0; $i<$argc; $i++) echo "\t$argv[$i]"; echo "\n"; $datetime=getdate(time()); $year=$datetime["year"]; $month=$datetime["mon"]; $day=$datetime["mday"]; $hour=$datetime["hours"]; echo "$year $month $day $hour\n"; if ($hour>=8) { $datetime=getdate(time()+24*60*60); $year=$datetime["year"]; $month=$datetime["mon"]; $day=$datetime["mday"]; $hour=$datetime["hours"]; echo "$year $month $day $hour\n"; } $hour=12; echo "InsertWeatherForCities($year,$month,$day,$hour);\n"; if ($argc>1) for ($k=1; $k<$argc; $k++) { $sdate=$argv[$k]; $Times[$k-1]["year"]=substr($sdate,0,4); $Times[$k-1]["month"]=substr($sdate,5,2); $Times[$k-1]["day"]=substr($sdate,8,2); } else { GetTime($year,$month,$day); } //InsertWeatherForTimes(); $fp=fopen("pointweather.xml","w"); $fpobs=fopen("pointweatherobs.xml","w"); InsertWeatherForCities($year,$month,$day,$hour); fclose($fpobs); fclose($fp); mysql_close(); ?>