include_once("instance/global.php");
include_once("instance/city_list.php");
include_once("instance/traffic.php");
include_once("utils.php");
include_once("screen_size.php");
include_once("weather_alerts_for_state_road.php");
include_once("ws_client.php");
function startsWithNumber($string) {
$length = strlen($string);
for ($i = 0, $int = ''; $i < $length; $i++) {
if (is_numeric($string[$i]))
$int .= $string[$i];
else break;
}
return (int) $int;
}
function getCityState($laln) {
$ret = getWebService("citystate", $laln);
$t = explode(",",$ret);
return $t;
}
function parseDotEvents($a) {
/*
Title=>US 30 both directions : Accident;;Description=>NJ DOT - TOC South: Accident on US 30 both directions East of CR 700/Linden Av (Lindenwold) traffic shift 5-10 minute delay use caution;;PubTime=>Wed, 10 Apr 2013 16:24:37 -0400;;Geo=>39.8154772416 -74.9911315733
*/
if(!isset($a)) return array();
$t = explode("%@|", $a);
$size = count($t);
$ret = array();
for($i=0;$i<$size;$i++) {
$t1 = explode(";;", $t[$i]);
$title = explode("=>", $t1[0]);
$desc = explode("=>", $t1[1]);
$time = explode("=>", $t1[2]);
if(startsWithNumber($title[1]) && strlen($title[1]) <= 3) {
$ret[$i]["time"] = $title[1];
$ret[$i]["title"] = "";
$ret[$i]["desc"] = "" . $title[1] . " ago: " . $desc[1];
} else {
$ret[$i]["title"] = $title[1];
$ret[$i]["desc"] = strip_tags($desc[1]);
$ret[$i]["time"] = $time[1];
}
}
return $ret;
}
function displayDotEvents($stateCode, $NUM) {
$events = getDotEvents($stateCode);
$ret = parseDotEvents($events);
$size = count($ret);
for($i=0;$i<$size;$i++) {
$desc = $ret[$i]["desc"];
if(isset($NUM))
if( (strpos($desc,"I-$NUM") === false) && (strpos($desc,"I $NUM") === false) &&(strpos($desc,"Interstate $NUM") === false) )
continue;
echo "
";
if($ret[$i]["title"] == "") {
echo $ret[$i]["desc"];
} else {
echo "" . $ret[$i]["title"] . "";
echo "
";
echo $ret[$i]["desc"];
echo "
";
echo "" . $ret[$i]["time"] . "";
}
echo "";
}
}
$stateIndex = $_GET['i'];
if($stateIndex >= count($city_list))
$stateIndex = count($city_list) - 1;
$state = $city_list[$stateIndex][0];
$stateCode = $state;
$state_name = getStateName($state);
$title = "I-$NUM Traffic Road Conditions $state_name - Roadnow";
$content = "I-$NUM traffic,road conditions in $state_name,Interstate $NUM $state_name current traffic,road conditions and accident reports.";
$keys = $content;
$hwy = $hwy_name;
//$bbox = getBboxForRoadInState($hwy,$state);
//$incidents = getIncidentsReports($bbox);
$size = count($incidents);
$k=0;
for($i=0;$i<$size;$i++) {
if(strpos($incidents[$i]->{"shortDesc"}, $hwy) === false ) continue;
$incidents_reports[$k]['title'] = $incidents[$i]->{"shortDesc"};
$incidents_reports[$k]['desc'] = $incidents[$i]->{"fullDesc"};
$incidents_reports[$k]['start'] = $incidents[$i]->{"startTime"};
$incidents_reports[$k]['end'] = $incidents[$i]->{"endTime"};
$incidents_reports[$k]['startOrig'] = $incidents[$i]->{"startTimeOrig"};
$incidents_reports[$k]['endOrig'] = $incidents[$i]->{"endTimeOrig"};
$incidents_reports[$k]['icon'] = $incidents[$i]->{"iconURL"};
$incidents_reports[$k]['la'] = $incidents[$i]->{"lat"};
$incidents_reports[$k]['ln'] = $incidents[$i]->{"lng"};
$incidents_reports[$k]['timeago'] = $incidents[$i]->{"timeago"};
$k++;
}
$gps = getHwyMidPoint($hwy,$state);
$la = $gps[0];
$ln = $gps[1];
$centerLa = $gps[0];
$centerLn = $gps[1];
$pageId="traffic_state";
$stateNameGood = good($state_name);
$alerts_count = getWeatherAlertCount($hwy,$state);
if($alerts_count == 0 )
$weather = "";
else
$weather = "$state Weather Alerts ($alerts_count)";
$dotSite = $dotSites[$state];
$t = explode(";", $dotSite);
if(count($t) > 1)
$dotSite = trim($t[1]);
else
$dotSite = trim($t[0]);
$numEvents = 0;
$events = getDotEvents("$state,S");
$t = explode("%@|", $events);
if(count($t) > 1)
$numEvents = $t[0];
$stateCode_L = strtolower($state);
$state_name_good = strtolower(good($state_names[$state]));
if($numEvents ==0)
$dot = "( see also $state DOT )";
else
$dot = "( see also $state Incident Reports ($numEvents) )";
$stateNameGood = str_replace(" ","+", $state_names[$state]);
$news_reports = getNewsEvents("I-$NUM+$stateNameGood");
$news_num = count($news_reports);
$news = "I-$NUM $state_name News ($news_num)";
//$content .= "
" . $dot;
?>
include("header_html.php");?>
include("header.php");?>
echo "";
?>
$poi_infowindows = "incidents_infowindows.php";
$zoom = 8;
include("g_traffic_incidents.php");
if(strlen($iname) <= 4) {
$road = "$iname,$stateCode";
} else
$road = str_replace(" ",",",$iname);
?>
include("admob.php");
?>
echo "";
$size = count($incidents_reports);
for($i=0;$i<$size;$i++) {
$title = $incidents_reports[$i]['title'];
$desc = $incidents_reports[$i]['desc'];
$start = $incidents_reports[$i]['start'];
$end = $incidents_reports[$i]['end'];
$startOrig = $incidents_reports[$i]['startOrig'];
$endOrig = $incidents_reports[$i]['endOrig'];
$la = $incidents_reports[$i]['la'];
$ln = $incidents_reports[$i]['ln'];
$timeago = $incidents_reports[$i]['timeago'];
$citystate = getCityState("$la,$ln");
$city = $citystate[0];
$city_good = good($citystate[0]);
$state = $citystate[1];
echo "- ";
/*
echo "
";
echo "
$timeago ago";
//echo "
$title, near $city_url
";
echo "
$title, near
$city, $state ";
echo "$desc
";
echo "start time: $start
";
echo "end time: $end
";
echo "
";
*/
echo "";
echo "
$timeago ago";
//echo "
$title, near $city_url
";
echo "
$title";
echo ",
near $city,$state ";
echo "
$desc";
echo "
start time: $start
";
echo "
end time: $end
";
echo "
";
echo " ";
}
displayDotEvents($stateCode,$NUM);
echo "
";
?>
include("footer_1_ad.php"); ?>