Data Interpreter

The data interpreter uses php to extract the data and create a versatile web display using the Google Maps Api. The data interpreter begins by checking if the data files are present and if they are formatted properly. If a data file is not present or is not formatted, the program stops and returns an error according to our error table (Figure 6,7). Each error code contains two letters and one number.

Figure 6 (above): A table of the meanings of the first 2 characters of the error codes

Figure 7 (above): A table of the meanings of the last character of the error codes

For example error FO1 would mean an error occurred while opening the file policedata.txt. If there are no opening or locating errors, the program opens and writes the basic html and Google Maps API components to our heatmap file. If the program cannot write the heatmap file it returns a writing error. The program continues by tokenizing the police data file, and counts the number of lines. A for loop separates the data line by line and stores the longitudes, latitudes and the amount of officers into arrays. If the file is improperly formatted, the program stops and returns a formatting error. The arrays are then unpacked and written to the heatmap file in the Google Maps LatLng format, {position: new google.maps.LatLng( longitude , latitude ), type : officer_number}. A second for loop repeats this process with the crime data file (crimedata.txt) using the Google Maps weighted location format, {position: new google.maps.LatLng( longitude , latitude ), weight: weight}. The program then writes the closing html and Google Maps Api components to the heatmap file.