[Geoserver-users] CQL Filter contradiction between WFS getFeature request and WMS mergeNewParams

Hi,

I am developing a web map application by using Geoserver 2.4.0. In my application, I have developed a module like Arcgis Query builder as shown below screenshot.

Inline image 1

In that, while I am using CQL Filter, WFS and WMS returns different result for same layer.

var oXml = OpenLayers.Request.GET({
url: "[http://xxx.xxx.x.xx:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=Buildings&cql_filter=](http://xxx.xxx.x.xx:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=Buildings&cql_filter=)" + $("#txtBoxQuery").val(),
async: false
});

var strXml = oXml.responseXML;
var featuresLst = strXml.getElementsByTagName('Buildings');
console.log("Features1: " + featuresLst.length);              //Return Error 

newFilter = format.read($("#txtBoxQuery").val());

var oXml2 = OpenLayers.Request.GET({
url: "[http://xxx.xxx.x.xx:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=Buildings&cql_filter=](http://xxx.xxx.x.xx:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=Buildings&cql_filter=)" + newFilter,
async: false
});

var strXml2 = oXml2.responseXML;
var featuresLst2 = strXml2.getElementsByTagName('Buildings');
console.log("Features2: " + featuresLst2.length);             //Return Error
<img src="upload://3I3WHZuoThIwaJPE9tny7vtIWXt.png" alt="Inline image 2" width="564" height="56">

//tocLayer is Buildings layer

tocLayer.mergeNewParams({ cql_filter: $("#txtBoxQuery").val() });        //Return 1

I am very new to CQL Filter, Kindly help me to fix this issue. Thanks in advance

On Fri, Dec 20, 2013 at 6:43 AM, venky <venky.src@anonymised.com> wrote:

I am very new to CQL Filter, Kindly help me to fix this issue. Thanks in
advance

The above is not enough to give you any response. Please share the requests
generated by
your client (the URLs hitting GeoServer) and the full responses, that might
give us something
useful to look at.

Cheers
Andrea

--
*== GeoSolutions will be closed for seasonal holidays from 23/12/2013 to
06/01/2014 ==*

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

Hi This is the URL hitting geoserver:

http://xxx.xxx.x.xx:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=cite:Plymouth_Buildings&cql_filter=Area=‘2.0224’%20+%20’2.0224

···

On Fri, Dec 20, 2013 at 2:10 PM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Fri, Dec 20, 2013 at 6:43 AM, venky <venky.src@anonymised.com> wrote:

I am very new to CQL Filter, Kindly help me to fix this issue. Thanks in advance

The above is not enough to give you any response. Please share the requests generated by
your client (the URLs hitting GeoServer) and the full responses, that might give us something
useful to look at.

Cheers
Andrea

== GeoSolutions will be closed for seasonal holidays from 23/12/2013 to 06/01/2014 ==

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


This is the URL hitting geoserver:

http://xxx.xxx.x.xx:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=cite:Plymouth_Buildings&cql_filter=Area=‘2.0224’%20+%20’2.0224

This is the full response from geoserver:

<ows:ExceptionReport xmlns:ows=“http://www.opengis.net/ows” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” version=“1.0.0” xsi:schemaLocation=“http://www.opengis.net/ows http://xxx.xxx.x.xx:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd”>
<ows:Exception exceptionCode=“NoApplicableCode”>
ows:ExceptionTextCould not parse CQL filter list.
Encountered “'2.0224'” at line 1, column 19.
Was expecting one of:
<EOF>
“and” …
“or” …
“;” …
“/” …
“*” …
“+” …
“-” …
Parsing : Area = ‘2.0224’ ‘2.0224’.</ows:ExceptionText>
</ows:Exception>
</ows:ExceptionReport>

···

On Fri, Dec 20, 2013 at 2:10 PM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Fri, Dec 20, 2013 at 6:43 AM, venky <venky.src@anonymised.com> wrote:

I am very new to CQL Filter, Kindly help me to fix this issue. Thanks in advance

The above is not enough to give you any response. Please share the requests generated by
your client (the URLs hitting GeoServer) and the full responses, that might give us something
useful to look at.

Cheers
Andrea

== GeoSolutions will be closed for seasonal holidays from 23/12/2013 to 06/01/2014 ==

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


Hi Venky,
the problem seems to be that you need to url encode the ‘+’ symbol (if not it will be converted to a space). The url should probably be:

