[Geoserver-users] Problen sending CQL_FILTER in WFS request based on an ID column

Hi all.

I have a problem when making a WFS request to a GeoServer layer (ccaa_4326). I need to make a selection of polygons based on a column called ID, but in this case I receive an error message. These are the layer feature columns:



the_geom



MultiPolygon



true



0/1



AREA



Double



true



0/1



PERIMETER



Double



true



0/1



CCAA_ID



Long



true



0/1



CCAA



Integer



true



0/1



NOMBRE



String



true



0/1



ID



Integer



true



0/1

The next example works fine: I make a request to ccaa_4326 layer. I define a condition based in CCAA_ID column:

http://pc-pbg:8080/geoserver/CursoIDE/wfs?request=GetFeature&service=WFS&version=1.0.0&typeName=CursoIDE:ccaa_4326&outputFormat=json&cql_filter=CCAA_ID+IN+(‘1’,‘2’)&page=1&start=0&limit=25

In the second example, the request is the same but the column has a different name: in this case its name is ID, but is the same type as CCAA_ID. The result is an error:

http://pc-pbg:8080/geoserver/CursoIDE/wfs?request=GetFeature&service=WFS&version=1.0.0&typeName=CursoIDE:ccaa_4326&outputFormat=json&cql_filter=ID+IN+(‘1’,‘2’)&page=1&start=0&limit=25

The result: an error: {"type":"FeatureCollection","features":[]}

I have tried the same request on different GeoServer installations, and I get the same results, so I think it is not a problem of GeoServer’s version os installation, or the data. It seems like GeoServer can not differentiate between ID and internal FID column.

Any idea?

Thanks in advance.

Un saludo

Pedro Briones Garcia
Jefe de Grupo de Actuaciones y Proyectos

Gerencia de SIG y Consultoria

Grupo Tragsa - SEPI

Calle Julián Camarillo 6 B - 28037 Madrid
Tel.: 913226489 - 88216 - Fax: 913226005
pbg@anonymised.com www.tragsa.es

En beneficio del medio ambiente, imprime este e-mail sólo si realmente es necesario
For the benefit of the environment, print this e-mail only if you really need


********************************************************************************************** El consumo de papel es perjudicial para el medio ambiente. Por favor, téngalo en cuenta antes de imprimir este mensaje. AVISO LEGAL: Este mensaje y sus anexos pueden contener información confidencial o legalmente protegida. Está dirigido únicamente a la persona o entidad indicada como destinatarios del mensaje. Si este mensaje le hubiera llegado por error, por favor elimínelo sin revisarlo ni reenviarlo y notifíquelo inmediatamente al remitente. **********************************************************************************************


On Mon, May 12, 2014 at 4:20 PM, Pedro Briones Garcia <pbg@anonymised.com> wrote:

Hi all.

I have a problem when making a WFS request to a GeoServer layer (
*ccaa_4326*). I need to make a selection of polygons based on a column
called *ID*, but in this case I receive an error message. These are the
layer feature columns:

the_geom

MultiPolygon

true

0/1

AREA

Double

true

0/1

PERIMETER

Double

true

0/1

*CCAA_ID*

Long

true

0/1

CCAA

Integer

true

0/1

NOMBRE

String

true

0/1

*ID*

Integer

true

0/1

The next example works fine: I make a request to *ccaa_4326* layer. I
define a condition based in *CCAA_ID *column:

http://pc-pbg:8080/geoserver/CursoIDE/wfs?request=GetFeature&service=WFS&version=1.0.0&typeName=CursoIDE:
*ccaa_4326*&outputFormat=json&cql_filter=*CCAA_ID*
+IN+('1','2')&page=1&start=0&limit=25<http://pc-pbg:8080/geoserver/CursoIDE/wfs?request=GetFeature&service=WFS&version=1.0.0&typeName=CursoIDE:ccaa_4326&outputFormat=json&cql_filter=CCAA_ID+IN+(‘1’,‘2’)&page=1&start=0&limit=25&gt;

In the second example, the request is the same but the column has a
different name: in this case its name is *ID*, but is the same type as
*CCAA_ID*. The result is an error:

