Ticket #2102 (new enhancement)

Opened 1 year ago

Last modified 3 months ago

[OGC:WFS] support query by featureid

Reported by: tomkralidis Assigned to: jmckenna
Priority: normal Milestone: 5.2.1 release
Component: MapServer Documentation Version:
Severity: normal Keywords:
Cc: sdlime, assefa, cplist

Description

OGC:WFS allows for GetFeature queries by feature id.

Use cases:

1./ WFS request HTTP GET with KVP

..and through WFS KVP, like:

http://example.org/wfs?service=WFS&version=1.0.0&request=GetFeature&featureid=roads.1013.

Note that, if featureid is found in the KVP, then typename is NOT required. Otherwise typename continues as mandatory.

2./ WFS request HTTP POST with Filter:

<?xml version="1.0" ?> <wfs:GetFeature service="WFS" version="1.0.0" outputFormat="GML2" xmlns:myns="http://www.someserver.com/myns" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs ../wfs/1.0.0/WFS-basic.xsd"> <wfs:Query typeName="myns:INWATERA_1M"> <ogc:Filter> <ogc:FeatureId fid="INWATERA_1M.1234"/> </ogc:Filter> </wfs:Query> </wfs:GetFeature>

FYI the KVP featureid is mutually exclusive with Filter and BBOX and can be one or more (comma separated) values. So we don't have to implement WFS HTTP GET with Filter encocding on Feature id (the logic being that this would be passed as a KVP request).

Background info:

OGC:WFS 1.0.0: http://portal.opengeospatial.org/files/?artifact_id=7176 OGC:FES 1.0.0: http://portal.opengeospatial.org/files/?artifact_id=1171

Info:

- the code would basically process the WFS request. If a feature filter (either case above), the a query by id type routine would be called against the column defined by MAP/LAYER/METADATA/gml_featureid

Issues:

- what happens if MAP/LAYER/METADATA/gml_featureid is NOT defined?

I'm not sure if this can be done in time for 5.0 (Steve: comments?), so I have not set a milestone.

Change History

05/25/07 23:57:20 changed by tomkralidis

  • cc changed from sdlime to sdlime, assefa.

correspondence from Assefa:

I think the work to be done is the following:

  • add in the parsing code a support <Filter> with ogc:FeatureIds.
  • as suggested I think we could build a valid <Filter> when used through WFS KVP

07/06/07 08:53:39 changed by assefa

  • status changed from new to assigned.
  • owner changed from mapserverbugs to assefa.

07/23/07 11:32:22 changed by assefa

The inention is to build an expression that looks something like:

([ows_feature_id_value] = value_in_filter1 OR [ows_feature_id_value] = value_in_filter2 ...)

This expression would be set on the filter element of the layer.

- which metadata should we use to lookup the featureid attribute ( msOWSLookupMetadata(&(lp->metadata), "OFG", "featureid") ??)

- do I need to take into account the namespace prefix attached to the featureid value (eg INWATERA_1M.1234) ? I guess I need to remove it before building the expression ?

07/23/07 18:19:29 changed by assefa

Initial support added for the HTTP POST with Filter and also a HTTP Get with a <Filter> parameter (r6370).

07/25/07 16:00:07 changed by assefa

Tom, is there a chache to do more testing on it in the coming days. I have started a bit and will correct bugs as I go (hopefully will be finsihed by the end of the week ready for beta2). Then more tests can be done on it

07/26/07 11:16:19 changed by cplist

  • cc changed from sdlime, assefa to sdlime, assefa, cplist.

07/30/07 17:50:37 changed by assefa

Correct bugs. Tested with few cases. r6419

wxs test to be added.

07/31/07 09:37:09 changed by tomkralidis

I can't get HTTP GET working (on trunk).

URL: http://devgeo.cciw.ca/cgi-bin/mapserv/sostest?service=WFS&version=1.0.0&request=GetFeature&featureid=observations.1990000162&

ows_featureid is set. However, when trying through ogrinfo I get results:

$ ogrinfo -al -where "SAMPLE_NU=1990000162" data/sos_test.shp

07/31/07 10:00:18 changed by assefa

Is your layer wfs valid with DUMP TRUE set ?

07/31/07 10:34:03 changed by tomkralidis

Whoops; it is now. Works now.

We should throw an exception if the layername / typename doesn't exist.

07/31/07 10:59:52 changed by assefa

something like this would do ?

msWFSGetFeature(): WFS server error. Invalid typename given with FeatureId? in GetFeature? : observationss

07/31/07 11:05:03 changed by tomkralidis

Yes.

07/31/07 11:11:02 changed by assefa

commited excpetion generation : r6424

07/31/07 12:58:36 changed by tomkralidis

  • status changed from assigned to new.
  • owner changed from assefa to jmckenna@dmsolutions.ca.

We should document the fact that we now need DUMP TRUE and gml_include_items. Before these weren't needed in the SOS implementation. Now they are.

Reassigned to Jeff for 5.0 docs.

07/31/07 13:48:22 changed by assefa

The FilterEncoding? doc should be updated with the FeatureId? support.

Section 2 "Currently Supported Features" should have a new entry Feature Identifier with the following text : "FeatureId? support added in 5.0. Note that the ows/wfs/gml_featureid must be defined on the layer to be able to search using a feature id"

I think the DUMP TRUE and gml_include_items are already documeneted with the wfs spec.

07/31/07 13:48:28 changed by assefa

  • milestone set to 5.0 release.

09/11/07 17:54:06 changed by jmckenna

  • owner changed from jmckenna@dmsolutions.ca to jmckenna.

01/22/08 11:20:54 changed by tomkralidis

  • component changed from WFS Server to MapServer Documentation.
  • milestone changed from 5.0 release to 5.2 release.

06/23/08 16:23:23 changed by tomkralidis

Assefa: in doing some research for #2599, I tested this again:

$ cd trunk/msautotest/wxs/
$ ../../mapserver/mapserv QUERY_STRING="map=wfs_simple.map&service=WFS&version=1.0.0&request=GetFeature&typename=province&featureid=province.Quebec"

...and I get all the features returned. I tried this on another WFS and got all the results again. Did something happen since this was implemented?

Please advise.

06/23/08 18:28:28 changed by assefa

tom, It was broken for some time. It should now work (r7733). Good thing that your are adding the msautotest.

06/23/08 18:32:01 changed by tomkralidis

Works. Thanks Assefa! Added msautotest in r7729 and r7734