http://xxx.xxx.x.xx:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=cite:Plymouth_Buildings&cql_filter=Area=‘2.0224’%20%2B%20’2.0224

Regards,Mauro Bartolomeoli

Yes. Its working now. Thanks for your help Mauro. Its really great. I will let u know if I met any further issue with this

···

On Sat, Dec 21, 2013 at 12:34 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

Hi Venky,
the problem seems to be that you need to url encode the ‘+’ symbol (if not it will be converted to a space). The url should probably be:

http://xxx.xxx.x.xx:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=cite:Plymouth_Buildings&cql_filter=Area=‘2.0224’%20%2B%20’2.0224

Regards,Mauro Bartolomeoli

== GeoSolutions will be closed for Christmas Holidays from 23/12/2013 to 06/01/2014 ==

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


Hi Mauro,

All is fine now. But below thing is not returning correct result. Is there anything wrong in that?

Area

···

i.e.Result should be 7 features.But its returning only one. Request URL is:

http://192.168.0.86:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=Plymouth_Buildings&cql_filter=Area > (‘41.9696’ +%2B+‘42.9826’) / 2

Please suggest me to use this type of queries

On Mon, Dec 23, 2013 at 5:01 PM, venky <venky.src@anonymised.com> wrote:

Yes. Its working now. Thanks for your help Mauro. Its really great. I will let u know if I met any further issue with this

On Sat, Dec 21, 2013 at 12:34 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

Hi Venky,
the problem seems to be that you need to url encode the ‘+’ symbol (if not it will be converted to a space). The url should probably be:

http://xxx.xxx.x.xx:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=cite:Plymouth_Buildings&cql_filter=Area=‘2.0224’%20%2B%20’2.0224

Regards,Mauro Bartolomeoli

== GeoSolutions will be closed for Christmas Holidays from 23/12/2013 to 06/01/2014 ==

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


Hi venky,

···

2013/12/24 venky <venky.src@anonymised.com>

Hi Mauro,

All is fine now. But below thing is not returning correct result. Is there anything wrong in that?

Area

41.9696
42.9826
43.0137
43.6441
46.8394
46.9315
47.2082
781.198

Area > (‘41.9696’ + ‘42.9826’) / 2

Its filtered out only 1 feature,Its Area 781.198

Please, try removing quotes around the numeric values in your filter. Quotes are used for string literal values, and I presume that using sum with quoted strings you get concatenation of strings and not arithmetic sum.
Your filter should be: Area > (41.9696 + 42.9826) / 2

Regards,
Mauro Bartolomeoli

== GeoSolutions will be closed for Christmas Holidays from 23/12/2013 to 06/01/2014 ==

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


Hi Mauro,

Thanks for your reply. I tried as per your instruction but got the same result. plz the generated url

Query is: Area > (41.9696 + 42.9826) / 2

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=Plymouth_Buildings&cql_filter=Area%20%3E%20(41.9696%20+%2B+%2042.9826)%20/%202

Is there anything I did wrongly? Kindly help me plz

···

On Sat, Dec 28, 2013 at 1:59 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com> wrote:

Hi venky,

2013/12/24 venky <venky.src@anonymised.com>

Hi Mauro,

All is fine now. But below thing is not returning correct result. Is there anything wrong in that?

Area

41.9696
42.9826
43.0137
43.6441
46.8394
46.9315
47.2082
781.198

Area > (‘41.9696’ + ‘42.9826’) / 2

Its filtered out only 1 feature,Its Area 781.198

Please, try removing quotes around the numeric values in your filter. Quotes are used for string literal values, and I presume that using sum with quoted strings you get concatenation of strings and not arithmetic sum.
Your filter should be: Area > (41.9696 + 42.9826) / 2

Regards,
Mauro Bartolomeoli

== GeoSolutions will be closed for Christmas Holidays from 23/12/2013 to 06/01/2014 ==

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


Hi,

