Traffic Incidents
Traffic Incidents module displaying a traffic event near the 02131 zipcode.
Overview
The Traffic Incidents module it is by far the most complex module. It provides real-time traffic updates for a specified location using the TomTom Traffic API. The module's display is a 1x3 rectangle.
Note: Only US ZIP codes are supported as of now.
Web GUI View
Information Displayed
The module presents the following details:
-
Traffic Event: Example: "Heavy Traffic Near" (the word "Near" indicates an approximate location).
- This is a list of all the following traffic events:
- Accident
- Fog
- Hazardous Road
- Rain
- Ice
- Jam
- Lane Closed
- Road Closed
- Road Works
- Narrow Lanes
- Tow Trucks
- Other
- This is a list of all the following traffic events:
-
Street Address: Example: 520 South St.
-
City, State, Zipcode: Example: Roslindale, MA 02131.
Usage
-
Click the "Select a Module:" dropdown at the top of the web GUI and select the "Traffic" module.
-
Click the green "Add Module" button to the right of the dropdown.
-
Drag and drop the module to your desired position within the grid.
-
Enter a valid US ZIP code in the "Enter a ZIP Code" field.
-
Click "Save Weather Settings":
- A green confirmation message will appear if the settings are saved successfully.
- A red error message will indicate a failure.
-
Click the "Generate API File" button and follow the instructions:
-
Click the "Consume API File" button and follow the instructions:
-
Click "Update Display":
- The screen will blink (indicating a cleaning sequence) and display the updated configuration.
Workflow
The Traffic Incidents module retrieves real-time traffic data based on user settings stored in the database.
-
Retrieve Settings:
The module pulls the user’s API key and selected ZIP code from the database (TrafficSettings
table). -
ZIP Code Conversion:
The ZIP code is converted into latitude and longitude coordinates using a local dataset (US.txt
). -
Define Bounding Box:
A small bounding box around the derived coordinates is calculated to narrow the area for traffic incident queries. -
API Request:
The TomTom API is queried with the bounding box, filtering incidents based on specific categories such as accidents, road closures, or heavy traffic. -
Response Handling:
The API's response is processed to extract incident details, including category and coordinates. -
Reverse Geocoding:
Incident coordinates are reverse-geocoded to obtain human-readable addresses. -
Address Formatting:
Addresses are abbreviated for better readability, and incidents are compiled into a list for display.- As of now only one which is randomly selected is used for the screen.