Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#1648 closed feature (fixed)

Add WFS protocol

Reported by: tschaub Owned by: tschaub
Priority: critical Milestone: 2.8 Release
Component: Layer.Vector Version: 2.7 RC1
Keywords: Cc: adube@…
State: Complete

Description

The WFS protocol will work with a GML format by default and should allow for some version negotiation (or at least support multiple versions).

Attachments (2)

wfs.patch (60.5 KB) - added by tschaub 8 years ago.
add wfs protocol for 1.0 and 1.1
wfs_with_tests.patch (77.7 KB) - added by ahocevar 8 years ago.

Download all attachments as: .zip

Change History (29)

comment:1 Changed 8 years ago by tschaub

It makes sense to add a BBOX strategy at the same time. This depends on #1543.

comment:2 Changed 8 years ago by elemoine

patch-1648-r7825-A0.diff includes the BBOX strategy code and corresponding unit tests. Unit tests pass on FF2 and FF3.

comment:3 Changed 8 years ago by euzuro

  • State set to Review

comment:4 Changed 8 years ago by euzuro

  • Version changed from 2.6 to 2.7 RC1

Floating to RC1... vector-behavior patches will go in on RC2.

comment:5 Changed 8 years ago by tschaub

I'll update the patch for this when #1639 is done.

comment:6 Changed 8 years ago by tschaub

  • State changed from Review to Needs More Work

comment:7 Changed 8 years ago by tschaub

I'm moving the bbox patch to #1731.

comment:8 Changed 8 years ago by euzuro

  • Milestone changed from 2.7 Release to 2.8 Release

comment:9 Changed 8 years ago by tschaub

  • State changed from Needs More Work to Review

Tests pass in FF3. Needs more testing (contributions welcome).

comment:10 Changed 8 years ago by adube

  • Cc adube@… added

I installed TinyOWS on my laptop and willing to test this new feature. I'll post any comments here if I have any.

Alexandre
Mapgears

comment:11 Changed 8 years ago by adube

I've been trying to figure why tinyOWS keeps saying "xml is not valid" as response of the post query. Found out in the apache access_log the following :

element Query: Schemas validity error : Element '{http://www.opengis.net/wfs}Query', attribute 'srsName': The attribute 'srsName' is not allowed.

See also in attached WFS-basic.xsd

So, after the srsName removed from the query, tinyows returned xml ! The wfs-protocol.html example uses GeoServer, so maybe GS is less strict than tinyows for that matter...

comment:12 Changed 8 years ago by tschaub

I've been doing a bit more work on this and want to separate out wfs 1.1 from 1.0. This involves updating the filter formats (so fe 1.1 uses gml 3 and fe 1.0 uses gml 2 among other changes). I'm working on these changes in a sandbox.

Thanks for any additional help.

comment:13 Changed 8 years ago by tschaub

  • State changed from Review to Needs More Work

Ok, there are still some places where we take advantage of GeoServer being liberal in what it accepts (srsName on wfs:Query for example), but the WFS protocol and associated changes are getting close. See the topp/wfs sandbox if you want to give it a try.

Help with test writing in particular would be appreciated. This is also going to involve changes for filters and gml parsing.

comment:14 Changed 8 years ago by tschaub

This is now in good shape. Next task is separating out all the non WFS (Filter & GML) changes into separate tickets. One remaining issue is that we don't write a schemaLocation attribute that includes a reference to the feature type schema. Not sure for whom that is important.

comment:15 Changed 8 years ago by tschaub

Filter related changes now in #1790. This ticket now depends on that one.

comment:16 Changed 8 years ago by bjornharrtell

Been looking through the stuff in the sandbox and the changes looks good. There is one thing though I think is important about the usage of WFS/Filters and that is clear documentation about where it is possible and/or recommended that filters can be used as an option to an constructor or function.

