Opened 17 years ago

Closed 17 years ago

#2101 closed defect (fixed)

Make WFS FID's compliant...

Reported by: sdlime Owned by: sdlime
Priority: normal Milestone: 5.0 release
Component: WFS Server Version: 5.0
Severity: normal Keywords:
Cc: bartvde@…, Jukka.Rahkonen@…, tom.kralidis@…

Description

MapServer by default will output non-compliant feature-id's with WFS output. Here's a piece of a thread by Jukka Rahkonen...


a) An excerpt from gml 2.1.2 feature.xsd schema:

<documentation>

An abstract feature provides a set of common properties. A concrete feature type must derive from this type and specify additional properties in an application schema. A feature may optionally possess an identifying attribute ('fid').

</documentation>

</annotation> <sequence>

<element ref="gml:description" minOccurs="0"/> <element ref="gml:name" minOccurs="0"/> <element ref="gml:boundedBy" minOccurs="0"/> <!-- additional properties must be specified in an application schema -->

</sequence> <attribute name="fid" type="ID" use="optional"/>

So fid seems to be of type "ID" b) Reference http://matcmadison.edu/schmidt/xml/dtdattr.htm says:

ID is used to uniquely identify an element in the [XML] document

  • It cannot be repeated within the document
  • Cannot have a fixed default value (#FIXED), since these cannot change
  • Most IDs use #REQUIRED for a default value, since an ID is required
  • ID values must conform to the rules for valid XML names
  • ID must be a valid XML name - must start with a letter or underscore
  • An ID using a pure number, such as a credit card number, social security number, telephone number or any other pure numeric value is not valid

There seem to exist WFS clients which are strict in validating the GML returned from the server. Shouldn't there be some mechanism in Mapserver WFS that automatically generates some valid character in the beginning of fid? At least in our database the most suitable columns that could be used as basis for fid are numeric, primary key taken from sequence or the kind. Now taking the most suitable column for fid by adddint "wfs_featureid" "ID" to LAYER METADATA section leads to non-standard result. Adding an underscore should make it valid for any client. Do WFS specialists agree?


The easiest fix would be to output the typename then a dot then the id. Apparently this is how both GeoServer and Ionic do things. The fid query support would need to be updated to reflect this new convention.

Change History (9)

comment:1 by sdlime, 17 years ago

Cc: bartvde@… added
Owner: changed from mapserverbugs to sdlime
Status: newassigned

comment:2 by sdlime, 17 years ago

I committed a change to the GML writer to write FIDs in the form typename.id so this should fix WFS output in 5.0. Might consider a backport because it looks as if you can't query by FID anyway so we could output anything there as long as it conformed to name spec mentioned in the description. I'd like to fix that query shortcoming but that's another bug.

Jukka, any chance you could try the main SVN branch?

Steve

comment:3 by tomkralidis, 17 years ago

Cc: tom.kralidis@… added

To confirm: I just tested this against r6142. Here's a snippet of the GetFeature response:

<gml:featureMember>

<owscat:service_endpoints fid="owscat:service_endpoints.1118"> <gml:boundedBy> <gml:Box srsName="EPSG:4326">\

so @fid is written out (as wfs_namespace_prefix:layer_name:MAP/LAYER/METADATA/gml_featureid), if MAP/LAYER/METADATA/gml_featureid is set. If it is not set, @fid is not output.

in reply to:  3 comment:4 by sdlime, 17 years ago

Replying to tomkralidis:

Nuts, I don't think that's quite what we want. The namespace prefix shouldn't be there. I think it should be:

<owscat:service_endpoints fid="service_endpoints.1118">

Correct? Your interpretation of when an FID is output is correct although I'm thinking that could change too. We could output the shape id if the FID metadata is not set. We really need to be able to query by FID then.

comment:5 by tomkralidis, 17 years ago

Fixed in r6143.

When you say shape id, do you mean any underlying data type (i.e. postgresql, mapinfo)?

Agreed querying by FID would be valuable.

in reply to:  5 ; comment:6 by sdlime, 17 years ago

Replying to tomkralidis:

Fixed in r6143.

Excellent, thanks!

When you say shape id, do you mean any underlying data type (i.e. postgresql, mapinfo)?

Each shape carries an integer ID that allows msLayerGetFeature() to work. It's an artifact of the two-stage query process. For a shapefile it's the sequential number in the file. PostGIS and the other drivers all have something equivalent. They are not stable over the long term so perhaps we should avoid and force users to set one.

Agreed querying by FID would be valuable.

By outputing the typename along with the ID this should be pretty easy and shouldn't require an RFC.

in reply to:  6 comment:7 by tomkralidis, 17 years ago

Replying to sdlime:

Replying to tomkralidis:

Fixed in r6143.

Excellent, thanks!

When you say shape id, do you mean any underlying data type (i.e. postgresql, mapinfo)?

Each shape carries an integer ID that allows msLayerGetFeature() to work. It's an artifact of the two-stage query process. For a shapefile it's the sequential number in the file. PostGIS and the other drivers all have something equivalent. They are not stable over the long term so perhaps we should avoid and force users to set one.

I agree that users should be setting this metadata, if it is important to them, and to keep persistence.

Agreed querying by FID would be valuable.

By outputing the typename along with the ID this should be pretty easy and shouldn't require an RFC.

Let's open another ticket for this one, and close this one...

comment:8 by tomkralidis, 17 years ago

I meant open another ticket for that one, and close this one :P

comment:9 by tomkralidis, 17 years ago

Resolution: fixed
Status: assignedclosed

Closing. #2102 covers implementation of querying by FID.

Note: See TracTickets for help on using tickets.