artemp/mapnik — Issue #476: PostGIS and queries containing quotes
Author: artemp
Created: 2011-10-11 16:21:11+00:00
State: open
Labels: Agg_Renderer

Mapnik 0.7, svn r1502.

Query in osm.xml file, works fine with postgis.input from debian sid (0.6.1-1):

{{{

(select way,aeroway,amenity,landuse,leisure,man_made,military,"natural",power,tourism,name
from planet_beosm_polygon
where landuse is not null
or leisure is not null
or aeroway in ('apron','aerodrome')
or man_made='pier'
or amenity in ('parking','university','college','school','hospital','grave_yard')
or military in ('barracks','danger_area')
or "natural" in ('field','beach','glacier','heath','mud','wood')
or power in ('station','sub_station')
or tourism in ('attraction','camp_site','caravan_site','picnic_site','zoo')
order by z_order,way_area desc
) as leisure

}}}

If I open postgresql console (added limit 10 and removed way column for convenience, the request works in both forms):

{{{
mapz@newbie:~/mapnik$ psql -d gis
Welcome to psql 8.3.7, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

gis=> select aeroway,amenity,landuse,leisure,man_made,military,"natural",power,tourism,name
gis-> from planet_beosm_polygon
gis-> where landuse is not null
gis-> or leisure is not null
gis-> or aeroway in ('apron','aerodrome')
gis-> or man_made='pier'
gis-> or amenity in ('parking','university','college','school','hospital','grave_yard')
gis-> or military in ('barracks','danger_area')
gis-> or "natural" in ('field','beach','glacier','heath','mud','wood')
gis-> or power in ('station','sub_station')
gis-> or tourism in ('attraction','camp_site','caravan_site','picnic_site','zoo')
gis-> order by z_order,way_area desc limit 10;
aeroway | amenity | landuse | leisure | man_made | military | natural | power | tourism | name
---------+---------+---------+---------+----------+----------+---------+-------+---------+------
| | forest | | | | | | |
| | | | | | wood | | |
| | forest | | | | | | |
| | forest | | | | | | |
| | | | | | wood | | |
| | forest | | | | | | |
| | forest | | | | | | |
| | forest | | | | | | |
| | forest | | | | | | |
| | forest | | | | wood | | |
(10 rows)

gis=>

}}}

When I try rendering with mapnik:

{{{
mapz@newbie:~/mapnik$ python getpdf.py
Traceback (most recent call last):
File "getpdf.py", line 34, in
mapnik.load_map(mapnik_map, mapfile)
RuntimeError: PSQL error:
ERROR: column "natural" does not exist
LINE 2: (select way,barrier,"natural",man_made from planet_beo...
^
Full sql was: 'select * from
(select way,barrier,"natural",man_made from planet_beosm_line where barrier is not null or "natural" in ('hedge','cliff') or man_made='embankment') as roads
limit 0'
(encountered during parsing of layer 'line features')

}}}

A temporary workaround for me is to copy postgis.input from debian binary package. That allows renderd to render everything as expected, but python segfaults then.