mapscript layer.setFilter()
David Niergarth
dn at HDDESIGN.COM
Thu Aug 2 13:33:48 PDT 2007
Hello,
I have a Python mapscript layer that works fine under mapserver 4.8.3 (Ubuntu
Edgy w/ postgresql 8.1) but fails under mapserver 4.10.0 (Ubuntu Feisty w/
postgresql 8.2). The problem happens when trying to set a filter on a layer.
layer_obj.data = "the_geom from tbl_people_points"
layer_obj.setFilter(
"idpeople in (select idpeople from tbl_request_%s) and quality=0"
% idrequest
)
Under 4.8.3, the subquery in the filter works just fine. Under 4.10.0, however,
the filter string is ending up truncated as 'idpeople in '.
Here's are a couple simple filters that still work under 4.10:
layer_obj.setFilter("idpeople = 10")
layer_obj.setFilter("idpeople = 10 or idpeople = 4")
And here are a couple simple queries that get truncated under 4.10:
layer_obj.setFilter("idpeople <= 10")
# For this query, layer.getFilterString() returns 'idpeople '.
layer_obj.setFilter("idpeople = 10 or (idpeople = 10)")
# For this query, layer.getFilterString() returns 'idpeople = 10 or ')
All the queries above work under 4.8. The truncation in 4.10 leads to an
obvious SQL syntax error, which is the error I'm seeing reported by Python
mapscript. Oddly, I'm not seeing these queries show up in my postgres log --
but maybe that's a log-level thing.
Does anyone know what might have changed between 4.8 and 4.10? Or is this
perhaps a bug in 4.10?
Thanks for any ideas,
--David
# Add people_points layer.
layer_obj = mapscript.layerObj(map_obj)
layer_obj.connectiontype = mapscript.MS_POSTGIS
layer_obj.name = 'people_points'
layer_obj.connection = "user=pgsql host=%s dbname=%s port=%s" % (
host, dbname, port)
layer_obj.data = "the_geom from tbl_people_points"
layer_obj.setFilter(
"idpeople in (select idpeople from tbl_request_%s) and quality=0"
% idrequest
)
layer_obj.status = mapscript.MS_ON
layer_obj.type = mapscript.MS_LAYER_POINT
layer_obj.transparency = 50
c = mapscript.classObj(layer_obj)
c.name = 'Members'
s = mapscript.styleObj(c)
s.color = mapscript.colorObj(255, 0, 0)
s.outlinecolor = mapscript.colorObj(255, 0, 0)
s.symbol = map_obj.symbolset.index('circle')
s.size = 8
More information about the MapServer-users
mailing list