https://github.com/systemed/mapcss_ruby
MapCSS parser for Ruby
https://github.com/systemed/mapcss_ruby
Last synced: over 1 year ago
JSON representation
MapCSS parser for Ruby
- Host: GitHub
- URL: https://github.com/systemed/mapcss_ruby
- Owner: systemed
- Archived: true
- Created: 2011-08-03T23:48:47.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2011-10-13T22:38:52.000Z (over 14 years ago)
- Last Synced: 2025-01-31T12:49:44.402Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 242 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.txt
Awesome Lists containing this project
README
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:
ruleset=StyleParser::RuleSet.new(12,20) # 12 and 20 are min/max zoom levels
ruleset.parse_from_file('opencyclemap.css')
Create the parent object mappings from an OSMlib database:
dictionary = StyleParser::Dictionary.instance
dictionary.populate(db)
Then get the style for any OSM object like this:
entity=db.get_way(3044458)
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).