Sunday, April 16, 2017

MapBuilder: It's Back And Better Than Ever

CalTopo has been having some performance issues lately, no point in trying to pretend otherwise.

Behind the scenes, there two different platforms: a Python/Mapnik/PostGIS stack that powers MapBuilder and auto-routing, and a Java app for everything else.  MapBuilder has been struggling for a while, but lately that started bleeding over into the rest of the site's operations - as the number of pending MapBuilder requests grew and grew, the Java side of the house (which proxies the requests) would eventually get overwhelmed and pages would stop loading.  A week ago I rolled out a new server and a new copy of the MapBuilder database with fresh OpenStreetMap updates, and everything pretty much came screeching to a halt.

This left me in a bit of a pickle.  If I rolled the deployment back, things would temporarily improve, but my production environment would be out of sync with my new development laptop, which would make it harder to debug the issues and arrive at a permanent fix.  If I didn't roll the change back, fixing the problem would be a lot easier, but it would be a rougher ride until then.  I bumped the primary EC2 instance up to a $100/day m4.16xlarge to buy some slack, rolled up my sleeves, and got to work.

What followed was a blurry week of long hours, coffee, beer, testing in production, and marathon coding sessions that produced results brilliantly functional yet barely understandable when re-examined the next day.  Kind of like being a CS undergrad during end-of-semester crunch time.

At any rate, the MapBuilder rendering stack has been almost completely rewritten, sorry for any inconveniences over the past several weeks, and I'm confident at this point that the latest round of performance issues are solidly in the rear view mirror.  At least, confident enough to roll out two new features that were waiting on this.

First, as a subscriber-only feature (all levels), CalTopo now offers Retina/HiDPI tiles for most layers.  Rather than rendering out a separate 512px tileset, my server pulls 4 tiles from the next zoom level down and rolls them up into a single tile.  As soon as you sign in to your account, the map viewer will automatically pull 512px tiles instead of the standard 256px ones.  If this is problematic for some reason (requests get routed though my server rather than direct to S3, so there are potential speed implications), it can be disabled via the config menu - look for the "Retina/HiDPI" option at the bottom of the Display group.

The other big news is the addition of a "hybrid shading" option to MapBuilder, and a new prefab layer based on it named MapBuilder Hybrid.  Hybrid shading blends the green-gradient canopy shading used by MapBuilder Topo with aerial imagery, producing a backdrop that shows you much of the detail you'd get from imagery, but with less of the visual noise that makes it hard to pick out other map features.

MapBuilder Hybrid, Tuolumne Meadows.
Zooming in, you can make out individual trees, but they don't overwhelm the image or distract from the trails and contours.

Example from the Casacades

Produces a nice visual effect at wide zoom levels, too.

Admittedly I'm both biased and a little loopy from the past week, but I have the MapBuilder Hybrid layer loaded on a 4k monitor and I can't stop staring at it.  I've been wanting to add this for a while and am psyched to get it live, although this is an early version that will probably see stylistic tweaks over time.


  1. The MapBuilder Hybrid layer looks great, thanks for the hard work! This is going to be helpful, and will reduce the amount of toggling back and forth between the MapBuilder layer and the Google Satellite layer that I find myself often doing.

  2. Liking the new layer and performance!

  3. Matt,
    Your site upgrades never cease to amaze. CalTopo has kept getting better and, while I couldn't have anticipated it, many of the features added recently have quickly become indispensible. Thanks!

  4. Amazing site! I use it all the time! Great job!

  5. Love the layer visuals and performance. Is there any chance you can work out an arrangement with the folks at Locus to allow offline maps? I really love your work, and the Locus app is by far the best on Android.