Wednesday, June 17, 2015

GeoSpatialKit - A suggestion for Apple

I spent last week at WWDC in San Francisco.  Not too much new, but I saw a lot of performance and optimization in iOS9.  I spend a lot of time on those myself, so I approve.

But Apple's geospatial support is still... mediocre, particular given what they must be paying for the map.  I got to thinking:  What would make geospatial display work better on iOS and OS/X?

First, what am I talking about?

Geospatial Is....


Geospatial data display is maps and globes.  A weather app is a geospatial app, as is any sort of map app and so is an Atlas.

Globe, map.  Map, globe.  Same thing.

Geospatial is what I do.   I make a popular toolkit for map and globe data display on iOS (and <cough> Android </cough>).  Presenting geospatial display to developers in a way they can handle is what I do.

And that leads to the important question:  What's wrong with the way Apple does it now?

The Current Situation on iOS (and OS/X)


Let's use weather as an example.  Everyone loves (or hates) their weather app.  In any case, they have an opinion.  So how do you make a serious weather app, with animated radar and such?

You build a serious weather app in one of two ways:  Core Graphics or OpenGL ES.  You can tell which was used immediately.  Is it a little weird and janky (Core Graphics) or smooth and pretty (OpenGL)?

Why that is has a little to do with rendering and a lot to do with data management.  The way you display 20 pins in UIViews is not the way you render 20 layers of animated streaming radar data.

And okay, that's a hard case, but it's also plain old map apps that are kind of 'meh' under Core Graphics.  There's another reason for that.



MapKit Under Glass


The Maps App is a big, capable and (I imagine) very expensive system.  It does a lot and it's pretty good at it.  MapKit looks to be a sort of wrapper on top of it.  That's a problem.

Hands up.  Who's reimplemented that compass?

You can't change the bulk of what MapKit is displaying.  Sure, you've got a few knobs to twiddle and you can toss a little of your data on top, but only grudgingly.   But there's an even bigger issue.  MapKit was obviously (obviously!) written with OpenGL ES, but none of that infrastructure is available to the rest of us.

So here's the question.  If you scooped out MapKit's brains and made neat little piles, what would that (unfortunate metaphor) look like?

CATiledLayer Revisited


I think you'd start with CATiledLayer, the go-to data structure for the pre-OpenGL map era.  As a reminder, CATiledLayer will break the world into little pieces and tell you when to load those pieces.

Something like this

A new CATiledLayer is a good place to start, but it's probably a bit low level and it's missing one giant thing: A Spatial Reference System.

Adding an SRS to a CATiledLayer(-like thing) would solve the first set of problems.  Your data could exist in one system while displaying in another.  I'd also make the levels and loading strategies explicit with budgets for tiles and such.  And threads everywhere.  EVERYWHERE.

One tile loading strategy

That helps with loading, but what do you do once you've got that little image or basket of vectors for a tile.  How do you render it fast?

With Core Graphics, you really don't render it fast.  And the layer based image solutions are kind of weak.  It's time to drill a hole in UIKit and plunge into the icy waters of OpenGL ES.

Images, Vectors, and Shaders - Oh My!


Most of what you want to display on a map is pretty simple:  Image tiles, symbols, text, lines, and polygons.  All pretty easy to display slow, but hard to render fast.

Sometimes a map is just a map

Here's what you do.  You develop a little system for abstracting those object types to hand to a renderer.  Then let the system manage them, batch them and move them around.  Essentially you've moved the developers job off into other threads:  Just load the data and let the system handle it.

This is suspiciously similar to what I do in WhirlyGlobe-Maply.

What About The Globe?


Well, yes, everyone loves the globe; even developers who should know better.  User interaction with a globe is just different from a map and switching between the two makes life harder than it needs to be (looking at you MapKit).

Globe + Weather = Awesome

But the globe is cool, so where do you put it?  SceneKit.  SceneKit is where you put it.

Pull the tile loading logic from CATiledLayer++ above, make a nice globe surface and voila!  You can reuse most of what you build for the 2D maps.  Sure, it's a little more work to set up SceneKit and live in OpenGL-land.  But globe.

Aaaaand back to MapKit


Okay, so you've built up a nice rendering infrastructure for map tiles, vectors, symbols and other such stuff.  It gets along with both UIViews and SceneKit.  But does it use anything from MapKit?  It also begs the question:  Should you rewrite MapKit in this stuff?  

No.  Good grief, no.  Only interns and the criminally insane rewrite working systems for the hell of it.  Instead, you steal data from the map.

Nothing personal, Santa Rosa

Apple Maps has a number of interesting data layers it would be fantastic to reuse in other apps:  Roads, water, symbols, land, parks, and labels to name a few.  Especially labels, which would make one of my dreams come true:  Putting the @%&#@ labels on top of the animated radar.

Map Data Reuse


