Many fire departments are able to receive text or email messages from their dispatch center’s computer-assisted dispatch (CAD) system to alert them to a call. These text messaging systems are usually a secondary means of notification, with voice or alphanumeric paging being the primary method, since commercial text messaging can be delayed if the system is busy. This page describes how to use the information from a CAD system email to map out directions to the call on a Google Map page and also to show the actual building in Google Street View. These can both be integrated into a single web page that can be displayed in a truck bay or on an apparatus laptop. The driving directions help with route planning, and the Street View snapshot can help give us clues about building construction, occupancy type, and apparatus placement before we ever even arrive.
First, your dispatch center must be able to send the call
information to an email address. Next,
you’ll need a list of addresses in your coverage district with associated
latitude and longitude for each address.
You may be able to get this from your city our county GIS
department. If not, you can generate
this data yourself using Google Earth, but it will take some work. In addition, in order to get the Street View
working properly, you’ll need a data set that has the roads in your district in
some type of segmented line format. This
could be as a shapefile, KML file, etc.
Again, your GIS department may have this data, or you can generate it
yourself using Google Earth. Finally, you'll need a web server that you can host the web page on. The server must be running PHP. If your department already has a website, you can probably use that web server. Or, if you only need the mapping on one computer, you could host the web page locally using WampServer.
The most important key to making this system work is to have accurate address data. This means a list of addresses with associated latitude and longitude. While Google Maps are nice, the exact addresses can be off by quite a distance, especially on rural roads. Having your own data set allows you to map to a specific set of coordinates (which Google Maps is very good at) instead of to an address that may not be accurate in Google’s database. This data set could come from a county or city Geographic Information Services (GIS) department, or you can manually generate it yourself using Google Earth. In any case, the format isn’t critical, as long as you have the data. In my situation I used an ESRI shapefile as a starting point and converted that into a KML file that I could view and edit in Google Earth. It’s important to spend some time looking over the data set closely and making additions and corrections. Don’t assume that the data that the county or city gives you is 100% correct (also, share your corrections with your GIS department). After I had all of my corrections made, I converted the KML file into a CSV file for ease of use by the PHP script. The resulting CSV file is simply a list of addresses with associated lat/long, in comma-separated text format:
18619 ZIMMERMAN RD,40.5994167,-89.2832167
Sometimes an exact match isn’t found but a close match is
found. As an example, this can happen if
an address is given as “402 FIRST AVE” in the dispatch email but is listed as
“402 FIRST AV” in the CSV file. Or you
may have a new address in your district that isn’t yet in your CSV file. If the address given is “402 FIRST AVE” but
you don’t yet have that address in the CSV file, “401 FIRST AVE” would produce
a close, but not exact, match. In this
case we’ll still use the lat/long from the close match to send to the Google
Maps API, but we’ll give a visual indication that an exact match wasn’t found
by coloring the infowindow background yellow instead of green. This lets responders know to check the
address given and the address plotted to see why they’re different. We’ll set a threshold of the Levenshtein
distance (for example, distance <=2)
to determine whether it’s a close match or not.
If no exact or close match is found, we can still punt and send the raw address information directly to the Google Maps API, instead of a lat/long. This may get us close, or it could send us to a different state, it’s hard to say. We’ll color the background of the destination marker’s infowindow red to alert responders that they really need to be careful about trusting the directions given. In most cases, the guess is pretty good. For example, an address might be given as an intersection of two roads for a car accident. Since this isn’t an actual address, it may not be in your CSV file, but Google may still be able to figure out about where it is. Another example may be a call in a mutual aid district that you don’t have exact address data for. Again, Google may be able to get you close. But it could also send you to somewhere in Arizona, so be careful.
Once you know the destination lat/long, you could also show a zoomed-in aerial image of the location, in addition to the driving directions. This could be helpful for initial sizeup and apparatus positioning. Or, you may also be able to show the building in Street View, but that takes some additional work, as described below.
Having driving directions to an address is a big help, but what if you were able to see the building you’re going to before you ever even leave the station? Street View makes that possible. However, it’s not as easy as just giving Google a Lat/Long of a building and having it show up in Street View. Instead, the Street View API requires that we input the lat/long of the camera location, which is the location on the street in front of the building, as well as a camera heading, which is the direction that the camera is pointing.
So we know the lat/long of our destination address, how do
we get the lat/long of the location on the street that we want the street view
camera to “shoot” from? There are two ways we can go about doing this. The first method works if we have a data set of road segments that we can use to calculate the best camera location from. If we don't have that data set available, there is a way to do some web-scraping of Google's map results to get their best camera position and heading.
First, we need to know where the road is. In GIS terms, roads are made up of segments, and each segment has a starting set of coordinates, and an ending set of coordinates (lat/long). Even a curved road can be segmented, it’s just broken up into a lot more segments than a straight road is:
If we can get a list of road segments in our district, we can then loop through all of the segments and find the distance from the closest point on each segment to our address coordinates using this algorithm (example code). In the drawing below, it shows the shortest distance from each segment to our address (point A). The point at the end of the shortest of all of the distances (point B) is where we want the Street View camera to be.
Now that we know where the camera should be located, we need to figure out which direction it should be facing (its heading). Figuring this out requires some trigonometry (hint: think arctangent!). Also note that since the distances we’re dealing with are probably pretty small, we can cheat and use our lat/long coordinates as if they’re Cartesian coordinates and use Euclidean geometry, rather than getting technically correct and using Riemannian geometry, which is what we’d have to do to account for the curvature of the Earth if we were dealing with long distances.
120 Oak Valley Dr,40.6146688,-89.27487764,40.6138806113,-89.2741799034,318.483443301
If we don't have a data set of road segments, there is a way that we can make Google do the work for us. If you do a Google Map search of a location where Street View is available, you'll notice that on the results page there is a link that you can click on to go directly to a Street View of that location. For example, if I search for lat/long location 43.194966, -88.728030 in Google Maps, I get this back:
Here is some PHP code that sends a lat/long to Google Maps and scrapes the returned web page to see if the Street View hyperlink is available. If it is, it extracts the camera location (from the cbll parameter) and the heading (from the cbp parameter) to use in our own API call. See this page for more information about the Google Maps URL parameters and how to understand them.