Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Last active December 28, 2015 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save springmeyer/7459452 to your computer and use it in GitHub Desktop.
Save springmeyer/7459452 to your computer and use it in GitHub Desktop.
Mapnik simplistic testcase starter

Test case for Bug #1

Depends

  • Mapnik >= 2.2 and the python bindings

How to replicate

To replicate the bug run:

python render.py

Then look at the bug.png and see how ____ is rendered wrong. Instead it should be ________.

<Map
background-color="#eee"
srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<Style name="point">
<Rule>
<MarkersSymbolizer />
</Rule>
</Style>
<Style name="frame">
<Rule>
<PolygonSymbolizer />
</Rule>
</Style>
<!--
frame is a layer with a single polygon that is used to ensure that m.zoom_all() will zoom the
map to a reasonable bounding extent to make the test easy to view with tools like nik2img.py
(which calls m.zoom_all() by default). Another approach in >= Mapnik 2.3.x is to just sent a
manual `extent` for the CSV datasource.
-->
<Layer name="frame" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<StyleName>frame</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline">
wkt|name
Polygon((-180.0 -85.0, -180.0 85.0, 180.0 85.0, 180.0 -85.0, -180.0 -85.0))|bounds
</Parameter>
</Datasource>
</Layer>
<!--
"bug" is a layer that should provide sample data that triggers the bug in question. It is
listed after the "frame" layer so that it renders on top and is visible.
-->
<Layer name="bug" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<StyleName>point</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline">
id|name|wkt
1|null island|Point(0 0)
</Parameter>
</Datasource>
</Layer>
</Map>
import mapnik
m = mapnik.Map(256,256)
mapnik.load_map(m,'map.xml')
m.zoom_all()
im = mapnik.Image(m.width,m.height)
mapnik.render(m,im)
im.save('bug.png')
@Andrey-VI
Copy link

How to upload an image to a gist?

@springmeyer
Copy link
Author

@Andrey_VI: git clone the gist and then add the image via git.

@Andrey-VI
Copy link

Thank you, Dane!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment