Thursday, September 08, 2011

The 2011 FOSS4G Map by Jason Sanford

If you’re like me, at any given time you’ve got a number of new software products you’ve been hearing about, but just haven’t had time to tinker with. A few weeks back Peter Batty asked if I’d be interested in creating an interactive map for the upcoming FOSS4G conference that will be here in Denver. This sounded like the perfect opportunity to try out some new open source geo tools.

I’ll start with a link to the map (http://2011.foss4g.org/content/foss4g-map) and tell you a little about how it works and what was used to create it. Visiting the site above displays a slippy map that you can pan and zoom like any other. The initial map shows four FOSS4G Venues as well as some light rail lines and stops to help you get around. As you zoom into the map you’ll see more information about bars, cafes, restaurants and even bicycle rental stations. Clicking these icons will show varying amounts of information in either a popup window or a small panel in the bottom left corner of the map.



All the pieces
The mapping library I’m using is Leaflet, from CloudMade. This is a great library that is very lightweight, easy to use, works great on mobile and most importantly, is open source. The core developer is very responsive to bugs and feature requests which is encouraging for those just getting started with Leaflet. If you haven’t checked out Leaflet yet or haven’t in the last few months, do yourself a favor and take a look. It’s grown by leaps and bounds lately and bugs are squashed often.

As I mentioned before the map shows various local amenities in the downtown Denver area. These come from OpenStreetMap and are periodically updated to keep the map fresh with updates from you. I’m sure you’ve all heard about OpenStreetMap. It’s awesome. End of story.

The OSM data is stored in PostGIS where we reference it for tile creation and map feature selection. PostGIS (/post’-jis/) is a spatial extension of the open source PostgreSQL database. PostGIS essentially adds spatial data types (geometry and geography) and lots (no really, hundreds) of functions to interact with these data types. If your data has a geometry question, PostGIS has one or more functions to answer it. PostGIS has installers for Windows and Mac and even has install packages for various linux flavors. It’s also not terribly hard to compile the source yourself. Even I’ve done this, once without cursing.

I’m creating map tiles with TileMill from Development Seed. TileMill is a browser based map design studio that can read from various data sources including shapefiles, KML, GeoJSON, PostGIS and GeoTIFF. With TileMill you create your map styles with Carto, a CSS-like map styling language that translates to Mapnik styles (correct me if I’m wrong) for super-fast tile rendering. Creating beautiful maps is so easy you’ll forget all about SLD. Recent updates include easy installation for both Mac OS X and Ubuntu (time to fire up the VMs windows users).

The product of a TileMill export is an mbtiles file which is an open spec for storing tiled map data in a SQLite database. This makes it much easier to transfer millions of map tiles to different locations as a single file, not the z/x/y.png directory hell that is the end result of most tiling jobs. I once vowed to quit map tiling efforts. Then I found TileMill. Anyway, we need a way to serve these tiles in this mbtiles format. Development Seed has another piece of open software for serving these, TileStream. You can download the source code for TileStream and build your own service or use a hosted solution for a fee and have your map tiles on a globally distributed CDN. Another solution, and the one I chose, is TileStache which python-based web application written by Michal Migurski that can serve and cache map tiles. With just a few lines of code you can tell TileStache where to find your mbtiles file, what URL to serve them from and where to cache the generated tiles.

Last but certainly not least is MapFish. MapFish is a Pylons (python) based application that lets you Create, Read, Update and Delete (CRUD) geographic features via HTTP POST, GET, PUT and DELETEs. For this application, I’ve extended MapFish to create a select service that simply runs multiple spatial queries against a few layers (bars, cafes, restaurants, bicycle rentals) with just one HTTP request. I’ve been using MapFish for a while now for a number of projects and highly recommend it.
Credit where credit is due
In addition to the projects above, there were a number of other resources used that deserve mention.
The OpenStreetMap data was downloaded from Geofabrik who graciously provide OSM data downloads to the state level updated daily. In my case it was very simple (and fast) to download just the data for Colorado. What an effort! Thanks Geofabrik.
The base map tiles come from MapQuest, who recently as part of their Open MapQuest efforts have released both street and aerial maps free for use, with pretty generous terms. Thanks MapQuest!
Speaking of OSM, our local Denver OSM Meetup Group have had a few recent efforts to help create a more accurate and complete map of downtown Denver. Thanks.
A note to local Denver folks: If you see a missing or incorrect bar, cafe, restaurant, etc in the map, update it in OpenStreetMap. I’ll be pulling fresh OSM data a time or two more before the conference.

About

I’m Jason Sanford. I work for Ubisense building web mapping applications for electric/gas utilities and telcos. Over the last few years working with geospatial technology I’ve found that some of the best help I’ve received came from bloggers simply documenting their experiences, challenges and solutions. My goal here is to do the same.


Check out all of Jason's articles at http://geojason.info/

No comments: