[OpenLayers-Users] CQL queries with WFS

Brenningmeyer, Todd tbrenningmeyer at maryville.edu
Thu Aug 14 20:42:52 EDT 2008


The filter is finally up and running.  Thanks for everyone's help.  It turns out that openlayers was tagging an extra BBOX to the end of the request.  I'm guessing that this kept the filter from executing as it worked just fine when I removed the bbox from the url.  Does setcenter place a BBOX at the end of the url?  The request I'm now using is a wfs request but I'm puting this into a gml layer and the bbox is no longer an issue.  I'll include the request below.  I'm not sure if there is a good way to bypass this with a regular wfs filter request but the query is now working the way I had hoped.
Thanks again for your help.
Todd
 
           gmlLayer = new OpenLayers.Layer.GML( "villages",[ http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.map&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=VILLAGES&Filter=<Filter><PropertyIsEqualTo><PropertyName>nomos</PropertyName><Literal>Eleia</Literal></PropertyIsEqualTo></Filter>&outputformat=gml2]
                );


________________________________

From: josh.marcus at gmail.com on behalf of Josh Marcus
Sent: Thu 8/14/2008 3:03 PM
To: Arnd Wippermann
Cc: Brenningmeyer, Todd; users at openlayers.org
Subject: Re: [OpenLayers-Users] CQL queries with WFS


By the way, here is a brief documentation reference about how to apply a filter:

Look at:

http://ms.gis.umn.edu/docs/reference/mapfile/layer

and search for "FILTER".

So, for example, you might achieve the same result as passing in the following CGI variable to a GeoServer WMS call:

CQL_FILTER="attribute > 50"

... by passing the following CGI variable to a MapServer WMS call:

MAP_LAYER_0_FILTER="attribute > 50"

--j



