Old wine jug becomes lamp/biosphere – locals fearful

I decided to rescue an empty bottle of Carlo Rossi and convert it into a self-contained ‘biosphere’, as well as a lamp. I Dremeled through the base of the jar to thread the wire through, and epoxied the whole thing shut. Now stuff is starting to grow!

At the lab, most people have expressed fear and trepidation at what will come of this experiment. The consensus seems to be that it will all die, and moldy putrified goop will become sentient and kill us all. I, on the other hand, continue to be optimistic.

SVG vs. Canvas

Well, SVG doesn’t scale well to large numbers of objects, but Canvas doesn’t scale well to large screens:

Performance with many objects

Here are the results of the first fruitful experiment, which clearly shows that SVG performance degrades quickly (exponentially on Safari?) in the number of objects, but Canvas performance remains at a near-constant low. This makes sense, since Canvas is just a bitmap buffer, while SVG has to maintain additional references to each object that it renders. Also, though not pictured, note that performance in clearing an SVG element also decreases in the number of drawn objects.

Performance on a large rendering context

Via Boris Smus

Serving ‘OSM-JSON’ alongside XML from the OpenStreetMap Rails port

OpenStreetMap.org‘s RESTful API allows anyone to access data on their continually growing collaborative map of the world… in XML. This is great for most applications, but if you’re working in JavaScript (as we are), XML might as well be greek. We need JSON.

To offer OSM-JSON along with of OSM-XML, we added a route to accept a “.format” suffix, and split up the render call based on the params[:format] part of the route:

# /config/routes.rb:46-50

map.connect "api/#{API_VERSION}/geohash/:geohash.:format", :controller => 'api', :action => 'geohash'
map.connect "api/#{API_VERSION}/geohash/:geohash", :controller => 'api', :action => 'geohash'

map.connect "api/#{API_VERSION}/map.:format", :controller => 'api', :action => 'map'
map.connect "api/#{API_VERSION}/map", :controller => 'api', :action => 'map'

Notice we also added a ‘geohash’ route. Whereas the /map call requires a bbox parameter (‘bbox=min_lon,min_lat,max_lon,max_lat’), we can use a geohash (Geohash in JavaScript, Geohash in Rails) which defines a bounding box as a sequence of letters and numbers. This fits Cartagen’s needs well, and since it doesn’t require any parameters, we can page cache it in Rails. (Remember that page caching bypasses Rails entirely, letting Apache handle these cached files at high speed – that saved us when we were on BoingBoing).

Continue reading “Serving ‘OSM-JSON’ alongside XML from the OpenStreetMap Rails port”

Cartagen 0.6.1 – Speed

We know we just released Cartagen 0.5 a couple weeks ago, but after testing it extensively in the wild, we really wanted a fast, low-resource release so that users of netbooks, older computers, and older browsers could use Cartagen too.

So, as well as including some general cleanup, this version hums along on a variety of machines. Please send feedback on speed/load times/CPU usage, etc; we tested it on an 800mhz G4 iMac and while it wasn’t super responsive, it did load and was somewhat usable in Firefox 3.5. For reference, Hulu.com’s Flash player does not run on that machine. On more powerful machines (4x3ghz Intel Xeon, 2500×1600 monitor), it can load over 10,000 objects in the viewport without hiccuping. For most users, a typical browser window size yields a responsive and reasonably low-resource experience.

Download Cartagen 0.6.1 (We did 0.6 and just rushed directly into 0.6.1 before announcing.)

There’s definitely a lot more we can do to improve speed, but for now we feel good about our optimizations. We identified the high CPU usage as generally poor management of timers in JavaScript, and wrote a TimerManager class which adjusts its timer intervals automatically, easing the CPU load. We elected to maintain a relatively high CPU usage to keep things rendering smoothly, but users of TimerManager can ‘turn up the heat’ or turn down CPU usage by tweaking a ‘spacing’ parameter. We also broke more intense tasks up by creating a TaskManager class, which preserves UI responsiveness and framerate while staying in a single JavaScript thread. We plan to use the multithreaded, asynchronous Web Workers spec in HTML5 when available, but for now we wanted to work on older hardware/software.

We hope that TimerManager and TaskManager will be of use to others working with JavaScript animation and we’ll be packaging them up separately for download.

For now, look at http://code.google.org/p/cartagen for source and http://wiki.cartagen.org for update docs.

Warcraft map stylesheet for London

So this is an accurate (in terms of coordinates) map of London, generated from OpenStreetMap data:

[field name=”iframe”]

You can pan around quite a bit and use the scroll wheel to zoom. To achieve this, I created the following geographic stylesheet:


The map is built on Cartagen, a mapping framework for viewing and geographic data in a dynamic, personally relevant way. Cartagen uses the GSS (Geo Style Sheet) format, which allows users to design maps with CSS-like styles. Learn more at Cartagen.org and the Cartagen wiki, or download the source at Google Code.

Go to Cartagen.org to view anywhere in the world through this stylesheet.


Quick update: some users (read: most) are having trouble zooming in and out! This is because of a known last-minute bug in the 0.6 release of Cartagen, and only affects maps embedded in other pages. It does not affect cartagen.org. For a quick fix, to zoom you can also hold down the ‘z’ key and drag up and down on the map.
Followup update: zooming with the scroll wheel should work now. Thanks for your patience!