I think it is useful to be able to filter as a part of a strategy on a Vector layer, but also when using the WFS protocol/format standalone. At one time a filter was put on the the Vector layer itself - I'm guessing this is no longer the case which I think is good, but at the same time I don't really follow where to use it now. I can only find it as a part of "Query" in the WFST/v1.js format. I think support for optional and arbitrary filters for both queries and transactions would be useful.

comment:17 Changed 8 years ago by bartvde

Tim, I tried your patch against 2.7, but found a few issues. Should this patch still be removing the BBOX writer Filter/v1.js since ticket:1731 made it into 2.7? Also, the examples/filter.html is a diff but there is no initial version in 2.7 (but maybe in your sandbox).

comment:18 Changed 8 years ago by bartvde

A more serious issue IMHO is that the protocol in filterDelete is writing XML stuff that should be done by the Format instead. Or am I missing something?

    /**
     * Method: filterDelete
     * Send a request that deletes all features by their filter.
     *
     * Parameters:
     * filter - {OpenLayers.Filter} filter
     */
    filterDelete: function(filter) {
        var root = this.format.writeNode("wfs:Transaction");

        var deleteNode = this.format.createElementNSPlus("wfs:Delete", {
            attributes: {
                typeName: (options.featureNS ? this.featurePrefix + ":" : "") +
                    options.featureType
            }
        });

        if(options.featureNS) {
            deleteNode.setAttribute("xmlns:" + this.featurePrefix, options.featureNS);
        }
        var filterNode = this.format.writeNode("ogc:Filter", filter);

        deleteNode.appendChild(filterNode);

        root.appendChild(deleteNode);

        var data = OpenLayers.Format.XML.prototype.write.apply(
            this.format, [root]
        );

        return OpenLayers.Request.POST({
            url: this.url,
            data: data
        });

    },

    CLASS_NAME: "OpenLayers.Protocol.WFS.v1"

comment:19 Changed 8 years ago by tschaub

Setting feature state is addressed in #1833 now.

comment:20 Changed 8 years ago by tschaub

This patch has now been pared down to just the wfs/wfst related stuff.

The wfs protocol depends on a few other patches getting committed first:

I'll set this ticket state to review when this patch has sufficient tests.

Changed 8 years ago by tschaub

add wfs protocol for 1.0 and 1.1

comment:21 Changed 8 years ago by ahocevar

  • Owner changed from tschaub to ahocevar

I am working on the tests now.

comment:22 Changed 8 years ago by ahocevar

  • State changed from Needs More Work to Review

Tests added; relevant tests pass in FF3 and IE7.

An update on the initial ticket description: the default format for the WFS protocol is not GML any more, but the new WFST format (also contained in this patch).

Changed 8 years ago by ahocevar

comment:23 Changed 8 years ago by ahocevar

  • Owner changed from ahocevar to tschaub

Tim, I added unit tests and all pass. This is great work and good to commit.

comment:24 Changed 8 years ago by ahocevar

  • State changed from Review to Commit

comment:25 follow-up: Changed 8 years ago by elemoine

An abort method was added to the Protocol base class. This method is called to abort the request that corresponds to the response argument it is passed. See [1] and [2].

[1]http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Protocol.js#L143

[2]http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Protocol/HTTP.js#L465

Could this abort method be added to the WFS Protocol class?

comment:26 Changed 8 years ago by tschaub

  • Resolution set to fixed
  • State changed from Commit to Complete
  • Status changed from new to closed

(In [8868]) Adding a WFS protocol. This allows for creating, reading, updating, and deleting features via WFS. Huge thanks to ahocevar for the test writing and review. r=ahocevar (closes #1648)

comment:27 in reply to: ↑ 25 Changed 8 years ago by tschaub

Replying to elemoine:

An abort method was added to the Protocol base class. This method is called to abort the request that corresponds to the response argument it is passed. See [1] and [2].

[1]http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Protocol.js#L143

[2]http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Protocol/HTTP.js#L465

Could this abort method be added to the WFS Protocol class?

Sure thing (with patch/tests). See #1943.

Note: See TracTickets for help on using tickets.