[OpenLayers-Users] CQL queries with WFS

Brenningmeyer, Todd tbrenningmeyer at maryville.edu
Thu Aug 14 11:18:52 EDT 2008


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&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&typename=villages&request=getfeature&version=1.0.0&service=wfs&,{
  {
    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_FILTER=nomos=\'Eleia\'&typename=villages&request=getfeature&version=1.0.0&service=wfs,{
>                {
>                 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_FILTER=nomos='Eleia'
>> <http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.map&CQL_FILTER=nomos='Eleia',{//
>> <http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.map&CQL_FILTER=nomos='Eleia',{// <http://localhost/cgi-bin/mapserv.exe?map=../htdocs/amap/sites_wfs.map&CQL_FILTER=nomos='Eleia',{//<Filter> >
>> ><PropertyIsEqualTo><PropertyName>nom_nr</PropertyName><Literal>39</Literal></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_FILTER=nomos='Eleia'&typename=villages&request=getfeature&version=1.0.0&service=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/>
>> 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
>>
>
>
>
>
>







More information about the Users mailing list