Skip to content
MapCSS parser for Ruby
Latest commit 4e2e332 Oct 13, 2011 @systemed Use a simple hash by default, and only use the binding if an eval is …
…involved. Typically halves the time required to render a map.
Failed to load latest commit information.


Ruby MapCSS parser

This is an experimental Ruby parser for MapCSS 0.2, based on the Halcyon parser.

== Dependencies ==

You'll require Jochen Topf's OSMlib library. We use the Node, Way and Relation objects from this. Unlike Halcyon, OSMlib doesn't keep track of 'parent' objects, so we have a singleton Dictionary class to store this mapping.

== How to use ==

Install style_parser and style_parser.rb into a lib/ directory. Require style_parser as usual.

Read a MapCSS file like this:,20)					# 12 and 20 are min/max zoom levels
Create the parent object mappings from an OSMlib database:

	dictionary = StyleParser::Dictionary.instance

Then get the style for any OSM object like this:

	stylelist=ruleset.get_styles(entity,entity.tags,14)		# 14 is the target zoom level
	puts stylelist

You can see an example of this in osm_test.rb.

== Limitations ==

- It hasn't really been tested at all.
- The test stylesheet is MapCSS 0.1. That's not too helpful. ;)
- Setting tags from the stylesheet doesn't yet work.
- Any limitations of Halcyon's parser are also present here.

== Licence and author ==

WTFPL. You can do whatever the fuck you want with this code. Code by Richard Fairhurst, summer 2011.

Example files: OpenCycleMap Potlatch 2 style by Andy Allan, Charlbury OpenStreetMap data by OpenStreetMap contributors (CC-BY-SA).
Something went wrong with that request. Please try again.