problems with FILTER string in PostGIS layer
Pietro Giannini
pgiannini at BYTEWISE.IT
Tue Jul 18 07:53:31 PDT 2006
Hi all,
I'm running a query aginst a PostGIS layer via the FILTER attribute of the
layer.
I'm dinamically changing the FILTER attribute via PHP MapScript.
I must filter the features via a sql statement like "WHERE [field] IN
([comma-separated list of occurrences]).
here relevant part of *.map file:
layer
name "pg_distretti_an"
connection "user=postg password=postg dbname=geodb host=localhost
port=5432"
connectiontype postgis
data "the_geom FROM distretti_tot"
status off
type polygon
tolerance 3
template 'templates/coords_query_template.html'
debug on
#
projection "init=epsg:32632" end
#
class
name 'distretti'
style
outlinecolor 50 125 50
color 255 255 0
end
end
end
mapscript:
$string = "DISTRETTO
IN('0737','0742','0743','0744','0746','0761','0763','0765','0766','0771','0773','0774','0775','0776','0781','0782','0783','0784','0785','0789','0823','0824','0825','0827','0828','0831','0832','0833','0835','0836','0861','0862','0863','0864','0865','0871','0872','0873','0874','0875','0881','0882','0883','0884','0885','0921','0922','0923','0924','0925','0931','0932','0933','0934','0935','0941','0942','0961','0962','0963','0964','0965','0966','0967','0968','0971','0972','0973','0974','0975','0976','0981','0982','0983','0984','0985')";
$layer->setFilter($string);
All works ok, but where the FILTER string exceed the length of 255 and MS
is displayed only a part of the map (function map->zoompoint() invoked)
the MapServer answer is:
____________________________________________
Warning: [MapServer Error]: prepare_database(): Error executing POSTGIS
DECLARE (the actual query) statement: 'DECLARE mycursor BINARY CURSOR FOR
SELECT
distretto::text,asbinary(force_collection(force_2d(the_geom)),'NDR'),gid::text
from distretti_tot WHERE ("DISTRETTO
IN('010','011','0121','0122','0124','0125','0131','0141','0142','0143','0144','015','0163','0165','0171','0172','0173','0174','0175','0182','0183','0184','0185','0187','019','02','030','031','0321','0322','0323','0331','0332','0341','0342','035)
and (the_geom && setSRID( 'BOX3D(589741.961712017
4695052.44517138,916455.321123285
4901133.17969)'::BOX3D,find_srid('','distretti_tot','the_geom') ))'
Postgresql reports the error as 'ERROR: unterminated quoted identifier at
or near ""DISTRETTO
IN('010','011','0121','0122','0124','0125','0131','0141','0142','0143','0144','015','0163','0165','0171','0172','0173','0174','0175','0182','0183','0184','0185','0187','019','02','030','031','0321','0322','0323','0331','0332','0341','0342','035)
and (the_geom & in C:\ms4w\apps\contatti\italia_pg_contatti.phtml on line
294
____________________________________________
Effectively the query string apppears to be truncated at the 255th byte.
Is that a limitation of MS?
Somebody can help me?
Thanks in advance.
Pietro Giannini
More information about the MapServer-users
mailing list