This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

pycnik

A simple Translator from Python code (with coding conventions) to Mapnik XML stylesheet.

  • features:
    • allow using exotic number of zoom levels and tile sizes (computes scales denominators)
    • provides a mechanism for inheritance
    • automatically add cache-feature attribute when using more than 2 styles
  • caveats:

Install Pycnik

$ git clone https://github.com/Mappy/pycnik.git
$ cd pycnik
$ python setup.py install

Or via pip:

$ pip install pycnik

Dependencies:

  • python-mapnik (mapnik >= 2.x)
  • lxml

Testing

Dependencies:

$ pip install -r requirements/test.pip

To run the tests with nose:

$ nosetests -v

Getting started

Pycnik uses dynamic variable declaration, so you have to use the same keywords as the xml declaration syntax.

example.py:

from pycnik.model import *

BACKGROUND_COLOR = 'rgb(255,255,220)'

NATURAL_RASTER = {
    "type": "gdal",
    "file": "natural_earth.tif"
}

DATABASE_PARAM = {
    "dbname": "database",
    "estimate_extent": "true",
    "host": "0.0.0.0",
    "password": "******",
    "port": "5432",
    "type": "postgis",
    "user": "mapuser",
    "srid": "4326",
}

################
# MAP DEFINITION
################
Map.background_color = BACKGROUND_COLOR
Map.srs = "+init=epsg:4326"
Map.minimum_version = "2.0"
Map.font_directory = "fonts"
Map.buffer_size = 128

########
# LAYERS
########
natural_earth = Layer("natural_earth")
natural_earth.datasource = NATURAL_RASTER

bnd = Layer("country boundaries")
bnd.datasource = DATABASE_PARAM
bnd.table = "schema.boundaries"

########
# STYLES
########
natural_earth.style()[:3] = {
    RASTER: {
        'scaling': 'bilinear'
    }
}

bnd.style("blue")[0:19] = {
    LINE: {
        'fill': 'rgb(255,0,0)',
        'stroke-width': '4'
    },
    'filter': "[countrycode]='ESP'"
}

# change the stroke width from level 10 to 15
# the `filter` and `fill` attributes are preserved
bnd.style("blue")[10:15] = {
    LINE: {'stroke-width': '12'}}

You can see more examples in the test/resources directory.

Generate mapnik XML

$ pycnik example.py -o example.xml

Changelog

1.4 (2015-02-23)

  • fix compute_scales for WGS84

1.3.2 (2012-12-05)

  • allowing any attributes for layer tag

1.3.1 (2012-10-25)

  • Updated documentation

1.3 (2012-10-04)

  • Removed “zoom” comment in tag scaledenominator (for mapnik 2.1)
  • More tests

1.2 (2012-09-11)

  • Added copy_style() helper

1.1 (2012-09-10)

  • Support many symbolizer with the same type in rule
  • More tests

1.0 (2012-08-07)

  • Initial release
Release History

Release History

1.4

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.3.2.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pycnik-1.4.tar.gz (10.8 kB) Copy SHA256 Checksum SHA256 Source Feb 23, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting