Skip to content
gene-ressler edited this page Apr 3, 2014 · 17 revisions

Pippa - What is it?

Gem Version

Do you need to produce a simple map graphic showing locations of "stuff going on" nationally or internationally, with no dependency on third-party services? If so, Pippa is for you.

Pippa uses Lulu to optionally remove overlaps among markers with an algorithm better than other open source options. The example below shows typical results.

Usage

Create a map. Optionally change drawing parameters. Add dots of any area using pixel coordinates, latitude/longitude, and/or US zip codes for locations. Then fetch a blob usable as an HTML img tag source or else write to a file in any format ImageMagick supports (which is many!).

Maps also expose the underlying ImageMagick map image and provide access to both latitude/longitude to pixel coordinate conversion and the zip code database, which maps zips to latitude and longitude in addition to other interesting tidbits. This allows you to draw anything you like as an overlay, geocoded if you wish.

This is a very simple library. See the README on the repository home page for code examples. The embedded RDOC has more.

Note that the the Yard-generated docs at rubygems.org miss dynamically created methods that rdoc doesn't. Docs generated during local installation won't have this problem.

Sample output

A map of all the US zip codes. This is intentionally cluttered for testing purposes. West Point, NY and Berkeley, CA are in a second rendering layer. Sample output map produced with Pippa

License

While the author might easily be flexible on licensing, the base maps and associated configuration data are licensed by the University of California Regents. See the Licence file in the repo. Apparently they're "free use" unless you want to make a profit.

Possible enhancements

  • Volunteers welcome!

  • Merging dots to remove overlaps by agglomerative clustering is an interesting and surprisingly tough task. Doing it optimally by any commonsense metric is NP hard. A cool project for a rainy day. Update: It rained last weekend so the Ruby gem Lulu now exists to solve this problem.

  • The zip code data CSV file is about 3x the necessary size. But the extra fields might come in handy, so we're leaving them for now. Loading is slow, though. Up to 5 seconds on my old MacBook. Should we save a marshaled version and try loading that first? Update: Did this too, but it will only work if the application has write permission in the gem store.

Clone this wiki locally