Tuesday, November 24, 2015

Too many annotations

As with all my previous parking app implementations, the problem of "too many annotations" is a tough nut to crack once again. It's been a while since my last post, so let me describe out some of the progress I've made.

Swift doesn't have a natively easy way to work with JSON. I found an open source package online called SwiftyJSON that did a lot of the leg work. With it I was able to quickly parse my JSON file.

Loading the JSON takes a long time, on the order of minutes. It made sense to save this data using Core Data. The first time the app runs it spends a long time parsing the JSON, but subsequent app loads are much quicker. There must be a way to not have to do any JSON parsing in my app, and instead do it offline and save that data directly into my app. Worth exploring.

This brought us to the current problem. Displaying the approximately 10,000 parking signs as annotations causes the app to perform extremely poorly. I would classify it as unusable. My first instinct was to do some sort of clustering. Unfortunately Apple provides no implementation of such a feature, so I tried out several open source packages before settling on kingpin. It works okay, but it's implementation makes it hard to customize the annotations. And frankly it actually isn't very fast anyway.

In my search for inspiration I happened upon an app called Plane Finder. This app displays commercial flights in semi real time, displaying a plane icon at the purported location of the actual plane. On screen at any time are upwards of 5,000 plane icons, which I assume are annotations with custom art. Although it never displayed as many points as I did at once, the app is clearly doing something interesting that causes it to be very performant. I emailed the company asking if they'd be willing to share their technique. To my surprise they actually replied, but declined to share anything.

I considered going an underground route and reverse engineering their app, in hopes of figuring out how they're accomplishing their impressive annotation performance. The worst part about going that route is the need to jailbreak my device, which I really don't want to do. There's also no guarantee I'd actually learn anything valuable, so it's a gamble on my time. And of course there's the whole legal and ethical boundaries I'd be tiptoeing.

In the meantime I can work on other aspects of the app.

  • App icon / logo. 
  • Improved splash screen
  • UI elements
    • pan to user's current location
    • pan to Santa Monica
  • Preprocessing JSON data and saving to Core Data

No comments:

Post a Comment