If possible, test with some data that we others can also use easily. Trying with another dataset removes also the possibility that there is something special in your own data. In this case the famous topp:states feels suitable.

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=topp:states&cql_filter=WATER_KM&gt;6000
Result=OK, have a next try with 2000+4000 instead of 6000

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=topp:states&propertyname=STATE_NAME,WATER_KM&cql_filter=WATER_KM&gt;\(2000\.00\+4000\.00\)
Result=Error, let's change '+' into '%2B'

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=topp:states&propertyname=STATE_NAME,WATER_KM&cql_filter=WATER_KM&gt;\(2000\.00%2B4000\.00\)
Result=OK, improve formula into (2000+4000)/2

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=topp:states&propertyname=STATE_NAME,WATER_KM&cql_filter=WATER_KM&gt;\(2000\.00%2B4000\.00\)/2
Result=OK

Perhaps the reason for the remaining trouble is the extra space characters in your formula: '2000 + 4000' instead of '2000+4000'.

-Jukka Rahkonen-

________________________________
venky wrote:

Hi Mauro,

Thanks for your reply. I tried as per your instruction but got the same result. plz the generated url

Query is: Area > (41.9696 + 42.9826) / 2

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=Plymouth_Buildings&cql_filter=Area%20>%20(41.9696%20+%2B+%2042.9826)%20/%202

Is there anything I did wrongly? Kindly help me plz

On Sat, Dec 28, 2013 at 1:59 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com1107...<mailto:mauro.bartolomeoli@anonymised.com>> wrote:
Hi venky,

2013/12/24 venky <venky.src@anonymised.com<mailto:venky.src@anonymised.com>>
Hi Mauro,

All is fine now. But below thing is not returning correct result. Is there anything wrong in that?

Area
-------

41.9696
42.9826
43.0137
43.6441
46.8394
46.9315
47.2082
781.198

Area > ('41.9696' + '42.9826') / 2

Its filtered out only 1 feature,Its Area 781.198

Please, try removing quotes around the numeric values in your filter. Quotes are used for string literal values, and I presume that using sum with quoted strings you get concatenation of strings and not arithmetic sum.
Your filter should be: Area > (41.9696 + 42.9826) / 2

Regards,
Mauro Bartolomeoli

--
== GeoSolutions will be closed for Christmas Holidays from 23/12/2013 to 06/01/2014 ==

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

Hi Rahkonen,

Thanks for nice response. I tried your example and I got the perfect output but there is no change in my dataset.
So problem is only in my dataset.

···

On Sun, Dec 29, 2013 at 10:38 PM, Rahkonen Jukka <jukka.rahkonen@anonymised.com> wrote:

Hi,

If possible, test with some data that we others can also use easily. Trying with another dataset removes also the possibility that there is something special in your own data. In this case the famous topp:states feels suitable.

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=topp:states&cql_filter=WATER_KM>6000
Result=OK, have a next try with 2000+4000 instead of 6000

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=topp:states&propertyname=STATE_NAME,WATER_KM&cql_filter=WATER_KM>(2000.00+4000.00)
Result=Error, let’s change ‘+’ into ‘%2B’

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=topp:states&propertyname=STATE_NAME,WATER_KM&cql_filter=WATER_KM>(2000.00%2B4000.00)
Result=OK, improve formula into (2000+4000)/2

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=topp:states&propertyname=STATE_NAME,WATER_KM&cql_filter=WATER_KM>(2000.00%2B4000.00)/2
Result=OK

Perhaps the reason for the remaining trouble is the extra space characters in your formula: ‘2000 + 4000’ instead of ‘2000+4000’.

-Jukka Rahkonen-


venky wrote:

Hi Mauro,

Thanks for your reply. I tried as per your instruction but got the same result. plz the generated url

Query is: Area > (41.9696 + 42.9826) / 2

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=Plymouth_Buildings&cql_filter=Area%20%3E%20(41.9696%20+%2B+%2042.9826)%20/%202

Is there anything I did wrongly? Kindly help me plz

On Sat, Dec 28, 2013 at 1:59 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com.1107…mailto:[mauro.bartolomeoli@anonymised.com](mailto:mauro.bartolomeoli@anonymised.com)> wrote:
Hi venky,

2013/12/24 venky <venky.src@…84…mailto:[venky.src@anonymised.com4...](mailto:venky.src@anonymised.com)>

Hi Mauro,

All is fine now. But below thing is not returning correct result. Is there anything wrong in that?

Area

41.9696
42.9826
43.0137
43.6441
46.8394
46.9315
47.2082
781.198

Area > (‘41.9696’ + ‘42.9826’) / 2

Its filtered out only 1 feature,Its Area 781.198

