Ticket #2107 (closed feature: fixed)

Opened 4 years ago

Last modified 3 years ago

Patch for WFS Protocol to allow for different outputFormat

Reported by: rdewit Owned by: tschaub
Priority: minor Milestone: 2.9 Release
Component: Protocol.WFS Version: 2.8 RC3
Keywords: Cc: bartvde
State: Review

Description

I wanted to do something relatively simple that is not possible with the current WFS protocol: request a different outputFormat (JSON in my case).

The attached patch makes this possible. I'd like to get feedback on whether is is the right path to follow to get this done. If it looks good, I'll create appropriate tests.

Example use:

protocol: new OpenLayers.Protocol.WFS({
    readFormat: new OpenLayers.Format.GeoJSON(),
    formatOptions: {
        outputFormat: "JSON"
    }, .....

Attachments

wfs_protocol_custom_outputformat.diff Download (1.4 KB) - added by rdewit 4 years ago.
ticket2107.patch Download (4.9 KB) - added by bartvde 4 years ago.
patch which includes tests

Change History

Changed 4 years ago by rdewit

  Changed 4 years ago by bjornharrtell

Wanted to do the same today but found out I didn't understand enough about the relationship between WFS protocol and WFST format, in particularily the readers property on WFST/v1.js which seemed to require a "node" in the namespace "wfs" which I though meant it was somehow hardcoded to the standard WFS+GML XML-response. This looks great in my opinion, both code and choice of option properties.

follow-up: ↓ 4   Changed 4 years ago by bartvde

  • cc bartvde added

Roald, I think this approach makes sense. What I do not get is how your specified outputFormat gets written in the WFS query, since I do not see the outputFormat attribute implemented in Format WFST on Query. Is there another related patch?

  Changed 4 years ago by bartvde

see also ticket:2250 for the outputFormat attribute.

in reply to: ↑ 2   Changed 4 years ago by bartvde

Replying to bartvde:

Roald, I think this approach makes sense. What I do not get is how your specified outputFormat gets written in the WFS query, since I do not see the outputFormat attribute implemented in Format WFST on Query. Is there another related patch?

I missed the second part of your patch.

  Changed 4 years ago by bartvde

I'll close 2250 as a duplicate and I'll update this patch with tests.

  Changed 4 years ago by bartvde

  • state set to Review

Changed 4 years ago by bartvde

patch which includes tests

  Changed 4 years ago by bartvde

  • status changed from new to closed
  • state changed from Review to Complete
  • resolution set to fixed

(In [9725]) allow WFS protocol to use a different outputFormat, for instance json, patch by rdewit, r=me (closes #2107)

  Changed 3 years ago by igrcic

  • status changed from closed to reopened
  • state changed from Complete to Review
  • resolution fixed deleted

Hi,

what patch is commited excatly? Because I dont see changes for  http://svn.openlayers.org/trunk/openlayers/lib/OpenLayers/Format/WFST/v1.js

There is no: 74 * APIProperty: outputFormat 75 * {String} Optional output format for the WFS GetFeature requests 76 */ 77 outputFormat: null,

or

188 outputFormat: this.outputFormat options && options.outputFormat,

commited in trunk, while changes for lib/OpenLayers/Protocol/WFS/v1.js are visible.

  Changed 3 years ago by bartvde

  • status changed from reopened to closed
  • resolution set to fixed

Hi Ivan, see the changeset link r9725 so:

outputFormat: options && options.outputFormat,

just like maxFeatures. It is no APIProperty, it is passed in through the options. See the tests for examples.

  Changed 3 years ago by igrcic

Ah, ok so this patch is not same as  http://trac.openlayers.org/changeset/9725.

Like it is now we have to put

        protocol: new OpenLayers.Protocol.WFS({
            readFormat: new OpenLayers.Format.GeoJSON(),
            outputFormat: "JSON"
...
...

Am I right? Cheers

and not

formatOptions: {
                outputFormat: "JSON"
            }

follow-up: ↓ 12   Changed 3 years ago by bartvde

Hi Ivan, no you would still use:

var protocol = new OpenLayers.Protocol.WFS({ 
    url: "http://some.url.org", 
    featureNS: "http://namespace.org", 
    featureType: "type", 
    formatOptions: {outputFormat: 'json'}, 
    readFormat: new OpenLayers.Format.GeoJSON() 
}); 

in reply to: ↑ 11   Changed 3 years ago by bartvde

Replying to bartvde:

Hi Ivan, no you would still use: {{{ var protocol = new OpenLayers.Protocol.WFS({ url: " http://some.url.org", featureNS: " http://namespace.org", featureType: "type", formatOptions: {outputFormat: 'json'}, readFormat: new OpenLayers.Format.GeoJSON() }); }}}

This example is actually wrong, it needs to be:

 var protocol = new OpenLayers.Protocol.WFS({ 
     url: "http://some.url.org", 
     featureNS: "http://namespace.org", 
     featureType: "type", 
     outputFormat: 'json', 
     readFormat: new OpenLayers.Format.GeoJSON() 
 }); 
Note: See TracTickets for help on using tickets.