On Thu, Aug 14, 2008 at 3:57 PM, Josh Marcus <jmarcus at avencia.com> wrote:


	Arnd,
	
	While MapServer does not support CQL specifically, most CQL filters will work as MapServer filters -- and MapServer filters have some capabilities beyond what CQL will support.  But a basic CQL filter (e.g. just checking for equality or greater than or less than) will work unchanged under Mapsever.
	
	--j 



	On Thu, Aug 14, 2008 at 3:50 PM, Arnd Wippermann <arnd.wippermann at web.de> wrote:
	

		Hi,
		
		Does MapServer support CQL? If so I would be interested. Can someone point
		me to a source, how to use it? Internet search shows nothing for MapServer.
		
		Arnd Wippermann
		
		-----Ursprüngliche Nachricht-----
		Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
		Auftrag von Brenningmeyer, Todd
		Gesendet: Donnerstag, 14. August 2008 17:19
		An: bartvde at osgis.nl
		Cc: Openlayers Users List
		Betreff: Re: [OpenLayers-Users] CQL queries with WFS
		

		I used the code below but the map still returned all of the villages.  It
		seems very strange that both my CQL_Filter and URL style filters aren't
		working.  I'm sure I'm missing something but the filter process just doesn't
		seem to like my queries (at least in terms of the syntax I'm using).  The
		CQL_Filter params did appear in the params section within firebug when I ran
		it but in a vertical format with each letter listed after a number...so 0 C
		1 Q 2 L and so on in a vertical column.  I'm not sure if this makes sense or
		if it is important to the filter problem.  Thanks again for your help.  If
		you have any other suggestions about using the CQL_FILTER or a URL style
		filter please let me know.  I've been tinkering with this for quite a while
		without success so your help is very much appreciated.
		Thanks again,
		Todd
		
		var wfsLayer = new OpenLayers.Layer.WFS( "villages",
		
		"http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.map&typen
		ame=villages&request=getfeature&version=1.0.0&service=wfs& <http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.map&typename=villages&request=getfeature&version=1.0.0&service=wfs&> ",
		 {
		   styleMap: oStyleMap
		 }
		);
		var value = "nomos='Eleia'";
		wfsLayer.mergeNewParams('CQL_FILTER:' + escape(value));  (I've used both :
		and = after CQL_FILTER but neither seemed to work)
		
		________________________________
		
		From: bartvde at osgis.nl [mailto:bartvde at osgis.nl]
		Sent: Thu 8/14/2008 9:23 AM
		To: Brenningmeyer, Todd
		Cc: bartvde at osgis.nl; Andreas Hocevar; Eric Lemoine; Openlayers Users List
		Subject: RE: [OpenLayers-Users] CQL queries with WFS
		
		
		
		Can you try something like:
		
		var wfsLayer = new OpenLayers.Layer.WFS( "villages",
		
		http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.map&typena
		me=villages&request=getfeature&version=1.0.0&service=wfs&,{ <http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.map&typename=villages&request=getfeature&version=1.0.0&service=wfs&,%7B> 
		 {
		   styleMap: oStyleMap
		 }
		);
		var value = "nomos='Eleia'";
		wfsLayer.mergeNewParams({'CQL_FILTER', escape(value)});
		
		Best regards,
		Bart
		
		> Bart,
		> I tried escaping the quotes around the value of the nomos but
		> unfortunately it didn't change the returned results.  I used
		> backslashes in front of the single quotes around Eleia.  Is this what you
		had in mind?
		>  It may be that I'm not escaping the right part of the filter.
		> Thanks,
		> Todd
		>            wfsLayer = new OpenLayers.Layer.WFS( "villages",
		>
		http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.map&CQL_FI
		LTER=nomos=\'Eleia\'&typename=villages&request=getfeature&version=1.0.0&serv
		ice=wfs,{ <http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.map&CQL_FILTER=nomos=%5C%27Eleia%5C%27&typename=villages&request=getfeature&version=1.0.0&service=wfs,%7B> 
		>                {
		>                 styleMap: oStyleMap
		>                 }
		>             );
		>
		> ________________________________
		>
		> From: bartvde at osgis.nl [mailto:bartvde at osgis.nl]
		> Sent: Thu 8/14/2008 8:52 AM
		> To: Brenningmeyer, Todd
		> Cc: Andreas Hocevar; Eric Lemoine; Openlayers Users List
		> Subject: Re: [OpenLayers-Users] CQL queries with WFS
		>
		>
		>
		> Have you tried escaping the value of your parameter CQL_FILTER?
		>
		> Best regards,
		> Bart
		>
		>> Thanks Andreas and Eric.  I've tried a few different options with the
		>> filter but without success.  I'm using the following filter and have
		>> tried this with the map location moved into the params section and a
		>> few other times with everything in a single URL request but still no
		>> luck.  The request returns all of the villages with none of these
		>> filtered out.  If you have any ideas that might help please let me
		>> know.  Thanks again for your help.
		>> Todd
		>>            wfsLayer = new OpenLayers.Layer.WFS( "villages",
		>>
		"http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.map&CQL_F
		ILTER=nomos='Eleia <http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.map&CQL_FILTER=nomos=%27Eleia> '
		>> <http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.ma
		>> p&CQL_FILTER=nomos='Eleia',{//
		>> <http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.ma
		>> p&CQL_FILTER=nomos='Eleia',{//
		>> <http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.ma
		
		>> p&CQL_FILTER=nomos='Eleia',{//<Filter> >
		>> ><PropertyIsEqualTo><PropertyName>nom_nr</PropertyName><Literal>39</L
		>> >iteral></PropertyIsEqualTo></Filter>
		>> ",{
		>>                service: "WFS",
		>>                typename: "villages",
		>>                request: "getfeature",
		>>                version: "1.0.0"
		>>                },
		>>                {
		>>                 extractAttributes: true
		>>                 }
		>>             );
		>>
		>> Attempt with the params moved into the URL:
		>>            wfsLayer = new OpenLayers.Layer.WFS( "villages",
		>>
		"http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.map&CQL_F
		
		ILTER=nomos='Eleia'&typename=villages&request=getfeature&version=1.0.0&servi
		
		ce=wfs",{
		>>                 styleMap: oStyleMap
		>>                 }
		>>             );
		>>
		>> ________________________________
		>>
		>> From: Andreas Hocevar [mailto:andreas.hocevar at gmail.com]
		>> Sent: Wed 8/13/2008 7:11 AM
		>> To: Eric Lemoine
		>> Cc: Brenningmeyer, Todd; Openlayers Users List
		>> Subject: Re: [OpenLayers-Users] CQL queries with WFS
		>>
		>>
		>>
		>> Hi,
		>>
		>> On Wed, Aug 13, 2008 at 2:08 PM, Eric Lemoine <eric.c2c at gmail.com>
		>> wrote:
		>>> On Wed, Aug 13, 2008 at 11:49 AM, Andreas Hocevar
		>>> <andreas.hocevar at gmail.com> wrote:
		>>>> Hi,
		>>>>
		>>>> Since CQL_FILTER is not part to the WMS spec, the best way is to
		>>>> add the filter to the WMS url, e.g.
		>>>>
		>>>> var layer=new OpenLayers.Layer.WMS("cql",
		>>>> "http://your-server/wms?CQL_FILTER=foo<3", params, options);
		>>>
		>>> Todd's question related to WFS, but I guess the response is similar,
		>>> isn't it?
		>>
		>> Should be, yes. Just s/WMS/WFS/gi.
		>>
		>> Regards,
		>> Andreas.
		>>
		>> No virus found in this incoming message.
		>> Checked by AVG - http://www.avg.com <http://www.avg.com/>  <http://www.avg.com/>
		>> <http://www.avg.com/> <http://www.avg.com/>
		>> Version: 8.0.138 / Virus Database: 270.6.2/1609 - Release Date:
		>> 8/13/2008
		>> 6:43 AM
		>>
		>>
		>> _______________________________________________
		>> Users mailing list
		>> Users at openlayers.org
		>> http://openlayers.org/mailman/listinfo/users
		>>
		>
		>
		>
		>
		>
		
		
		
		
		_______________________________________________
		Users mailing list
		Users at openlayers.org
		http://openlayers.org/mailman/listinfo/users
		
		_______________________________________________
		Users mailing list
		Users at openlayers.org
		http://openlayers.org/mailman/listinfo/users
		






More information about the Users mailing list