Green Kauai Map (2013)

empty

Malama Kauai

The Green Kauai Map is a map of Kauai that displays many of the “green” (environmentally and socially conscious) businesses, organizations, and farms on the island.  It also has a list of all of the island’s farmers’ markets.

(Free) Download for iOS: https://itunes.apple.com/us/app/green-kauai-map/id519540648

Malama Kauai first published the app in 2010, but the app had been non-functional for many months after various changes in Google’s mapping APIs.   Since Malama Kauai is a small non-profit organization that my family strongly supports, I volunteered my services to fix and maintain the app for free.

The most important thing to fix was the location data.  In the v1.0 version that the previous developer made, all of the locations’ geographical positions were looked up with reverse geolocation based on their mailing addresses.  This created a variety of problems.

Problems:

  • Mailing addresses could not always be resolved to geographical locations.
  • Each location required one call to a map API’s reverse geolocation system, so the app would make 50+ calls per session.  This would result in a service rejection due to overuse, so the app could no longer function.  Additionally: by making so many API calls, the app might go beyond what is allowed for free use of the APIs.
  • Since the first two problems would cause location data to be non-retrievable, location pins would appear on the equator off the coast of Africa instead of on the island!
  • When it worked, reverse geolocation was not always accurate.  It would sometimes return coordinates that were miles away from the actual location.
  • Startup time could be long because the data had to be downloaded at startup every time the app was run.
  • Location data would always be loaded from a remote server at startup, so no data would be available if the device had no network connection at the time.  Although GPS data is available over most of the island, but cell phone service or wi-fi is not always available on the island, the lack of data could be annoying for users.
  • Even though the app was relatively simple, the previous developer had left a bunch of unused content in the app’s package, so the file size was over the 50MB limit for downloading apps over a cell phone network.  (iOS 7 has a 100MB limit, but I’m trying to support  iOS 5+.)

Solutions:

First, I completely removed the reverse geolocation calls.  Instead, I added latitude and longitude coordinates to the database.  That allowed the app to get location coordinates without using any API calls.  Not only did that save money, but it also drastically improved the startup speed, allowed the locations to be perfectly accurate, and uncoupled mailing addresses from physical addresses.

Next, I rewrote the data system so data could be downloaded and cached locally on a device.   That improved startup speed even more, since the data would be available right away.  It also allowed the app to work offline.

One interesting thing about the old system was that the original developer used a third-party data provider.  That data provider had an SDK for retrieving data from their system, but it didn’t support offline caching.  Also, that SDK required the Facebook and StoreKit frameworks, even if an app didn’t use Facebook or the App Store!  However, that data provider also had a REST interface that the app could use.  I removed all of the third-party code and frameworks and wrote a much simpler and faster REST downloader, cacher, and parser.  The code for parsing data dropped from thousands of lines to less than two hundred, even after adding the downloading and caching code!

After the offline data system was implemented, there needed to be a way to determine whether the data had been updated recently.  I wrote a version-checking system so the app will auto-update its local data whenever it needs to.

Once all of the changes to the data were implemented, I went through the app and removed the unused content, dropping the file size from 55.4MB to 9.86MB.  This made the app load even more quickly and permitted downloading over cell phone networks.

My previous iOS apps had been created with Unity or AIR and had used Objective-C for plugins and extensions, but this was my first pure Objective-C app for iOS.

Technologies used:

  • Objective-C
  • JSON/REST
  • Apple Maps API
  • Google Maps API