[mapserver-users] WFS GetFeature with filter for multiple layers

Eichner, Andreas - SID-NLKM Andreas.Eichner at sid.sachsen.de
Thu Jan 24 04:27:48 PST 2013


Hi,

when using KVP encoded request to retrieve features of multiple types you should supply one filter for each type, enclose each filter in parentheses  and concatenate them as final value for the filter parameter like so: 

&FILTER=(<Filter>..</Filter>)(<Filter>..</Filter>)&TYPENAME=type1,type2

This is mostly equivalent to a <Query> for each type.

> -----Ursprüngliche Nachricht-----
> Von: mapserver-users-bounces at lists.osgeo.org 
> [mailto:mapserver-users-bounces at lists.osgeo.org] Im Auftrag 
> von Arjen de Korte
> Gesendet: Donnerstag, 24. Januar 2013 11:50
> An: Rahkonen Jukka; mapserver-users at lists.osgeo.org
> Betreff: Re: [mapserver-users] WFS GetFeature with filter for 
> multiple layers
> 
> Thanks Jukka. I think the trick is also to use a POST request 
> instead of
> GET, which is what I'm doing now. Looking at the example you gave, it
> looks like multiple filters should work with a POST request, while it
> doesn't seem to work with GET.
> 
> Thanks again!
> 
> Arjen.
> 
> 
> On Wed, Jan 23, 2013, at 13:17, Rahkonen Jukka wrote:
> > Hi,
> > 
> > I found this example from archives
> > 
> http://www.mail-archive.com/mapserver-users@lists.osgeo.org/ms
g10755.html
> > It has worked with two featuretypes and two filters on Mapserver.
> > 
> > -Jukka-
> > 
> > 
> > Arjen de Korte wrote:
> > > 
> > > Thanks for your time and suggestions!
> > > 
> > > - I'll have a good look at the filter again.
> > > - I understand this. Even if I would want to, it doesn't 
> work with Mapserver,
> > > which is what brought me here. (Since we have the server 
> under control
> > > also, the complications you mention would be less of an 
> issue, but in principle
> > > I agree!)
> > > - How do I correctly specify a list of filters? (This is 
> my original
> > > question.) If I get this to work, the problem is solved. 
> I'm not in the position
> > > to change/upgrade my client's Mapserver.
> > > - I agree this is better/simpler in a lot of regards, but 
> this will be for the long
> > > term. I will however make the WFS requests using POST as 
> I already have
> > > problems with urls that become too long.
> > > 
> > > Kind regards,
> > > Arjen.
> > > 
> > > 
> > > On Wed, Jan 23, 2013, at 12:03, Rahkonen Jukka wrote:
> > > > Hi,
> > > >
> > > > Some thoughts:
> > > >
> > > > - I am not a specialist with filters, but are you sure that your
> > > > filter is correct?  I have some examples about filters in page
> > > > http://latuviitta.org/Http-POST-ja-Filter.php but they 
> are generated
> > > > by a ready made application (Kosmo GIS).
> > > > - One filter for many layers is not the way to go. For 
> example, it can
> > > > only work if all the feature types are using same name for the
> > > > geometry field, and filtering with attributes would also require
> > > > similar attribute schemas. You may get it to work with 
> your own server
> > > > but your application won't most probably work against 
> any other WFS
> > > server.
> > > > - Correct way is to use a list of filters. If your old 
> Mapserver does
> > > > not support it correctly, update of change to some 
> other server that
> > > > supports.
> > > > - Continue to consider doing one request per one 
> feature type, for
> > > > many reasons.  It will be a hell to find out what goes 
> wrong with
> > > > multi-featuretype and multi-filter requests and if one 
> thing fails
> > > > then nothing works. I am sure that all WFS servers are 
> poorly tested
> > > > with featuretype lists and lists of filters, especially 
> if you are
> > > > going to use http GET.  Filters suit much better for 
> http POST and
> > > > that is better tested option too.
> > > >
> > > > Feel free to test with my TinyOWS at
> > > > http://hip.latuviitta.org/cgi-bin/tinyows? It would be 
> nice to see
> > > > what goes to my access and error logs.
> > > >
> > > > -Jukka Rahkonen-
> > > >
> > > >
> > > > > -----Alkuperäinen viesti-----
> > > > > Lähettäjä: Arjen de Korte [mailto:arjendk at gmx.net]
> > > > > Lähetetty: 23. tammikuuta 2013 12:09
> > > > > Vastaanottaja: Rahkonen Jukka; Lime, Steve D (DNR); mapserver-
> > > > > users at lists.osgeo.org
> > > > > Aihe: Re: [mapserver-users] WFS GetFeature with 
> filter for multiple
> > > > > layers
> > > > >
> > > > > Hi Jukka,
> > > > >
> > > > > Thanks for the suggestion. I am already taking that into
> > > > > consideration (and probably should have mentioned 
> it). The problem
> > > > > is that it would be quite some work to get it into 
> the existing
> > > > > application that way. For simplicity I gave an 
> example with two
> > > > > layers, but there can actually be many more, 
> depending on the map
> > > > > that is displayed. I would definitely like to keep it 
> simple, but in
> > > > > this case one GetFeature request would definitely be 
> a simpler solution!
> > > Any other suggestions welcome!
> > > > >
> > > > > Thanks!
> > > > >
> > > > > Kind regards,
> > > > > Arjen.
> > > > >
> > > > >
> > > > > On Wed, Jan 23, 2013, at 10:39, Rahkonen Jukka wrote:
> > > > > > Hi,
> > > > > >
> > > > > > Keep it simple and make two separate GetFeatures, 
> one for each
> > > > > > feature type.
> > > > > >
> > > > > > -Jukka Rahkonen-
> > > > > >
> > > > > > Arjen de Korte wrote:
> > > > > >
> > > > > >
> > > > > > > Hi Steve,
> > > > > > >
> > > > > > > Yes, for now I (my client) is stuck to this version, so a
> > > > > > > workaround (or accepting that it can't be done) 
> is the only
> > > > > > > option at the moment. Has this been solved in 
> newer versions?
> > > > > > >
> > > > > > > Kind regards,
> > > > > > > Arjen.
> > > > > > >
> > > > > > >
> > > > > > > On Tue, Jan 22, 2013, at 20:15, Lime, Steve D (DNR) wrote:
> > > > > > > > Are you stuck running such an old version?
> > > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: mapserver-users-bounces at lists.osgeo.org
> > > > > > > > 
> [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of
> > > > > > > > Arjen de Korte
> > > > > > > > Sent: Tuesday, January 22, 2013 10:45 AM
> > > > > > > > To: mapserver-users at lists.osgeo.org
> > > > > > > > Subject: [mapserver-users] WFS GetFeature with 
> filter for
> > > > > > > > multiple layers
> > > > > > > >
> > > > > > > > Hi all,
> > > > > > > >
> > > > > > > > I'm having a problem with Mapserver 5.2.1 and 
> WFS GetFeature
> > > > > requests:
> > > > > > > > when I do a GetFeature request with an OGC 
> filter for more
> > > > > > > > than one layer, I only get results for the 
> first layer. I
> > > > > > > > found a description of the issue here:
> > > > > https://github.com/mapserver/mapserver/issues/3584.
> > > > > > > > It says the issue can be worked around by 
> listing a separate
> > > > > > > > filter for each layer, but I can't work out a 
> way to do this.
> > > > > > > >
> > > > > > > > My original request looks like this:
> > > > > > > >
> > > > > > > > http://myserver.com/cgi-
> > > > > > > bin/mapserv.exe?map=mymapfile.map&Service=WFS&
> > > > > > > >
> > > > > > >
> > > > >
> > > 
> Request=GetFeature&TypeName=layer1,layer2&Version=1.0.0&Filter=<ogc:
> > > > > > > Fi
> > > > > > > > lter
> > > > > > > >
> > > > > > >
> > > > >
> > > 
> xmlns:ogc="http://www.opengis.net/ogc"><ogc:Intersects><ogc:Property
> > > > > > > N
> > > > > > > a
> > > > > > > > me/><gml:Polygon
> > > > > > > >
> > > > > > >
> > > > >
> > > 
> xmlns:gml="http://www.opengis.net/gml"><gml:outerBoundaryIs><gml:Lin
> > > > > > > ea
> > > > > > > > rRing><gml:coordinates decimal="." cs="," ts="
> > > > > > > > ">89760.045356755,436071.75388938
> > > > > > > > 89762.029730683,436071.75388938 
> 89762.029730683,436073.7382633
> > > > > > > > 89760.045356755,436073.7382633
> > > > > > > >
> > > > > > >
> > > > >
> > > 
> 89760.045356755,436071.75388938</gml:coordinates></gml:LinearRing></
> > > > > > > g
> > > > > > > m
> > > > > > > > 
> l:outerBoundaryIs></gml:Polygon></ogc:Intersects></ogc:Filter>
> > > > > > > >
> > > > > > > > ...returning only results for layer1.
> > > > > > > >
> > > > > > > > I've tried repeating the exact same filter like:
> > > > > > > >
> > > > > > > > http://myserver.com/cgi-
> > > > > > > bin/mapserv.exe?map=mymapfile.map&Service=WFS&
> > > > > > > > Request=GetFeature&TypeName=layer1,
> > > > > > > > layer2&Version=1.0.0&Filter=<ogc:Filter
> > > > > > > > 
> xmlns:ogc="http://www.opengis.net/ogc"><ogc:Intersects> ...
> > > > > > > > </ogc:Intersects><ogc:Intersects> ...
> > > > > > > > </ogc:Intersects></ogc:Filter>
> > > > > > > >
> > > > > > > > and
> > > > > > > >
> > > > > > > > http://myserver.com/cgi-
> > > > > > > bin/mapserv.exe?map=mymapfile.map&Service=WFS&
> > > > > > > > Request=GetFeature&TypeName=layer1,
> > > > > > > > layer2&Version=1.0.0&Filter=<ogc:Filter
> > > > > > > > 
> xmlns:ogc="http://www.opengis.net/ogc"><ogc:Intersects> ...
> > > > > > > > 
> </ogc:Intersects></ogc:Filter>,<ogc:Filter><ogc:Intersects> ...
> > > > > > > > </ogc:Intersects></ogc:Filter>
> > > > > > > >
> > > > > > > > ...but the first returns the same: only results 
> for layer1,
> > > > > > > > and the second returns an error.
> > > > > > > >
> > > > > > > > What is the correct way to list multiple 
> filters, or is there
> > > > > > > > another solution to work around this limitation?
> > > > > > > >
> > > > > > > > Thanks!
> > > > > > > >
> > > > > > > > Kind regards,
> > > > > > > > Arjen.
> > > > > > > > _______________________________________________
> > > > > > > > mapserver-users mailing list
> > > > > > > > mapserver-users at lists.osgeo.org
> > > > > > > > http://lists.osgeo.org/mailman/listinfo/mapserver-users
> > > > > > > >
> > > > > > > >
> > > > > > > _______________________________________________
> > > > > > > mapserver-users mailing list
> > > > > > > mapserver-users at lists.osgeo.org
> > > > > > > http://lists.osgeo.org/mailman/listinfo/mapserver-users
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> 


More information about the mapserver-users mailing list