[Geoserver-users] How to <ogc:filter> gid column?

Hello!
I am trying to filter features on my gid column, looking a bit like
following:

<ogc:PropertyIsEqualTo>
<ogc:PropertyName>gid</ogc:PropertyName>
<ogc:Literal>82211</ogc:Literal>
</ogc:PropertyIsEqualTo>

But I get an error as follows:

org.vfny.geoserver.wms.WmsException: The requested Style can not be used
with th
is featureType. The style specifies an attribute of gid and the featureType
def
inition is: DefaultFeatureType [name=occurrencerecord ,
namespace=http://localh
...........................

The gid field is in table but it seem like it is not possible to filter it
in a usual way.
The gid field is not showing up in the geoservers FeatureAttribute Editor
(all other fields are).

Is there a special trick when filtering on primary keys like gid?

/Anders

--
View this message in context: http://www.nabble.com/How-to-<ogc%3Afilter>--gid-column--tp15144022p15144022.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Lasse Larsson ha scritto:

Hello!
I am trying to filter features on my gid column, looking a bit like
following:

<ogc:PropertyIsEqualTo>
<ogc:PropertyName>gid</ogc:PropertyName>
<ogc:Literal>82211</ogc:Literal>
</ogc:PropertyIsEqualTo>

But I get an error as follows:

org.vfny.geoserver.wms.WmsException: The requested Style can not be used
with th
is featureType. The style specifies an attribute of gid and the featureType
def
inition is: DefaultFeatureType [name=occurrencerecord ,
namespace=http://localh
...........................

The gid field is in table but it seem like it is not possible to filter it
in a usual way.
The gid field is not showing up in the geoservers FeatureAttribute Editor
(all other fields are).

Is there a special trick when filtering on primary keys like gid?

Primary key is turned into the feature identifier, and it cannot
be specified as a normal filter. You have to see how GeoServer
turns your value into a primary key (usually it appends the
typename) and then use a FeatureId. There is some example
in the sample request if my mind does not play tricks to me.

The downside of FidFilter is that you cannot mix them with
other filters. The syntax should be something like:

<Filter>
   <FeatureId>states.1</FeatureId>
   <FeatureId>states.12</FeatureId>
   <FeatureId>states.25</FeatureId>
   ...
</Filter>

Cheers
Andrea

Primary key is turned into the feature identifier, and it cannot
be specified as a normal filter. You have to see how GeoServer
turns your value into a primary key (usually it appends the
typename) and then use a FeatureId. There is some example
in the sample request if my mind does not play tricks to me.

Not quite true. The wfs 1.1 cite tests dictate that gml:id be handled in
binary comparison So this should be the equivalent:

<PropertyIsEqualTo>
  <PropertyName>gml:id</PropertyName>
  <Literal>..</Literal>
</PropertyIsEqualTo>

Wether it is handled by all datastores... not sure, I know it is in postgis.

-Justin

--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org

Thank you guys!
It really broke the simplicity of my code..... shame that all column can't
be handled in the same way...

Justin's proposal should have saved me, but it didn't work (a least not with
geoserver 1.5.3) querying a postgis database.

This is the second filter I tried (but not working).

<ogc:Filter>
   <ogc:PropertyIsEqualTo>
      <ogc:PropertyName>gml:id</ogc:PropertyName>
      <ogc:Literal>82064</ogc:Literal>
   </ogc:PropertyIsEqualTo>
</ogc:Filter>

What did work was the initial proposal from Andrea (even though my code now
contains some more if-statements.....)

<ogc:Filter>
    <ogc:FeatureId fid="occurrencerecord.82213"/>
</ogc:Filter>

/Anders Larsson

--
View this message in context: http://www.nabble.com/How-to-<ogc%3Afilter>--gid-column--tp15144022p15147213.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Oh yeah.... i forgot to mention that the gml:id thing will only work
post 1.6.x :).

Lasse Larsson wrote:

Thank you guys!
It really broke the simplicity of my code..... shame that all column can't
be handled in the same way...

Justin's proposal should have saved me, but it didn't work (a least not with
geoserver 1.5.3) querying a postgis database.

This is the second filter I tried (but not working).

<ogc:Filter>
   <ogc:PropertyIsEqualTo>
      <ogc:PropertyName>gml:id</ogc:PropertyName>
      <ogc:Literal>82064</ogc:Literal>
   </ogc:PropertyIsEqualTo>
</ogc:Filter>

What did work was the initial proposal from Andrea (even though my code now
contains some more if-statements.....)

<ogc:Filter>
    <ogc:FeatureId fid="occurrencerecord.82213"/>
</ogc:Filter>

/Anders Larsson

--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org