function networkSelectAuto($network, $selected, $extra = array()) { $network = strtoupper($network); $s = ""; include_once dirname(__FILE__) . "/network.php"; $nt = new NetworkTable($network); $cities = $nt->table; reset($cities); $s .= "<select name=\"station\" onChange=\"this.form.submit()\">\n"; while (list($sid, $tbl) = each($cities)) { if ($tbl["network"] != $network) { continue; } $s .= "<option value=\"{$sid}\" "; if ($selected == $sid) { $s .= "SELECTED"; } $s .= ">[{$sid}] " . $tbl["name"] . "</option>\n"; } while (list($idx, $sid) = each($extra)) { $nt->load_station($sid); $tbl = $nt->table[$sid]; $s .= "<option value=\"{$sid}\" "; if ($selected == $sid) { $s .= "SELECTED"; } $s .= ">[{$sid}] " . $tbl["name"] . "</option>\n"; } $s .= "</select>\n"; return $s; }
<?php include "../../config/settings.inc.php"; include "../../include/mlib.php"; include "../../include/network.php"; $nt = new NetworkTable("IA_RWIS"); $cities = $nt->table; function fancy($v, $floor, $ceil, $p) { if ($v < $floor || $v > $ceil) { return ""; } return sprintf("%{$p}.1f", $v); } include "../../include/iemaccess.php"; include "../../include/iemaccessob.php"; $iem = new IEMAccess(); /* Lets also get the traffic data, please */ $rs = pg_query($iem->dbconn, "select l.nwsli, t.* from rwis_traffic t, \n\trwis_locations l where l.id = t.location_id and lane_id < 4"); $traffic = array(); for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) { if (!array_key_exists($row["nwsli"], $traffic)) { $traffic[$row["nwsli"]] = array("avgspeed0" => "M", "avgspeed1" => "M", "avgspeed2" => "M", "avgspeed3" => "M"); } $traffic[$row["nwsli"]][sprintf("avgspeed%s", $row["lane_id"])] = round($row["avg_speed"], 0); } $tstamp = gmdate("Y-m-d\\TH:i:s"); $mydata = $iem->getNetwork("IA_RWIS"); $rwis = fopen('/tmp/wxc_iadot.txt', 'w'); fwrite($rwis, "Weather Central 001d0300 Surface Data TimeStamp={$tstamp}\n 22\n 5 Station\n 52 CityName\n 2 State\n 7 Lat\n 8 Lon\n 2 Day\n 4 Hour\n 5 AirTemp\n 5 AirDewp\n 4 Wind Direction Degrees\n 4 Wind Direction Text\n 4 Wind Speed\n 4 SubSurface Temp\n 4 P1 Temp\n 4 P2 Temp\n 4 P3 Temp\n 4 P4 Temp\n 4 Pave Ave Temp\n 3 Sensor 0 Average Speed\n 3 Sensor 1 Average Speed\n 3 Sensor 2 Average Speed\n 3 Sensor 3 Average Speed\n"); $now = time();