Mere mortals can't reuse Apple Maps data... but Apple could.  If they started teasing it apart and tossing it into a system like I've described above, it would make maps apps that much more interesting.  And yes, the label thing, which bugs me a lot.  Seriously, that's annoying.

Missouri?  Maybe?

This would also let us mix and match data from varying sources.  There are some excellent map tiles out there and I'm sure Apple could come up with a few more of its own that don't quite belong in what they've got now.

Wrapping it Up


I've skipped over a few details, but here's the basic story.
  • Add a Spatial Reference System for selected layers
  • Soup up CATiledLayer for some serious tile management
  • Drill a hole down to OpenGL ES (and/or Metal) for some decent primitive display.
  • Globe meet SceneKit.  SceneKit, globe.
  • Start pulling data layers out of the map source.

Do that, Apple, and you've got yourself some seriously reusable geospatial display support.  It would be interesting to see what came of it.

Actually, feel free to not do that.  It would put a crimp in my WhirlyGlobe-Maply business.

Sunday, June 7, 2015

WhirlyGlobe-Maply Contract Job

I've got a short term contract available for the right person.  I need you to run through the tutorials, looking for errors.


The best thing about this:  You don't have to be an iOS expert!  In fact, it's better if you're not.

Tutorial Checker


The WhirlyGlobe-Maply tutorials have been a huge boon to beginning users.  But I suspect some of them have errors and spots that are difficult to follow.  I know of a few, but I'd like to find the rest.

That's where you come in.  As a Tutorial Checker you need to have the following:
  • Appropriate Apple hardware and Xcode already installed.
  • Some experience building at least a test app for iOS.
  • Excellent English skills.
  • Be in the US.  I'm not sure how to legally pay people outside the country.
If you've just wrapped up one of those six week code academy things for mobile, that would be absolutely perfect.

What's Next


If you're interested, drop me a line.  You can find my contact info on the WhirlyGlobe-Maply page.  Let me know what your development qualifications are (they can be thin) and we'll talk.

Friday, June 5, 2015

mousebird consulting Needs YOU!

I'm hiring.  If I can find the right person.

It's not relevant, I just like this image.

What We Do


You can read the web site yourself, but here's the tl;dr.  

We do high performance geospatial display for mobile devices.  Our customers include National GeographicForecast.IO and many others.  Our code burns millions of battery hours on millions of devices all over the world.

At any given time we're working on apps in weather, aerospace, education, and mapping.  And lately, all of them.  At once.

What It Is


I need another software developer, primarily.  These are the areas we work in.
  • OpenGL (ES or not)
  • iOS Development, Objective-C
  • Android Development, Java
  • User Interface development
  • C++
  • Geospatial data processing: GDAL, OGR, Proj.4
  • Data processing on Amazon ec2

If you have experience in any three of those, that would be interesting.  If you have experience in all of them... you're probably too expensive, but let's talk.

Where It's At


I'm in San Francisco.  If you are too, you can share the office.  Yes, an actual office with a door and everything.

If you're remote, that's fine.  Our clients are scattered around the world and don't visit much (sniff).  You have to be in the US, though.  I barely understand my own country's employment laws as it is.

What Is Next


Send me a resume, or your github profile, of Snapchat some code or something.  Just let me know if you're interested and we'll figure it out.

I'm open to part time, just returning to the work force, that sort of thing.  The mobile development market is red hot right now and I'm willing to be flexible.

Wednesday, June 3, 2015

Mapzen Vector Tile Service

Let's take a look at Mapzen's vector tile service.  They've recently announced a developer program and done a lot of work behind the scenes.

Sea levels aren't rising!  Shut up!

Vector Tiles


Mapzen is processing the OpenStreetMap planet file into nicely addressable vector tiles.  They provide the recipes for doing this yourself, but my attitude is better their Amazon account than mine.



Of the formats they offer, WhirlyGlobe-Maply supports two:  GeoJSON and PBF (aka Mapbox Vector Tiles).  I prefer the latter.

PBF (or MVT) contains compressed vector data with general attribution.  To make something visual, you have to match the attributes to a style.  In the past I've used Mapnik XML for this, but this time I've gone with something different.

Mapbox GL Style Sheet


Mapbox has been busily developing (yet another) styling format for their vector tiles.  The new format is nicely tuned to display rather than offline rendering.

The main disadvantage with the new format is there's no way to generate the damn things; you just have to edit the JSON directly.  I imagine we're all hoping they'll update Mapbox Studio one of these days.

OSM loves footpaths

But I like the format and it's clearly where this part of the open source community is going.  So I added a parser to WhirlyGlobe-Maply.

Mapzen Data + Mapbox Style + WhirlyGlobe-Maply


We've got the vector data from Mapzen, a style sheet in the Mapbox format and a big real time rendering toolkit.  How hard is it to put it all together?