Please, try removing quotes around the numeric values in your filter. Quotes are used for string literal values, and I presume that using sum with quoted strings you get concatenation of strings and not arithmetic sum.
Your filter should be: Area > (41.9696 + 42.9826) / 2

Regards,
Mauro Bartolomeoli


== GeoSolutions will be closed for Christmas Holidays from 23/12/2013 to 06/01/2014 ==

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it



Rapidly troubleshoot problems before they affect your business. Most IT
organizations don’t have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Hi,

This test proves so far only that the CQL filter with ">(x+y)/2" filter works with the topp:states data coming from a shapefile datastore. Do your data come also from a shapefile? If not, have another try by converting your data into shapefile and making a new layer from that. That way you can check if the difference comes from datastores, for example shapefile vs. PostGIS.

If your data is in shapefile, start from the scratch and copy a few features from your data into a new shapefile and check if that works. If not, rip off all other attributes than geometry and the one you use in the filter. If still no success, edit the minimal shapefile with OpenJUMP or QGIS, delete the attribute values and rewrite them by hand. This may reveal if there is some odd data error in the shapefile. If still no success, it starts to feel like a bug and you can zip the problematic small shapefile and put it somewhere where developers can download it.

-Jukka Rahkonen-
________________________________
venky wrote:

Hi Rahkonen,

Thanks for nice response. I tried your example and I got the perfect output but there is no change in my dataset.
So problem is only in my dataset.

On Sun, Dec 29, 2013 at 10:38 PM, Rahkonen Jukka <jukka.rahkonen@anonymised.com<mailto:jukka.rahkonen@anonymised.com>> wrote:
Hi,

If possible, test with some data that we others can also use easily. Trying with another dataset removes also the possibility that there is something special in your own data. In this case the famous topp:states feels suitable.

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=topp:states&cql_filter=WATER_KM&gt;6000
Result=OK, have a next try with 2000+4000 instead of 6000

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=topp:states&propertyname=STATE_NAME,WATER_KM&cql_filter=WATER_KM&gt;\(2000\.00\+4000\.00\)
Result=Error, let's change '+' into '%2B'

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=topp:states&propertyname=STATE_NAME,WATER_KM&cql_filter=WATER_KM&gt;\(2000\.00%2B4000\.00\)
Result=OK, improve formula into (2000+4000)/2

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=topp:states&propertyname=STATE_NAME,WATER_KM&cql_filter=WATER_KM&gt;\(2000\.00%2B4000\.00\)/2
Result=OK

Perhaps the reason for the remaining trouble is the extra space characters in your formula: '2000 + 4000' instead of '2000+4000'.

-Jukka Rahkonen-

________________________________
venky wrote:

Hi Mauro,

Thanks for your reply. I tried as per your instruction but got the same result. plz the generated url

Query is: Area > (41.9696 + 42.9826) / 2

http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=Plymouth_Buildings&cql_filter=Area%20>%20(41.9696%20+%2B+%2042.9826)%20/%202

Is there anything I did wrongly? Kindly help me plz

On Sat, Dec 28, 2013 at 1:59 PM, Mauro Bartolomeoli <mauro.bartolomeoli@anonymised.com1107...<mailto:mauro.bartolomeoli@anonymised.com><mailto:mauro.bartolomeoli@anonymised.com1107...<mailto:mauro.bartolomeoli@anonymised.com>>> wrote:
Hi venky,

2013/12/24 venky <venky.src@anonymised.com<mailto:venky.src@anonymised.com><mailto:venky.src@anonymised.com>>
Hi Mauro,

All is fine now. But below thing is not returning correct result. Is there anything wrong in that?

Area
-------

41.9696
42.9826
43.0137
43.6441
46.8394
46.9315
47.2082
781.198

Area > ('41.9696' + '42.9826') / 2

Its filtered out only 1 feature,Its Area 781.198

Please, try removing quotes around the numeric values in your filter. Quotes are used for string literal values, and I presume that using sum with quoted strings you get concatenation of strings and not arithmetic sum.
Your filter should be: Area > (41.9696 + 42.9826) / 2

Regards,
Mauro Bartolomeoli

--
== GeoSolutions will be closed for Christmas Holidays from 23/12/2013 to 06/01/2014 ==

Dott. Mauro Bartolomeoli
@mauro_bart
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net<mailto:Geoserver-users@anonymised.comrge.net>
https://lists.sourceforge.net/lists/listinfo/geoserver-users