[gdal-dev] WFS and -where with non-ASCII characters

Rahkonen Jukka Jukka.Rahkonen at mmmtike.fi
Tue Jan 3 05:34:06 EST 2012

Even Rouault <even.rouault <at> mines-paris.org> writes:

> On Windows, there might perhaps be a problem with the shell passing strings in
> the local code page (CP1252 or whatever variant of it that is used in
> Finland), whereas the WFS server perhaps expect it to be UTF-8. I'm not sure
> which encoding we are supposed to send through Filter Encoding in KVP, and I'm
> not sure how it is escaped (or not) currently. But if it works with Linux, it is
> likely not an escaping problem, but one related with the encoding. Sending the
> Filter Encoding as a POST content will likely get rid of the encoding problem
> from a theoritical point of view, but there would still be the problem of
> Windows passing non-UTF8 strings to the command line utilities

POST method has been reliable for me both with GIS clients or when sending
requests through Firefox and Poster.
> Jukka, I have not the means of checking for now (behind corporate firewall that
> blocks your servre). But perhaps you could try with the following OGR Python
> script :
> from osgeo import ogr
> ds = ogr.Open('WFS:http://hip.latuviitta.org/cgi-bin/tinyows')
> lyr = ds.GetLayerByName('lv:pks_tilastoalue_piste')
> lyr.SetAttributeFilter("name='Hämeenkylä'")
> feat = lyr.GetNextFeature()
> feat.DumpReadable()
> The python shell should send UTF8 strings to GDAL.

Error is about the same as with ogr2ogr

>>> ds = ogr.Open('WFS:http://hip.latuviitta.org/cgi-bin/tinyows')
>>> lyr = ds.GetLayerByName('lv:pks_tilastoalue_piste')
>>> lyr.SetAttributeFilter("name='Hämeenkylä'")
>>> feat = lyr.GetNextFeature()
ERROR 1: Error returned by server : <?xml version='1.0' encoding='UTF-8'?>
 xsi:schemaLocation='http://www.opengis.net/ows http://schemas.opengis.net/ows/1
 version='1.1.0' language='en'>
 <ows:Exception exceptionCode='MissingParameterValue' locator='request'>
  <ows:ExceptionText>QUERY_STRING contains forbidden characters</ows:ExceptionTe

>>> feat.DumpReadable()

I do not know if this is TinyOWS error but Mapserver 6.0 is not happy either. It
gives me http 500 error with browser

ogr2ogr -f "ESRI Shapefile" -spat 377346 6673628 392155 6684806 test.shp
pks_tilastoalue_piste -where name='Hämeenkylä'
ERROR 1: HTTP error code : 500
ERROR 1: Error returned by server : HTTP error code : 500 (0)

and a bit better report when sent through python

ERROR 1: Error returned by server : <?xml version="1.0" encoding="UTF-8"?>
<ows:ExceptionReport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns
:ows="http://www.opengis.net/ows" version="1.1.0" language="en-US" xsi:schemaLoc
ation="http://www.opengis.net/ows http://schemas.opengis.net/ows/1.0.0/owsExcept
  <ows:Exception exceptionCode="NoApplicableCode" locator="mapserv">
    <ows:ExceptionText>msWFSGetFeature(): WFS server error. FLTApplyFilterToLaye
r() failed
msPostGISLayerWhichShapes(): Query error. Error (ERROR:  invalid byte sequence f
or encoding "UTF8": 0x84
) executing query: select "gid","ogc_fid","name",encode(ST_AsBinary(ST_Force_2D(
"the_geom"),'NDR'),'hex') as geom,"gid" from pks_tilastoalue_piste where the_geo
m &amp;&amp; GeomFromText('POLYGON((61600 6597900,61600 7776800,733000 7776800,7
33000 6597900,61600 6597900))',3067) and ( ("name"= 'Hämeenkylä') ) limit 100000

msEvalRegex(): Regular expression error. String failed expression test.</ows:Exc


> Best regards,
> Even

More information about the gdal-dev mailing list