Not hard at all.  There's a standard tiling loader (not shown) that will read it on the fly (in multiple threads).  We just have to set up the MapzenSource which involves..
  • Reading the MapzenGLStyle file.  It's in the local bundle.
  • Setting up the cache directory, so we're not always hitting Mapzen.
  • Specifying the base URL and API key for forming the Mapzen URL.
  • Picking the layers we want.  All of them in this case, but we could be selective.
  • Using PBF (MVT) for the source and Mapbox GL for the style.

Yup, it really is that simple.  I've been messing around with vector tiles for years now.  I've got it down.

This code is in the WhirlyGlobeComponentTester app in the develop branch on github.  I suggest using it in 2D mode.  Things get a little weird on the globe at lower resolutions.

Performance & Next Steps


It's pretty good on the device.  You could use this in a shipping product.  The style is a little bland, but it's fine for a demo.  Rendering performance is decent, but could be optimized.

Needs more labels
Mapzen's set things up so you can fetch individual layers.  I think it would be interesting to use, say the symbol and labels on top of one of NASA's live data sets.  Somebody go do that and let me know how it looks.

Saturday, May 30, 2015

State -o- The Business and Conferences Galore

I run a little consulting company called mousebird consulting inc. [yep, all lowercase]  We do development on and around the WhirlyGlobe-Maply toolkit.  This pushes new features in the toolkit and, ya know, pays the bills.

[Put gratuitous graphics here]

The toolkit brings in leads, I pursue them, clients sign contracts and invoices are paid.  It's a pleasant arrangement when it's chugging along.

So How's Business?


It's chugging along.  I logged my best month ever in January.  Then I did it again in February and April.  That was a ton of WhirlyGlobe-Maply work, some neat apps, and lots of great new features in 2.4.

The down side is my backlog.  I haven't had much time to track down problems for users who aren't clients, write new documentation, or make the Android version easier to install.

If you need some of my attention, the best way is a support contract.  I have a few of those now and I like how they're playing out.

Conferences


Another downside of so much paying work is a dearth of presentations.  Good ones require time to write and I have no time.

Even so, I'll be on a panel for State Of The Map 2015 in New York next week.  I'll also be at WWDC in San Francisco the next week.  If you want to get together at either, drop me a line.

Monday, April 20, 2015

Old App: FlyQ EFB

Purple rectangles are common at altitude
This is an oldie, but I've just gotten permission to disclose it.  Introducing FlyQ EFB from Seattle Avionics.

Seattle Avionics is actually one of my oldest clients and theirs are among the most complex WhirlyGlobe-Maply apps around.  I've finally talked them into going public with their support for open source!

FlyQ EFB


For those of you unfamiliar with aviation terms (guilty) EFB stands for "Electronic Flight Bag."  

Pilots used to haul a ton of paper charts around and do all sorts of complicated things with them.  PCs and specialized devices replaced much of that and now commodity tablets are changing things again.  Just like in other markets.

If you've ever wondered why WhirlyGlobe-Maply seems to have so many aviation-friendly features, now you know.

Maps, Globes, and True 3D


In FlyQ EFB WG-Maply is largely used as a map.  Even though it's on a globe, everything is plastered to the surface and interactions are almost entirely map like.  

Don't let me anywhere near the controls of a plane.

All of the objects you see on the globe are standard things like screen markers, labels, image layers and so forth.  Organizing the data and passing it to WG-Maply is accomplished in the app, and I can assure you, that's the hard part.


Orange is bad.  It's not orange's fault.

There's also a true 3D mode which is meant to resemble what a pilot might actually see with certain caveats (Look out the window, fool).  This is a little further afield of what WG-Maply is meant for and is tied much more tightly to their app.

Smart Plates & Charts


Seattle Avionics has another app called SmartPlates & Charts.  Think of it as a simpler sibling to FlyQ EFB.  If you're just curious, I'd start here.


It's great to be publicly welcoming Seattle Avionics to the open source family!  If any of you other lurkers want to fess up, let me know.

Thursday, April 16, 2015

New App: National Geographic World Atlas

WhirlyGlobe-Maply is now at the heart of the National Geographic's World Atlas iOS app.

And why not Belgium? (tm)


I plan on being insufferable for a week and then smug for another two months.

The App


It's gorgeous, just go buy it.  You may already have it, lots of people do.  NatGeo provided 4.0 as an update, which is really nice of them actually.



The Technology


There's some really interesting stuff going on with the globe.  For instance doesn't that text look suspiciously... sharp?

Did you know Vatican City is its own country?  Of course you did

We'll talk more about the process later, but let's just say it involves: PDF, Mapbox, hybrid raster/vector tiles, on-device font glyph rendering and lots of math.  Getting that classic NatGeo map look on mobile, but better, was interesting.

The People


I just did the globe.  Rally Interactive did the bulk of the user interface and it's gorgeous.  Mapbox helped out on the data processing and storage side.  National Geographic did some of the development and all the data (of course) as well as the project management.  That last one was some serious work.

That'd hurt if you picked it up.

It was a pleasure working with Rally and NGS.  It's a hell of an app and I hope the users love it.