SPUG: perl interface to Puget Sound traffic conditions
Mark Wagner
mark at lanfear.net
Thu Dec 27 18:08:16 CST 2001
While working on a text version of the Eastside Journal web site I started
hacking together a perl interface to the Puget Sound traffic condition
data. That project was canceled but I got the interface working somewhat.
Rather than let it die (perhaps it should) I've made a tarball of
the source at <http://www.lanfear.net/~mark/webflow.tar.gz>.
The following example finds the locations of heavy traffic on the main
I-5 southbound lanes and the major incidents for the area:
-- cut here --
use Webflow ();
my $wf = new Webflow;
$wf->update(stations => 'foo.sta', messages => 'foo.msg',
data => 'foo.dat') or die $wf->{errmsg};
$sucks = $wf->select(highway => 'I-5', lane => 'main',
direction => 'south', congestion => 'heavy')
or die $wf->{errmsg};
print "Incidents:\n";
for my $message (@{$wf->{messages}}) {
$message->{heading} eq 'INCIDENT' or next;
for my $text (@{$message->{text}}) {
print "$text\n";
}
}
print "\n";
print "Heavy traffic:\n";
for (@{$sucks}) {
print "$wf->{stations}[$_]{location}\n";
-- cut here --
As of Thu Dec 27 15:51:15 PST 2001 the this produced the following
output:
-- cut here --
Incidents:
CLEARED verified with camera 3:12 PM: I-5 southbound TO MERCER ST accident partially blocking RAMP verified with camera 3:08 PM
A MAJOR EVENT WILL OCCUR THIS AFTERNOON AT SAFECO FIELD FROM 1:00 TO 5:30 PM. MOTORISTS SHOULD EXPECT SIGNIFICANT TRAFFIC IMPACTS AND ARE ADVISED TO PLAN ACCORDINGLY.
A MAJOR EVENT WILL OCCUR THIS EVENING AT THE KEY ARENA FROM 7:30 TO 10:00 PM. MOTORISTS SHOULD EXPECT SIGNIFICANT TRAFFIC IMPACTS AND ARE ADVISED TO PLAN ACCORDINGLY.
Heavy traffic:
Marion St
S Spokane St
Columbian Way
Mercer St
4th Ave
S Oregon St
-- cut here --
--
Mark Wagner mark at lanfear.net
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/
More information about the spug-list
mailing list