mapnik-org/mapnik — Issue #762: Expressions with enum types in postgis do not work
Author: artemp
Created: 2011-10-11 08:11:15+00:00
State: open
Labels: Core_Library

When using postgis enum types as filter expression, no feature is drawn on the map:

{{{
CREATE TYPE alert_level AS ENUM (
'yellow',
'orange',
'red'
);
}}}

{{{

CREATE TABLE test_mapnik_enum (
id integer NOT NULL,
test_column alert_level,
geom geometry -- created by addgeometry
);

}}}

And the Python code:

{{{
import mapnik2 as mapnik
proj4 = '+proj=utm +zone=30 +ellps=intl +units=m +no_defs'
ds=mapnik.PostGIS(dbname='sigym3-dev',table='test_mapnik_enum')

r=mapnik.Rule()
r.symbols.append(mapnik.PointSymbolizer())
r.filter=mapnik.Expression('''[test_column] = 'red' ''') #### NOT WORKING
s = mapnik.Style()
s.rules.append(r)

lyr = mapnik.Layer('world',proj4)
lyr.datasource=ds
lyr.styles.append('My Style')

m=mapnik.Map(200,200,proj4)
m.append_style('My Style',s)
m.layers.append(lyr)
m.zoom_all()
m.layers[0].srs=proj4
m.zoom_all()
print m.envelope()
mapnik.render_to_file(m,'world.png', 'png')

}}}

If I omit the filter, the points in the table show fine.