[gdal-dev] WFS driver does not do URL-encoding right

Rahkonen Jukka Jukka.Rahkonen at mmmtike.fi
Wed Aug 15 14:14:53 PDT 2012


Even Rouault wrote:


Le mercredi 15 août 2012 21:28:22, Jukka Rahkonen a écrit :
>> GvSIG is also sending GetFeatures with http GET and filters and it had same
>> kind of problems with special characters. Now the developers say that they
>> have fixed URL encoding. I hope that the solution is somehow re-usable

> I'm not sure this is a problem with URL encoding, but more a problem with the
> fact that the Windows console is not using UTF-8. So even if the OGR WFS
> driver did escape the special character, this wouldn't solve anything, since
> it would get a non UTF8 character and would escape it wrongly...

> Some seraching would suggest that typing "chcp 65001" before might help, but
> I'm not sure...

> I'm wondering if the GDAL command line utilities shouldn't use special
> instructions under Windows to better deal with Unicode characters. Some search
> would suggest that using wmain() and/or SetConsoleOutputCP() might help. Are
> there Windows programmers around that might give advice on how to get
> arguments in UTF-8 from the Windows command line ?

> Anyway, with Linux, it works fine :
........

If it happens to help, this is the only reliable method I have discovered so far for 
creating GetFeatures on Windows so that they work.

1) Create a complete plain text request 
2) Split it into two pieces and copy the part before XML filter to a safe place.
http://188.64.1.61/cgi-bin/tinyows?SERVICE=WFS&VERSION=1.1.0&REQUEST=GetFeature&TYPENAME=lv:municipalities&FILTER=
3) Copy the filter part and drop into some URL encoding service like http://www.albionresearch.com/misc/urlencode.php. 

For example this goes to the URL-encoding service
<Filter xmlns="http://www.opengis.net/ogc" xmlns:lv="http://latuviitta.fi/" xmlns:gml="http://www.opengis.net/gml"><PropertyIsEqualTo><PropertyName>kunta_ni1</PropertyName><Literal>Saarijärvi</Literal></PropertyIsEqualTo></Filter>

and this comes back
%3CFilter%20xmlns%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22%20xmlns%3Alv%3D%22http%3A%2F%2Flatuviitta.fi%2F%22%20xmlns%3Agml%3D%22http%3A%2F%2Fwww.opengis.net%2Fgml%22%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3Ekunta_ni1%3C%2FPropertyName%3E%3CLiteral%3ESaarij%C3%A4rvi%3C%2FLiteral%3E%3C%2FPropertyIsEqualTo%3E%3C%2FFilter%3E

4) Combine the starting part of GetFeature from step 2) and URL-encoded filter from step 3)
This new GetFeature can be sent with a browser or with wget or curl.

You can guess that I do not really use this method for any real work.  Instead I am either using Kosmo
GIS as WFS client because it is using http POST (and has a query builder), or then I send requests 
from browser with POST method by using Poster add-on.  However, using WFS through OGR offers 
so nice possibilities that it would be great to learn some way for making also attribute filters with special characters to work - on Windows and in Finland.

-Jukka-



More information about the gdal-dev mailing list