http://pc-pbg:8080/geoserver/CursoIDE/wfs?request=GetFeature&service=WFS&version=1.0.0&typeName=CursoIDE:ccaa_4326&outputFormat=json&cql_filter=
*ID*+IN+('1','2')&page=1&start=0&limit=25<http://pc-pbg:8080/geoserver/CursoIDE/wfs?request=GetFeature&service=WFS&version=1.0.0&typeName=CursoIDE:ccaa_4326&outputFormat=json&cql_filter=ID+IN+('1','2')&page=1&start=0&limit=25&gt;

The result: an error: {"type":"FeatureCollection","features":}

This is not an error, it's just an empty result.
Where are your information stored, in a database? If so, you should check
what sql is being generated by GeoServer by
enabling the "geotools developer logging" logging profile.

Also, if the column is numeric, I would expect ID in (1, 2) to be the
correct syntax

Cehers
Andrea

--

Meet us at GEO Business 2014! in London! Visit http://goo.gl/fES3aK
for more information.

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

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

Thanks Andrea.

I found that if I point the ID fiel in double quotes, it works well.

Regards.

Pedro Briones Garcia

Grupo Tragsa - SEPI

Calle Julián Camarillo 6 B - 28037 Madrid
Tel.: 913226489 - 88216 - Fax: 913226005
pbg@anonymised.com
www.tragsa.es

En beneficio del medio ambiente, imprime este e-mail sólo si realmente es necesario
For the benefit of the environment, print this e-mail only if you really need


De: andrea.aime@anonymised.com [mailto:andrea.aime@anonymised.com] En nombre de Andrea Aime
Enviado el: jueves, 15 de mayo de 2014 9:55
Para: Pedro Briones Garcia
CC: geoserver-users@anonymised.comurceforge.net
Asunto: Re: [Geoserver-users] Problen sending CQL_FILTER in WFS request based on an ID column

On Mon, May 12, 2014 at 4:20 PM, Pedro Briones Garcia <pbg@anonymised.com> wrote:

Hi all.

I have a problem when making a WFS request to a GeoServer layer (ccaa_4326). I need to make a selection of polygons based on a column called ID, but in this case I receive an error message. These are the layer feature columns:



the_geom



MultiPolygon



true



0/1



AREA



Double



true



0/1



PERIMETER



Double



true



0/1



CCAA_ID



Long



true



0/1



CCAA



Integer



true



0/1



NOMBRE



String



true



0/1



ID



Integer



true



0/1

The next example works fine: I make a request to ccaa_4326 layer. I define a condition based in CCAA_ID column:

http://pc-pbg:8080/geoserver/CursoIDE/wfs?request=GetFeature&service=WFS&version=1.0.0&typeName=CursoIDE:ccaa_4326&outputFormat=json&cql_filter=CCAA_ID+IN+(‘1’,‘2’)&page=1&start=0&limit=25

In the second example, the request is the same but the column has a different name: in this case its name is ID, but is the same type as CCAA_ID. The result is an error:

http://pc-pbg:8080/geoserver/CursoIDE/wfs?request=GetFeature&service=WFS&version=1.0.0&typeName=CursoIDE:ccaa_4326&outputFormat=json&cql_filter=ID+IN+(‘1’,‘2’)&page=1&start=0&limit=25

The result: an error: {"type":"FeatureCollection","features":[]}

This is not an error, it’s just an empty result.

Where are your information stored, in a database? If so, you should check what sql is being generated by GeoServer by

enabling the “geotools developer logging” logging profile.

Also, if the column is numeric, I would expect ID in (1, 2) to be the correct syntax

Cehers

Andrea

==

Meet us at GEO Business 2014! in London! Visit http://goo.gl/fES3aK

for more information.

==

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



********************************************************************************************** El consumo de papel es perjudicial para el medio ambiente. Por favor, téngalo en cuenta antes de imprimir este mensaje. AVISO LEGAL: Este mensaje y sus anexos pueden contener información confidencial o legalmente protegida. Está dirigido únicamente a la persona o entidad indicada como destinatarios del mensaje. Si este mensaje le hubiera llegado por error, por favor elimínelo sin revisarlo ni reenviarlo y notifíquelo inmediatamente al remitente. **********************************************************************************************