Skip to content

Instantly share code, notes, and snippets.

@manelclos
Last active December 29, 2015 12: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 manelclos/7672608 to your computer and use it in GitHub Desktop.
Save manelclos/7672608 to your computer and use it in GitHub Desktop.
Test case for Mapnik's Bug #2084

Test case for Mapnik's Bug #2084

Based on https://gist.github.com/springmeyer/7459452

Depends

  • Mapnik >= 2.3 and the python bindings

How to replicate

To replicate the bug run:

python render.py

You need to change the style in map.xml and the output file in render.py:

point.png is the reference image

shield1.png has dy=0 and the point is in the same place as point.png

shield2.png has dy=-10 and the point has moved some pixels up

shield3.png has dy=-30 and the point has moved the same pixels up as with dy=-10

I expect the point to always be in the same position

<Map
background-color="#eee"
srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<!-- polygon to frame the map testcase to m.zoom_all sets reasonable extents -->
<Style name="frame">
<Rule>
<PolygonSymbolizer />
</Rule>
</Style>
<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>
<!-- let's pretend the below exhibits some bug -->
<Style name="point">
<Rule>
<MarkersSymbolizer />
</Rule>
</Style>
<Style name="shield1">
<Rule>
<ShieldSymbolizer face-name="DejaVu Sans Book"
placement="point"
file="blue_point_8.png" >"test"</ShieldSymbolizer>
</Rule>
</Style>
<Style name="shield2">
<Rule>
<ShieldSymbolizer face-name="DejaVu Sans Book"
file="blue_point_8.png" dy="-10">"test"</ShieldSymbolizer>
</Rule>
</Style>
<Style name="shield3">
<Rule>
<ShieldSymbolizer face-name="DejaVu Sans Book"
file="blue_point_8.png" dy="-30">"test"</ShieldSymbolizer>
</Rule>
</Style>
<Layer name="layer" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<StyleName>shield3</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('shield3.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment