Let the read method respect readOptions and pass them to the format's read method. r=bartvde (closes #2957)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10947 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -142,12 +142,26 @@ OpenLayers.Protocol.WFS.v1 = OpenLayers.Class(OpenLayers.Protocol, {
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: read
|
||||
* APIMethod: read
|
||||
* Construct a request for reading new features. Since WFS splits the
|
||||
* basic CRUD operations into GetFeature requests (for read) and
|
||||
* Transactions (for all others), this method does not make use of the
|
||||
* format's read method (that is only about reading transaction
|
||||
* responses).
|
||||
*
|
||||
* To use a configured protocol to get e.g. a WFS hit count, applications
|
||||
* could do the following:
|
||||
*
|
||||
* (code)
|
||||
* protocol.read({
|
||||
* readOptions: {output: "object"},
|
||||
* resultType: "hits",
|
||||
* maxFeatures: null,
|
||||
* callback: function(resp) {
|
||||
* // process resp.numberOfFeatures here
|
||||
* }
|
||||
* });
|
||||
* (end)
|
||||
*/
|
||||
read: function(options) {
|
||||
OpenLayers.Protocol.prototype.read.apply(this, arguments);
|
||||
@@ -180,15 +194,18 @@ OpenLayers.Protocol.WFS.v1 = OpenLayers.Class(OpenLayers.Protocol, {
|
||||
* options - {Object} The user options passed to the read call.
|
||||
*/
|
||||
handleRead: function(response, options) {
|
||||
options = OpenLayers.Util.extend({}, options);
|
||||
OpenLayers.Util.applyDefaults(options, this.options);
|
||||
|
||||
if(options.callback) {
|
||||
var request = response.priv;
|
||||
if(request.status >= 200 && request.status < 300) {
|
||||
// success
|
||||
if (this.readOptions && this.readOptions.output == "object") {
|
||||
if (options.readOptions && options.readOptions.output == "object") {
|
||||
OpenLayers.Util.extend(response,
|
||||
this.parseResponse(request, this.readOptions));
|
||||
this.parseResponse(request, options.readOptions));
|
||||
} else {
|
||||
response.features = this.parseResponse(request);
|
||||
response.features = this.parseResponse(request, options.readOptions);
|
||||
}
|
||||
response.code = OpenLayers.Protocol.Response.SUCCESS;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user