Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm not able to use the featureID parameter in a WFS URL request for my dataset on GeoServer.

Example:

http://demo.opengeo.org/geoserver/wfs?version=1.1.0&service=wfs&request=GetFeature&typeName=topp:tasmania_roads&maxFeatures=10&featureID=tasmania_roads.2

The above URL returns ONE feature because i have appended the &featureID=tasmania_roads.2

The featureID paramter works great with the topp:tasmania_roads dataset on the demo.opengeo.org geoserver and on my geoserver as well.

Howerver, It does NOT work on the layer I have published. And I cannot see any differences. My geoserver is internal so I regret that I cannot provide a URL. But this is how i'm constructing my URL (same way I did for tasmania_roads):

From the GetCapabilities:

...
<FeatureType xmlns:catalog="http://mydomain.com/catalog">
  <Name>catalog:myData</Name>
  <Title>myData</Title>
...

From the GetFeature:

...
<gml:featureMembers>
  <catalog:myData gml:id="myData.fid--57bd457b_134ae684781_8989">
    <catalog:id>190004</catalog:id>
    <catalog:type>SICD</catalog:type>
...

So based on the above information my url should be:

http://myDomain.com/geoserver/wfs?version=1.1.0&service=wfs&request=GetFeature&typeName=catalog:myData&maxFeatures=10&featureID=myData.fid--57bd457b_134ae684781_8989

But I get ZERO results.

I tried URLencoding, republishing and different namespace/feature type naming configurations, with no luck.

I'm thinking there must be a setting on GeoServer when publishing the dataset that I'm overlooking?

share|improve this question
1  
what is your data store? If it doesn't have a primary key then the features get a new fid with each request. –  iant Apr 7 '12 at 15:13
    
@iant My data store is a postgis view. As you mention, that's probably why geoserver doesn't pick up the primary key. Thanks for the info, it supports what unicoletti says and I'm pretty confident that's the issue. (+1) –  CaptDragon Apr 7 '12 at 18:18
add comment

1 Answer

up vote 6 down vote accepted

Your feature ID looks suspiciously random as in randomly generated by Geoserver. The reason for that is that Geoserver (GeoTools actually) cannot pick a unique identifier from the datastore.

This document, though vague, explains what GeoTools consider a fid:

http://docs.codehaus.org/display/GEOTOOLS/What+is+a+FID

Solution: if you are using postgis define a Primary Key (though I have not tried, you could get the same result with a unique index) on the table and recreate the layer.

On shapefiles this should not be necessary because GeoServer will use the position of the feature in the shapefile.

share|improve this answer
    
I see, that makes sense. I am pointing my layer to a postgis view. That's probably why geoserver doesn't pick up the primary key? I'm going to run some tests on Monday. (+1) –  CaptDragon Apr 7 '12 at 18:15
    
Do you know if I'm able to use a FILTER to get that one row by the randomly generated ID? Or will i have the same problem as with featureID parameter? –  CaptDragon Apr 7 '12 at 18:26
1  
Not for sure, but in principle it should not work. You could work around by adding an ID or FID column to the view and then filter on that. –  unicoletti Apr 7 '12 at 21:12
    
I see, Many Thanks! –  CaptDragon Apr 8 '12 at 1:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.