Archive for March, 2017

Experiments with APIs: a CFA fire alerts app

March 13, 2017


Over the last couple of days I thought it might be interesting to investigate writing a prototype CFA fire alerts app.  The key motivation of this was essentially the pursuit of simplicity.  Emergency Victoria do happen to have an alerts app, but it contains a plethora of different calls to various different RSS feeds and other APIs, and is not just a way for people to be notified regarding CFA fire alerts.

The CFA used to have an older app, in fact, but it was decommissioned in favour of the “improved” and more general app.

So I decided to look into trying to build my own over the last couple of days, this Labour Day weekend.

Ultimately, I was successful in my goal of building a prototype.  Essentially I built an app in Unity that I was able to compile and deploy to my android phone.  It displays a map centered on hard-coded latitude and longitude coordinates, and places a black pin anywhere on that map corresponding to a flammables related incident that the app considers to be interesting.  Also it only does this once; there is no refresh option, no buttons to push.  Very simple and utilitarian.  But a good proof of concept.


Getting the data

So how did I go about building the app?  Well, first I worked out how to get the xml file located here:, by making a C# request using Unity libraries.

Processing the data

Secondly, I deserialised that xml object into a list of incidents.

Next, I extracted all of the information from the description attribute: an additional 13 fields.

Obtaining the interesting information within the data

Consequent to this, I used my google and script-kiddie abilities to graft on some code to my project that could convert two pairs of (latitude, longitude) coordinates into a relative distance.

After that, I wrote a filter to determine what constituted an “interesting” fire: that being sufficiently close to a particular pair of hard-coded coordinates, and also with the additional qualities that the fire was not small, and not under control.

Debugging statements and breakpoints helped tremendously throughout this process.

Displaying the information to the user

So that allowed me to determine what was interesting.  But that left one final thing, figuring out how to display that to the user.

Fortunately, there was a plugin on the Unity App Store I was able to download for free, for the google static maps api.  With additional code-kinder knowhow, I was able to adapt the out of date code therein.

With further chicanery and trial and error, I was able to then graft my hard-coded lat,long coordinates to center the map about my location of interest, then push through the interesting incidents into a list of markers which would then be placed on the map as black pins.  This relied entirely upon the features of the google static maps API.

Deploying to Android

Finally I investigated deploying and building the project to android.  I found that I needed to do a number of things:

  • Install Android Studio 2.3.1.
  • Install the Android SDK for Android 6.0
  • Install the JDK from the Oracle website for Java SE 8.
  • Alter the Unity settings to point to this new JDK rather than for Java SE 7.
  • Alter the player settings within the Unity build settings so that the 32 bit display buffer was unchecked.
  • Alter the player settings within the Unity build settings so that the project had an appropriate name (com.spinningcatstudios.ChrisCFAApp)
  • Create an android manifest at ProjectRoot/Assets/Plugins/Android/manifest.xml with an appropriate format, so that I could select the appropriate Android SDK
  • Finally, in Settings/Security, I needed to allow untrusted code to run in order to install my app.

After this I was able to build the project, and debug it while connected to my development computer.  However I found that Astro File Manager could not install apk files with Android OS 6, so I needed to switch to a more modern file manager.

Future features

Various additional features that come to mind are:

  • Configurability of what constitutes an interesting event.
  • Ability to alter the zoom and focused location of the map, to see more or less.
  • Add additional data feeds (eg traffic incidents etc) with other additional filters.
  • Move from the google static maps api to the google dynamic maps api 3.0
  • Notifications for when alerts occur

Bug fixes

  • Make the map look less stretched.

Parting thoughts

All in all, this was an interesting experience.  The end result is that I have a working prototype, which I can certainly at least deploy to Android, and hopefully should be less painful to deploy to iOS.  Anyway, here’s hoping!