Who are we?
We are just a couple people who used the Minnesota Department of Transportation's web page to see what
traffic conditions were like. While you can get a quick taste of what is happening by looking at MN/DOT's
incident page, we found it inconvenient to be "clicking" on each incident to see what was going on. We
wrote a program that would present all the incidents, with the images from MN/DOT's cameras, on one page.
When we saw that others were locating the page through search engines, we decided the pages should have their
own domain and more features. So here we are on www.twincitiestraffic(.com|.info|.net)
How do we get the information?
All the information presented on these pages is from the Minnesota Department of Transportation's web site.
At this point we have written 4 different programs that keep track of things and there will be several other
programs to present the information we have collected to the visitor. All the programs are written in Perl.
The first program is the "incident
updater" program and is running all the time, but sleeps for X seconds between scrapes, depending on the time of
day (0600 - 1000 : 60 Seconds)(1001 - 1459 : 120 Seconds)(1859 - 0559 : 300 Seconds) It's job is to monitor the
MN/DOT incident web page. The program scrapes the incident frame from the web site, parses the pertinent data
and then updates a MySQL database. When the program sees
an incident for the first time it places the information in the "current" and "working" tables in the database.
The next time it scrapes data, if an incident is no longer present it removes it from the "current" table. When
the incident is out of the "working" table for 5 minutes it removes it and places the
data into the "history" table. Each incident is given an "incident ID" number that is used to keep track of
each incident.
The second program is the "graph updater" and runs every 5 minutes. This program uses GD::Graph and Image::Magick
to create graphs from the data contained in the "history" table of the MySQL database.
The third program is the "incident_recorder" and is always running. This program has basically two states, an
incident state and a no-incident state. While in the incident state it will grab MN/DOT camera images every 10
seconds. In the no-incident state it checks the "working" table of the MySQL database. If it sees working incidents
it goes into the incident state. If there are no incidents it sleeps for 60 seconds. If an incident has ended, it
fires off the 4th program, waits for it to finish and then continues to monitor the "working" table.
The fourth program, "movie maker" is run automagically by the "incident recorder" program. When an incident
has ended, the program reads all the images that were saved by the incident recorder program and creates a
Flash SWF Movie from those incidents. After the movie is made, all the images from the incident are deleted.
These Flash Movies are then immediately available to the visitors for review.
The programs that are used to present the information to the visitor, are not all available at this time. The two
that exist are the main "index" program, whose output you see as the main page for Twin Cities Traffic Info, and
the "archive viewer" program, which shows a list of all the Flash Movie replays of the image captures of the
incidents. Eventually there will be other programs that will show the visitor information from the "history" table
of the MySQL database, and will allow you to choose incident replays from different time frames, etc.
Why do we do this?
Because we can.
Can you add feature X?
Perhaps, what feature would you like to see? Email webmaster (at) twincitiestraffic.info