Cascading Sheets Of Style for Mapnik
Python
Latest commit 82f6685 May 24, 2014 @mojodna mojodna Ignore test output
Permalink
Failed to load latest commit information.
cascadenik Remove text-force-odd-labels May 23, 2014
data Bumped to 2.6.2 with elimination of local dependency on test.shp for … Nov 17, 2012
doc styling a thematic map from remote geocommons geojson Dec 14, 2010
openstreetmap use default prefix in 'remapniking osm' style Aug 19, 2010
.gitignore Ignore test output May 24, 2014
AUTHORS.txt Added proper CHANGELOG and AUTHORS entries, made a new release Nov 27, 2010
CHANGELOG.md update dash array and requirements into the CHANGELOG Mar 28, 2013
INSTALL.md Moved README to markdown and added a note about running tests May 2, 2012
LICENSE.txt update License date Jan 4, 2010
MANIFEST.in set up for Cascadenik 0.1.0 release May 2, 2010
Makefile Moved the One True Copy of the version number to cascadenik.__version__ May 29, 2012
README.md Added sample variables to README May 29, 2012
cascadenik-compile.py Bumped to version 2.6.0 with addition of --style option to cascadenik… Nov 17, 2012
cascadenik-extract-dscfg.py Renamed special parameter 'base' to 'template' in datasource config t… Sep 26, 2010
cascadenik-style.py make cascadenik-style.py executable Dec 8, 2010
example.cfg Handle local overrides from a config file for datasources. Sep 26, 2010
example.mml to_mapnik now includes datasources. Tests pass - we need a local shap… Sep 26, 2010
example.mss oop Sep 3, 2008
example_dscfg.mml Handle local overrides from a config file for datasources. Sep 26, 2010
requirements.txt List cssutils as a dependency Mar 28, 2013
setup.py Setuptools doesn't actually have a clue how to install PIL Jun 10, 2012

README.md

Cascadenik

Cascadenik implements cascading stylesheets for Mapnik.

It’s an abstraction layer and preprocessor that converts special, CSS-like syntax into Mapnik-compatible style definitions. It’s easier to write complex style rules using the alternative syntax, because it allows for separation of symbolizers and provides a mechanism for inheritance.

Cascadenik supports many of Mapnik’s features in a simple declarative form:

/* Define a few colors */
@black: #000;
@orange: #f90;

/* Start with a white background */
Map
{
    map-bgcolor: #fff;
}

/* Draw roads as orange lines */
#roads
{
    /* Usually, 3px wide */
    line-width: 3;
    line-color: @orange;

    /* Make the important ones wider */
    &[kind=major] { line-width: 4 }
    &[kind=highway] { line-width: 5 }

    /* Add the road names in black */
    name
    {
        text-placement: line;
        text-face-name: "DejaVu Sans Book";
        text-fill: @black;
        text-size: 12;
    }
}

See more examples at https://github.com/mapnik/Cascadenik/wiki/Examples.

Usage

See INSTALL.md for installation instructions.

See the doc/ folder for more usage examples.

Unroll the rules in example.mss and show their cascade order:

% cascadenik-style.py example.mss > example-ordered-unrolled.mss

Compile example.mml into a Mapnik-suitable XML file:

% cascadenik-compile.py example.mml example-compiled.xml

Render a MML file directly to an image using nik2img.py:

% nik2img.py example.mml example.png