The Underlying Data
The system has several underlying database tables, including zip codes, cities and station data. The zip code and city tables, in addition to containing information about the locations, also include the latitude and longitude for the centroid each location. These are pretty simple, flat tables that contain the approximately 41,000 zip codes and 150,000 cities in the United States.
The station tables, on the other hand, are much more complex. They contain all of the nearly 2000 stations that carry NPR programming (as well as their translators) along with a wide array of information about those stations, including licensee data and pertinent URLs associated with the station (e.g. their home page, schedule page, donation page, audio streams, RSS feeds and podcast feeds). These tables also include the latitude, longitude and broadcast power information for each antenna.
The broadcast power information tells us how far that antenna's broadcast signal can reach in each direction. Our data is broken up into 72 directions, starting with due north and shifting five degrees around the circle until we are back at due north. For each direction, our database contains five different ranges, detailing how far the antenna can reach in that given direction. The range itself determines two things. First, it tells us how far away you can be from the antenna and still hear its signal - this takes into account some impediments, such as mountains. The second thing it tells us is what the quality of the signal will be. The closer you are to the antenna, generally, the more clear the signal will be (although this is not always the case).
Finally, most of the data in these tables is publicly available in our recently launched Station Finder API (the coverage data is not available, but everything else is). The functionality of the map is driven off of the API.
How Does the Search Work?
At the core, the system works based on latitudes and longitudes. If you search the system by zip code or city/state, the system will convert the search term into a latitude and longitude before looking for stations. Similarly, when you look for NPR stations along a driving route, the system identifies a series of points along the route and converts those points into latitudes and longitudes. The waypoints for driving routes include any turn, crossing of a border, start and end points, and some artificially inserted points that we create. (Searches based on call letters bypass the geo-searches and hits the station tables directly.)
Once we have the latitude and longitude, we perform a series of calculations based on the Great Circle Calcuation (GCC), which helps us to determine distances on a curved surface (ie. the Earth - and we are assuming that it is not flat). Using the GCC, we look for stations near the latitude and longitude, based on a 100 mile radius from that point. From that list of stations, which is too inclusive, we start our process of narrowing down the results to the actual stations that can be heard.
For each station returned from our initial search, we first determine the direction (one of the 72 described earlier) from the antenna to the requested latitude/longitude. Then we find out the distance between the antenna and the latitude/longitude using the GCC. Once we have the distance and the direction, we simply need to do a lookup in our database to determine if the broadcast distance of the station is greater than the distance between the antenna and the latitude/longitude. If the broadcast distance is greater, then the station can be heard in the latitude/longitude. If it is not, then the station cannot be heard.
Now, when I say "check to see if the broadcast distance is greater", we are really checking five different broadcast distances in the database. We do this to find out what the quality of the broadcast signal will be for that latitude/longitude. The further the distance, assuming it is still within range, the more likely the signal will worsen. There are other variables, but that is the basic idea.
Displaying on the Map
The display of this information on the map is pretty straight-forward. We simply drop an antenna icon at each latitude/longitude where a station's antenna is actually located. For that antenna, we use the polygon feature in Virtual Earth to draw and shade the coverage circles on the map. The contours of the coverage circles are drawn by taking the distance of the broadcast range in each of the 72 directions, drawing a line connecting the points, then shading in the circle. We do this for three of the five broadcast ranges in our database. The overlay of the shading for each of these three circles results in the inner circle being darker than the middle circle, which is darker than the outer circle.
One other thing I should point out about this data is that it is great for the purposes of this type of application - a web-based service to inform our audience as to which NPR stations are available throughout the country. There are other more sophisticated, more precise ways to identify the station coverage maps which are really overkill for this type of service.
To see another representation of this same functionality, go to nprroadtrip.com. This is a map mashup produced by an NPR enthusiast (not affiliated with NPR).