Hi,

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 following 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"
                       }, .....

Regards, Roald

P.S. I sent this to the dev list since trac is unusable atm.

--
Roald de Wit
Software Engineer
[email protected]

Commercial Support for Open Source GIS Software
http://lisasoft.com/LISAsoft/SupportedProducts/



The contents of this email are confidential and may be subject to legal or 
professional privilege and copyright. No representation is made that this email 
is free of viruses or other defects. If you have received this communication in 
error, you may not copy or distribute any part of it or otherwise disclose its 
contents to anyone. Please advise the sender of your incorrect receipt of this 
correspondence.
Index: lib/OpenLayers/Protocol/WFS/v1.js
===================================================================
--- lib/OpenLayers/Protocol/WFS/v1.js	(revision 9410)
+++ lib/OpenLayers/Protocol/WFS/v1.js	(working copy)
@@ -150,7 +150,7 @@
         options = OpenLayers.Util.extend({}, options);
         OpenLayers.Util.applyDefaults(options, this.options || {});
         var response = new OpenLayers.Protocol.Response({requestType: "read"});
-        
+
         var data = OpenLayers.Format.XML.prototype.write.apply(
             this.format, [this.format.writeNode("wfs:GetFeature", options)]
         );
@@ -209,7 +209,7 @@
         if(!doc || doc.length <= 0) {
             return null;
         }
-        return this.format.read(doc);
+        return this.readFormat ? this.readFormat.read(doc) : this.format.read(doc);
     },
 
     /**
Index: lib/OpenLayers/Format/WFST/v1.js
===================================================================
--- lib/OpenLayers/Format/WFST/v1.js	(revision 9410)
+++ lib/OpenLayers/Format/WFST/v1.js	(working copy)
@@ -180,6 +180,7 @@
                         service: "WFS",
                         version: this.version,
                         maxFeatures: options && options.maxFeatures,
+                        outputFormat: this.outputFormat,
                         "xsi:schemaLocation": this.schemaLocationAttr(options)
                     }
                 });
_______________________________________________
Dev mailing list
[email protected]
http://openlayers.org/mailman/listinfo/dev

Reply via email to