WCS testing more-or-less working, many tests failing, as expected
This commit is contained in:
56
lib/OpenLayers/Format/WCSCapabilities.js
Normal file
56
lib/OpenLayers/Format/WCSCapabilities.js
Normal file
@@ -0,0 +1,56 @@
|
||||
/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Format/XML/VersionedOGC.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Format.WCSCapabilities
|
||||
* Read WCS Capabilities.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Format.XML.VersionedOGC>
|
||||
*/
|
||||
OpenLayers.Format.WCSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.VersionedOGC, {
|
||||
|
||||
/**
|
||||
* APIProperty: defaultVersion
|
||||
* {String} Version number to assume if none found. Default is "1.1.0".
|
||||
*/
|
||||
defaultVersion: "1.1.0",
|
||||
|
||||
/**
|
||||
* APIProperty: errorProperty
|
||||
* {String} Which property of the returned object to check for in order to
|
||||
* determine whether or not parsing has failed. In the case that the
|
||||
* errorProperty is undefined on the returned object, the document will be
|
||||
* run through an OGCExceptionReport parser.
|
||||
*/
|
||||
errorProperty: "service",
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Format.WCSCapabilities
|
||||
* Create a new parser for WCS capabilities.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object whose properties will be set on
|
||||
* this instance.
|
||||
*/
|
||||
|
||||
/**
|
||||
* APIMethod: read
|
||||
* Read capabilities data from a string, and return a list of layers.
|
||||
*
|
||||
* Parameters:
|
||||
* data - {String} or {DOMElement} data to read/parse.
|
||||
*
|
||||
* Returns:
|
||||
* {Array} List of named layers.
|
||||
*/
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format.WCSCapabilities"
|
||||
|
||||
});
|
||||
108
lib/OpenLayers/Format/WCSCapabilities/v1.js
Normal file
108
lib/OpenLayers/Format/WCSCapabilities/v1.js
Normal file
@@ -0,0 +1,108 @@
|
||||
/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Format/WCSCapabilities.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Format.WCSCapabilities.v1
|
||||
* Abstract class not to be instantiated directly.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Format.XML>
|
||||
*/
|
||||
OpenLayers.Format.WCSCapabilities.v1 = OpenLayers.Class(
|
||||
OpenLayers.Format.XML, {
|
||||
|
||||
/**
|
||||
* Property: namespaces
|
||||
* {Object} Mapping of namespace aliases to namespace URIs.
|
||||
*/
|
||||
namespaces: {
|
||||
wcs: "http://www.opengis.net/wcs",
|
||||
xlink: "http://www.w3.org/1999/xlink",
|
||||
xsi: "http://www.w3.org/2001/XMLSchema-instance",
|
||||
ows: "http://www.opengis.net/ows"
|
||||
},
|
||||
|
||||
/**
|
||||
* Property: defaultPrefix
|
||||
*/
|
||||
defaultPrefix: "wcs",
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Format.WCSCapabilities.v1_1
|
||||
* Create an instance of one of the subclasses.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object whose properties will be set on
|
||||
* this instance.
|
||||
*/
|
||||
|
||||
/**
|
||||
* APIMethod: read
|
||||
* Read capabilities data from a string, and return a list of layers.
|
||||
*
|
||||
* Parameters:
|
||||
* data - {String} or {DOMElement} data to read/parse.
|
||||
*
|
||||
* Returns:
|
||||
* {Array} List of named layers.
|
||||
*/
|
||||
read: function(data) {
|
||||
if(typeof data == "string") {
|
||||
data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
|
||||
}
|
||||
var raw = data;
|
||||
if(data && data.nodeType == 9) {
|
||||
data = data.documentElement;
|
||||
}
|
||||
var capabilities = {};
|
||||
this.readNode(data, capabilities);
|
||||
return capabilities;
|
||||
},
|
||||
|
||||
/**
|
||||
* Property: readers
|
||||
* Contains public functions, grouped by namespace prefix, that will
|
||||
* be applied when a namespaced node is found matching the function
|
||||
* name. The function will be applied in the scope of this parser
|
||||
* with two arguments: the node being read and a context object passed
|
||||
* from the parent.
|
||||
*/
|
||||
readers: {
|
||||
"wcs": {
|
||||
"WCS_Capabilities": function(node, obj) { // In 1.0.0, this was WCS_Capabilties, changed in 1.1.0
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
"Name": function(node, obj) { //????
|
||||
var name = this.getChildValue(node);
|
||||
if(name) {
|
||||
var parts = name.split(":");
|
||||
obj.name = parts.pop();
|
||||
if(parts.length > 0) {
|
||||
obj.featureNS = this.lookupNamespaceURI(node, parts[0]);
|
||||
}
|
||||
}
|
||||
},
|
||||
"Title": function(node, obj) {
|
||||
var title = this.getChildValue(node);
|
||||
if(title) {
|
||||
obj.title = title;
|
||||
}
|
||||
},
|
||||
"Abstract": function(node, obj) {
|
||||
var abst = this.getChildValue(node);
|
||||
if(abst) {
|
||||
obj["abstract"] = abst;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format.WCSCapabilities.v1"
|
||||
|
||||
});
|
||||
115
lib/OpenLayers/Format/WCSCapabilities/v1_0_0.js
Normal file
115
lib/OpenLayers/Format/WCSCapabilities/v1_0_0.js
Normal file
@@ -0,0 +1,115 @@
|
||||
/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Format/WCSCapabilities/v1.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Format.WCSCapabilities/v1_0_0
|
||||
* Read WCS Capabilities version 1.0.0.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Format.WCSCapabilities.v1>
|
||||
*/
|
||||
OpenLayers.Format.WCSCapabilities.v1_0_0 = OpenLayers.Class(
|
||||
OpenLayers.Format.WCSCapabilities.v1, {
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Format.WCSCapabilities.v1_0_0
|
||||
* Create a new parser for WCS capabilities version 1.0.0.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object whose properties will be set on
|
||||
* this instance.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Property: readers
|
||||
* Contains public functions, grouped by namespace prefix, that will
|
||||
* be applied when a namespaced node is found matching the function
|
||||
* name. The function will be applied in the scope of this parser
|
||||
* with two arguments: the node being read and a context object passed
|
||||
* from the parent.
|
||||
*/
|
||||
readers: {
|
||||
"wcs": OpenLayers.Util.applyDefaults({
|
||||
"Service": function(node, capabilities) {
|
||||
capabilities.service = {};
|
||||
this.readChildNodes(node, capabilities.service);
|
||||
},
|
||||
"Fees": function(node, service) {
|
||||
var fees = this.getChildValue(node);
|
||||
if (fees && fees.toLowerCase() != "none") {
|
||||
service.fees = fees;
|
||||
}
|
||||
},
|
||||
"AccessConstraints": function(node, service) {
|
||||
var constraints = this.getChildValue(node);
|
||||
if (constraints && constraints.toLowerCase() != "none") {
|
||||
service.accessConstraints = constraints;
|
||||
}
|
||||
},
|
||||
"OnlineResource": function(node, service) {
|
||||
var onlineResource = this.getChildValue(node);
|
||||
if (onlineResource && onlineResource.toLowerCase() != "none") {
|
||||
service.onlineResource = onlineResource;
|
||||
}
|
||||
},
|
||||
"Keywords": function(node, service) {
|
||||
var keywords = this.getChildValue(node);
|
||||
if (keywords && keywords.toLowerCase() != "none") {
|
||||
service.keywords = keywords.split(', ');
|
||||
}
|
||||
},
|
||||
"Capability": function(node, capabilities) {
|
||||
capabilities.capability = {};
|
||||
this.readChildNodes(node, capabilities.capability);
|
||||
},
|
||||
"Request": function(node, obj) {
|
||||
obj.request = {};
|
||||
this.readChildNodes(node, obj.request);
|
||||
},
|
||||
"GetFeature": function(node, request) {
|
||||
request.getfeature = {
|
||||
href: {}, // DCPType
|
||||
formats: [] // ResultFormat
|
||||
};
|
||||
this.readChildNodes(node, request.getfeature);
|
||||
},
|
||||
"ResultFormat": function(node, obj) {
|
||||
var children = node.childNodes;
|
||||
var childNode;
|
||||
for(var i=0; i<children.length; i++) {
|
||||
childNode = children[i];
|
||||
if(childNode.nodeType == 1) {
|
||||
obj.formats.push(childNode.nodeName);
|
||||
}
|
||||
}
|
||||
},
|
||||
"DCPType": function(node, obj) {
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
"HTTP": function(node, obj) {
|
||||
this.readChildNodes(node, obj.href);
|
||||
},
|
||||
"Get": function(node, obj) {
|
||||
obj.get = node.getAttribute("onlineResource");
|
||||
},
|
||||
"Post": function(node, obj) {
|
||||
obj.post = node.getAttribute("onlineResource");
|
||||
},
|
||||
"SRS": function(node, obj) {
|
||||
var srs = this.getChildValue(node);
|
||||
if (srs) {
|
||||
obj.srs = srs;
|
||||
}
|
||||
}
|
||||
}, OpenLayers.Format.WCSCapabilities.v1.prototype.readers["wcs"])
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format.WCSCapabilities.v1_0_0"
|
||||
|
||||
});
|
||||
99
lib/OpenLayers/Format/WCSCapabilities/v1_1_0.js
Normal file
99
lib/OpenLayers/Format/WCSCapabilities/v1_1_0.js
Normal file
@@ -0,0 +1,99 @@
|
||||
/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Format/WCSCapabilities/v1.js
|
||||
* @requires OpenLayers/Format/OWSCommon/v1.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Format.WCSCapabilities/v1_1_0
|
||||
* Read WCS Capabilities version 1.1.0.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Format.WCSCapabilities>
|
||||
*/
|
||||
OpenLayers.Format.WCSCapabilities.v1_1_0 = OpenLayers.Class(
|
||||
OpenLayers.Format.WCSCapabilities.v1, {
|
||||
|
||||
/**
|
||||
* Property: regExes
|
||||
* Compiled regular expressions for manipulating strings.
|
||||
*/
|
||||
regExes: {
|
||||
trimSpace: (/^\s*|\s*$/g),
|
||||
removeSpace: (/\s*/g),
|
||||
splitSpace: (/\s+/),
|
||||
trimComma: (/\s*,\s*/g)
|
||||
},
|
||||
|
||||
|
||||
errorProperty: "Contents", // <== Not sure if this is strictly required by standard... maybe better to set to NULL?
|
||||
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Format.WCSCapabilities.v1_1_0
|
||||
* Create a new parser for WCS capabilities version 1.1.0.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object whose properties will be set on
|
||||
* this instance.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Property: readers
|
||||
* Contains public functions, grouped by namespace prefix, that will
|
||||
* be applied when a namespaced node is found matching the function
|
||||
* name. The function will be applied in the scope of this parser
|
||||
* with two arguments: the node being read and a context object passed
|
||||
* from the parent.
|
||||
*/
|
||||
readers: {
|
||||
"wcs": OpenLayers.Util.applyDefaults({
|
||||
"Capabilities": function(node, obj) { // In 1.0.0, this was WCS_Capabilties, in 1.1.0, it's just Capabilities
|
||||
this.readChildNodes(node, obj);
|
||||
},
|
||||
|
||||
"Contents": function(node, request) {
|
||||
request.featureTypeList = {
|
||||
contents: []
|
||||
};
|
||||
this.readChildNodes(node, request.contents);
|
||||
},
|
||||
|
||||
"CoverageSummary": function(node, request) {
|
||||
request.featureTypeList = {
|
||||
coverageSummary: []
|
||||
};
|
||||
this.readChildNodes(node, request.coverageSummary);
|
||||
},
|
||||
|
||||
"Identifier": function(node, obj) {
|
||||
obj.identifier = this.getChildValue(node);
|
||||
},
|
||||
|
||||
"SupportedCRS": function(node, obj) {
|
||||
var crs = this.getChildValue(node);
|
||||
if(crs) {
|
||||
if(!obj["supportedCRS"]) {
|
||||
obj["supportedCRS"] = [];
|
||||
}
|
||||
obj["supportedCRS"].push(crs);
|
||||
}
|
||||
},
|
||||
|
||||
"DefaultSRS": function(node, obj) {
|
||||
var defaultSRS = this.getChildValue(node);
|
||||
if (defaultSRS) {
|
||||
obj.srs = defaultSRS;
|
||||
}
|
||||
}
|
||||
}, OpenLayers.Format.WCSCapabilities.v1.prototype.readers["wcs"]),
|
||||
"ows": OpenLayers.Format.OWSCommon.v1.prototype.readers["ows"]
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format.WCSCapabilities.v1_1_0"
|
||||
|
||||
});
|
||||
86
lib/OpenLayers/Protocol/WCS.js
Normal file
86
lib/OpenLayers/Protocol/WCS.js
Normal file
@@ -0,0 +1,86 @@
|
||||
/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Protocol.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Protocol.WCS
|
||||
* Used to create a versioned WCS protocol. Default version is 1.0.0.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Protocol>} A WCS protocol of the given version.
|
||||
*
|
||||
* Example:
|
||||
* (code)
|
||||
* var protocol = new OpenLayers.Protocol.WCS({
|
||||
* version: "1.1.0",
|
||||
* url: "http://demo.opengeo.org/geoserver/wcs",
|
||||
* featureType: "tasmania_roads",
|
||||
* featureNS: "http://www.openplans.org/topp",
|
||||
* geometryName: "the_geom"
|
||||
* });
|
||||
* (end)
|
||||
*
|
||||
* See the protocols for specific WCS versions for more detail.
|
||||
*/
|
||||
OpenLayers.Protocol.WCS = function(options) {
|
||||
options = OpenLayers.Util.applyDefaults(
|
||||
options, OpenLayers.Protocol.WCS.DEFAULTS
|
||||
);
|
||||
var cls = OpenLayers.Protocol.WCS["v"+options.version.replace(/\./g, "_")];
|
||||
if(!cls) {
|
||||
throw "Unsupported WCS version: " + options.version;
|
||||
}
|
||||
return new cls(options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function: fromWMSLayer
|
||||
* Convenience function to create a WCS protocol from a WMS layer. This makes
|
||||
* the assumption that a WCS requests can be issued at the same URL as
|
||||
* WMS requests and that a WCS featureType exists with the same name as the
|
||||
* WMS layer.
|
||||
*
|
||||
* This function is designed to auto-configure <url>, <featureType>,
|
||||
* <featurePrefix> and <srsName> for WCS <version> 1.1.0. Note that
|
||||
* srsName matching with the WMS layer will not work with WCS 1.0.0.
|
||||
*
|
||||
* Parameters:
|
||||
* layer - {<OpenLayers.Layer.WMS>} WMS layer that has a matching WCS
|
||||
* FeatureType at the same server url with the same typename.
|
||||
* options - {Object} Default properties to be set on the protocol.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Protocol.WCS>}
|
||||
*/
|
||||
OpenLayers.Protocol.WCS.fromWMSLayer = function(layer, options) {
|
||||
var typeName, featurePrefix;
|
||||
var param = layer.params["LAYERS"];
|
||||
var parts = (OpenLayers.Util.isArray(param) ? param[0] : param).split(":");
|
||||
if(parts.length > 1) {
|
||||
featurePrefix = parts[0];
|
||||
}
|
||||
typeName = parts.pop();
|
||||
var protocolOptions = {
|
||||
url: layer.url,
|
||||
featureType: typeName,
|
||||
featurePrefix: featurePrefix,
|
||||
srsName: layer.projection && layer.projection.getCode() ||
|
||||
layer.map && layer.map.getProjectionObject().getCode(),
|
||||
version: "1.1.0"
|
||||
};
|
||||
return new OpenLayers.Protocol.WCS(OpenLayers.Util.applyDefaults(
|
||||
options, protocolOptions
|
||||
));
|
||||
};
|
||||
|
||||
/**
|
||||
* Constant: OpenLayers.Protocol.WCS.DEFAULTS
|
||||
*/
|
||||
OpenLayers.Protocol.WCS.DEFAULTS = {
|
||||
"version": "1.0.0"
|
||||
};
|
||||
434
lib/OpenLayers/Protocol/WCS/v1.js
Normal file
434
lib/OpenLayers/Protocol/WCS/v1.js
Normal file
@@ -0,0 +1,434 @@
|
||||
/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Protocol/WCS.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Protocol.WCS.v1
|
||||
* Abstract class for for v1.0.0 and v1.1.0 protocol.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Protocol>
|
||||
*/
|
||||
OpenLayers.Protocol.WCS.v1 = OpenLayers.Class(OpenLayers.Protocol, {
|
||||
|
||||
/**
|
||||
* Property: version
|
||||
* {String} WCS version number.
|
||||
*/
|
||||
version: null,
|
||||
|
||||
/**
|
||||
* Property: srsName
|
||||
* {String} Name of spatial reference system. Default is "EPSG:4326".
|
||||
*/
|
||||
srsName: "EPSG:4326",
|
||||
|
||||
/**
|
||||
* Property: featureType
|
||||
* {String} Local feature typeName.
|
||||
*/
|
||||
featureType: null,
|
||||
|
||||
/**
|
||||
* Property: featureNS
|
||||
* {String} Feature namespace.
|
||||
*/
|
||||
featureNS: null,
|
||||
|
||||
/**
|
||||
* Property: geometryName
|
||||
* {String} Name of the geometry attribute for features. Default is
|
||||
* "the_geom" for WCS <version> 1.0, and null for higher versions.
|
||||
*/
|
||||
geometryName: "the_geom",
|
||||
|
||||
/**
|
||||
* Property: schema
|
||||
* {String} Optional schema location that will be included in the
|
||||
* schemaLocation attribute value. Note that the feature type schema
|
||||
* is required for a strict XML validator (on transactions with an
|
||||
* insert for example), but is *not* required by the WCS specification
|
||||
* (since the server is supposed to know about feature type schemas).
|
||||
*/
|
||||
schema: null,
|
||||
|
||||
/**
|
||||
* Property: featurePrefix
|
||||
* {String} Namespace alias for feature type. Default is "feature".
|
||||
*/
|
||||
featurePrefix: "feature",
|
||||
|
||||
/**
|
||||
* Property: formatOptions
|
||||
* {Object} Optional options for the format. If a format is not provided,
|
||||
* this property can be used to extend the default format options.
|
||||
*/
|
||||
formatOptions: null,
|
||||
|
||||
/**
|
||||
* Property: readFormat
|
||||
*/
|
||||
readFormat: null,
|
||||
|
||||
/**
|
||||
* Property: readOptions
|
||||
* {Object} Optional object to pass to format's read.
|
||||
*/
|
||||
readOptions: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Protocol.WCS
|
||||
* A class for giving layers WCS protocol.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} Optional object whose properties will be set on the
|
||||
* instance.
|
||||
*
|
||||
* Valid options properties:
|
||||
* url - {String} URL to send requests to (required).
|
||||
* featureType - {String} Local (without prefix) feature typeName (required).
|
||||
* featureNS - {String} Feature namespace (required, but can be autodetected
|
||||
* during the first query if GML is used as readFormat and
|
||||
* featurePrefix is provided and matches the prefix used by the server
|
||||
* for this featureType).
|
||||
* featurePrefix - {String} Feature namespace alias (optional - only used
|
||||
* for writing if featureNS is provided). Default is 'feature'.
|
||||
* geometryName - {String} Name of geometry attribute. The default is
|
||||
* 'the_geom' for WCS <version> 1.0, and null for higher versions. If
|
||||
* null, it will be set to the name of the first geometry found in the
|
||||
* first read operation.
|
||||
* multi - {Boolean} If set to true, geometries will be casted to Multi
|
||||
* geometries before they are written in a transaction. No casting will
|
||||
* be done when reading features.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Protocol.prototype.initialize.apply(this, [options]);
|
||||
|
||||
if (!options.geometryName && parseFloat(this.format.version) > 1.0) {
|
||||
this.setGeometryName(null);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
* Clean up the protocol.
|
||||
*/
|
||||
destroy: function() {
|
||||
if(this.options && !this.options.format) {
|
||||
this.format.destroy();
|
||||
}
|
||||
this.format = null;
|
||||
OpenLayers.Protocol.prototype.destroy.apply(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: read
|
||||
* Construct a request for reading new features. Since WCS 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).
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} Options for the read operation, in addition to the
|
||||
* options set on the instance (options set here will take precedence).
|
||||
*
|
||||
* To use a configured protocol to get e.g. a WCS 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)
|
||||
*
|
||||
* To use a configured protocol to use WCS paging (if supported by the
|
||||
* server), applications could do the following:
|
||||
*
|
||||
* (code)
|
||||
* protocol.read({
|
||||
* startIndex: 0,
|
||||
* count: 50
|
||||
* });
|
||||
* (end)
|
||||
*
|
||||
* To limit the attributes returned by the GetFeature request, applications
|
||||
* can use the propertyNames option to specify the properties to include in
|
||||
* the response:
|
||||
*
|
||||
* (code)
|
||||
* protocol.read({
|
||||
* propertyNames: ["DURATION", "INTENSITY"]
|
||||
* });
|
||||
* (end)
|
||||
*/
|
||||
read: function(options) {
|
||||
OpenLayers.Protocol.prototype.read.apply(this, arguments);
|
||||
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("wcs:GetFeature", options)]
|
||||
);
|
||||
|
||||
response.priv = OpenLayers.Request.POST({
|
||||
url: options.url,
|
||||
callback: this.createCallback(this.handleRead, response, options),
|
||||
params: options.params,
|
||||
headers: options.headers,
|
||||
data: data
|
||||
});
|
||||
|
||||
return response;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: setFeatureType
|
||||
* Change the feature type on the fly.
|
||||
*
|
||||
* Parameters:
|
||||
* featureType - {String} Local (without prefix) feature typeName.
|
||||
*/
|
||||
setFeatureType: function(featureType) {
|
||||
this.featureType = featureType;
|
||||
this.format.featureType = featureType;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: setGeometryName
|
||||
* Sets the geometryName option after instantiation.
|
||||
*
|
||||
* Parameters:
|
||||
* geometryName - {String} Name of geometry attribute.
|
||||
*/
|
||||
setGeometryName: function(geometryName) {
|
||||
this.geometryName = geometryName;
|
||||
this.format.geometryName = geometryName;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: handleRead
|
||||
* Deal with response from the read request.
|
||||
*
|
||||
* Parameters:
|
||||
* response - {<OpenLayers.Protocol.Response>} The response object to pass
|
||||
* to the user callback.
|
||||
* 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
|
||||
var result = this.parseResponse(request, options.readOptions);
|
||||
if (result && result.success !== false) {
|
||||
if (options.readOptions && options.readOptions.output == "object") {
|
||||
OpenLayers.Util.extend(response, result);
|
||||
} else {
|
||||
response.features = result;
|
||||
}
|
||||
response.code = OpenLayers.Protocol.Response.SUCCESS;
|
||||
} else {
|
||||
// failure (service exception)
|
||||
response.code = OpenLayers.Protocol.Response.FAILURE;
|
||||
response.error = result;
|
||||
}
|
||||
} else {
|
||||
// failure
|
||||
response.code = OpenLayers.Protocol.Response.FAILURE;
|
||||
}
|
||||
options.callback.call(options.scope, response);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: parseResponse
|
||||
* Read HTTP response body and return features
|
||||
*
|
||||
* Parameters:
|
||||
* request - {XMLHttpRequest} The request object
|
||||
* options - {Object} Optional object to pass to format's read
|
||||
*
|
||||
* Returns:
|
||||
* {Object} or {Array({<OpenLayers.Feature.Vector>})} or
|
||||
* {<OpenLayers.Feature.Vector>}
|
||||
* An object with a features property, an array of features or a single
|
||||
* feature.
|
||||
*/
|
||||
parseResponse: function(request, options) {
|
||||
var doc = request.responseXML;
|
||||
if(!doc || !doc.documentElement) {
|
||||
doc = request.responseText;
|
||||
}
|
||||
if(!doc || doc.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
var result = (this.readFormat !== null) ? this.readFormat.read(doc) :
|
||||
this.format.read(doc, options);
|
||||
if (!this.featureNS) {
|
||||
var format = this.readFormat || this.format;
|
||||
this.featureNS = format.featureNS;
|
||||
// no need to auto-configure again on subsequent reads
|
||||
format.autoConfig = false;
|
||||
if (!this.geometryName) {
|
||||
this.setGeometryName(format.geometryName);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: commit
|
||||
* Given a list of feature, assemble a batch request for update, create,
|
||||
* and delete transactions. A commit call on the prototype amounts
|
||||
* to writing a WCS transaction - so the write method on the format
|
||||
* is used.
|
||||
*
|
||||
* Parameters:
|
||||
* features - {Array(<OpenLayers.Feature.Vector>)}
|
||||
* options - {Object}
|
||||
*
|
||||
* Valid options properties:
|
||||
* nativeElements - {Array({Object})} Array of objects with information for writing
|
||||
* out <Native> elements, these objects have vendorId, safeToIgnore and
|
||||
* value properties. The <Native> element is intended to allow access to
|
||||
* vendor specific capabilities of any particular web feature server or
|
||||
* datastore.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Protocol.Response>} A response object with a features
|
||||
* property containing any insertIds and a priv property referencing
|
||||
* the XMLHttpRequest object.
|
||||
*/
|
||||
commit: function(features, options) {
|
||||
|
||||
options = OpenLayers.Util.extend({}, options);
|
||||
OpenLayers.Util.applyDefaults(options, this.options);
|
||||
|
||||
var response = new OpenLayers.Protocol.Response({
|
||||
requestType: "commit",
|
||||
reqFeatures: features
|
||||
});
|
||||
response.priv = OpenLayers.Request.POST({
|
||||
url: options.url,
|
||||
headers: options.headers,
|
||||
data: this.format.write(features, options),
|
||||
callback: this.createCallback(this.handleCommit, response, options)
|
||||
});
|
||||
|
||||
return response;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: handleCommit
|
||||
* Called when the commit request returns.
|
||||
*
|
||||
* Parameters:
|
||||
* response - {<OpenLayers.Protocol.Response>} The response object to pass
|
||||
* to the user callback.
|
||||
* options - {Object} The user options passed to the commit call.
|
||||
*/
|
||||
handleCommit: function(response, options) {
|
||||
if(options.callback) {
|
||||
var request = response.priv;
|
||||
|
||||
// ensure that we have an xml doc
|
||||
var data = request.responseXML;
|
||||
if(!data || !data.documentElement) {
|
||||
data = request.responseText;
|
||||
}
|
||||
|
||||
var obj = this.format.read(data) || {};
|
||||
|
||||
response.insertIds = obj.insertIds || [];
|
||||
if (obj.success) {
|
||||
response.code = OpenLayers.Protocol.Response.SUCCESS;
|
||||
} else {
|
||||
response.code = OpenLayers.Protocol.Response.FAILURE;
|
||||
response.error = obj;
|
||||
}
|
||||
options.callback.call(options.scope, response);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: filterDelete
|
||||
* Send a request that deletes all features by their filter.
|
||||
*
|
||||
* Parameters:
|
||||
* filter - {<OpenLayers.Filter>} filter
|
||||
*/
|
||||
filterDelete: function(filter, options) {
|
||||
options = OpenLayers.Util.extend({}, options);
|
||||
OpenLayers.Util.applyDefaults(options, this.options);
|
||||
|
||||
var response = new OpenLayers.Protocol.Response({
|
||||
requestType: "commit"
|
||||
});
|
||||
|
||||
var root = this.format.createElementNSPlus("wcs:Transaction", {
|
||||
attributes: {
|
||||
service: "WCS",
|
||||
version: this.version
|
||||
}
|
||||
});
|
||||
|
||||
var deleteNode = this.format.createElementNSPlus("wcs: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,
|
||||
callback : options.callback || function(){},
|
||||
data: data
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: abort
|
||||
* Abort an ongoing request, the response object passed to
|
||||
* this method must come from this protocol (as a result
|
||||
* of a read, or commit operation).
|
||||
*
|
||||
* Parameters:
|
||||
* response - {<OpenLayers.Protocol.Response>}
|
||||
*/
|
||||
abort: function(response) {
|
||||
if (response) {
|
||||
response.priv.abort();
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Protocol.WCS.v1"
|
||||
});
|
||||
43
lib/OpenLayers/Protocol/WCS/v1_0_0.js
Normal file
43
lib/OpenLayers/Protocol/WCS/v1_0_0.js
Normal file
@@ -0,0 +1,43 @@
|
||||
/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Protocol/WCS/v1.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Protocol.WCS.v1_0_0
|
||||
* A WCS v1.0.0 protocol for vector layers. Create a new instance with the
|
||||
* <OpenLayers.Protocol.WCS.v1_0_0> constructor.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Protocol.WCS.v1>
|
||||
*/
|
||||
OpenLayers.Protocol.WCS.v1_0_0 = OpenLayers.Class(OpenLayers.Protocol.WCS.v1, {
|
||||
|
||||
/**
|
||||
* Property: version
|
||||
* {String} WCS version number.
|
||||
*/
|
||||
version: "1.0.0",
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Protocol.WCS.v1_0_0
|
||||
* A class for giving layers WCS v1.0.0 protocol.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} Optional object whose properties will be set on the
|
||||
* instance.
|
||||
*
|
||||
* Valid options properties:
|
||||
* featureType - {String} Local (without prefix) feature typeName (required).
|
||||
* featureNS - {String} Feature namespace (optional).
|
||||
* featurePrefix - {String} Feature namespace alias (optional - only used
|
||||
* if featureNS is provided). Default is 'feature'.
|
||||
* geometryName - {String} Name of geometry attribute. Default is 'the_geom'.
|
||||
*/
|
||||
|
||||
CLASS_NAME: "OpenLayers.Protocol.WCS.v1_0_0"
|
||||
});
|
||||
37
lib/OpenLayers/Protocol/WCS/v1_1_0.js
Normal file
37
lib/OpenLayers/Protocol/WCS/v1_1_0.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/* ======================================================================
|
||||
OpenLayers/Protocol/WCS/v1_1_0.js
|
||||
====================================================================== */
|
||||
|
||||
/* Copyright (c) 2006-2012 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Protocol/WCS/v1.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Protocol.WCS.v1_1_0
|
||||
* A WCS v1.1.0 protocol for vector layers. Create a new instance with the
|
||||
* <OpenLayers.Protocol.WCS.v1_1_0> constructor.
|
||||
*
|
||||
* Differences from the v1.0.0 protocol:
|
||||
* - uses Filter Encoding 1.1.0 instead of 1.0.0
|
||||
* - uses GML 3 instead of 2 if no format is provided
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Protocol.WCS.v1>
|
||||
*/
|
||||
OpenLayers.Protocol.WCS.v1_1_0 = OpenLayers.Class(OpenLayers.Protocol.WCS.v1, {
|
||||
|
||||
/**
|
||||
* Property: version
|
||||
* {String} WCS version number.
|
||||
*/
|
||||
version: "1.1.0",
|
||||
|
||||
|
||||
|
||||
CLASS_NAME: "OpenLayers.Protocol.WCS.v1_1_0"
|
||||
});
|
||||
Reference in New Issue
Block a user