1 /* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3 * full text of the license. */
6 * @requires OpenLayers/Protocol.js
10 * Function: OpenLayers.Protocol.WFS
11 * Used to create a versioned WFS protocol. Default version is 1.0.0.
14 * {<OpenLayers.Protocol>} A WFS protocol of the given version.
16 OpenLayers.Protocol.WFS = function(options) {
17 options = OpenLayers.Util.applyDefaults(
18 options, OpenLayers.Protocol.WFS.DEFAULTS
20 var cls = OpenLayers.Protocol.WFS["v"+options.version.replace(/\./g, "_")];
22 throw "Unsupported WFS version: " + options.version;
24 return new cls(options);
28 * Function: OpenLayers.Protocol.WFS.fromWMSLayer
29 * Convenience function to create a WFS protocol from a WMS layer. This makes
30 * the assumption that a WFS requests can be issued at the same URL as
31 * WMS requests and that a WFS featureType exists with the same name as the
34 * This function is designed to auto-configure <url>, <featureType>,
35 * <featurePrefix> and <srsName> for WFS <version> 1.1.0. Note that
36 * srsName matching with the WMS layer will not work with WFS 1.0.0..
39 * layer - {<OpenLayers.Layer.WMS>} WMS layer that has a matching WFS
40 * FeatureType at the same server url with the same typename.
41 * options - {Object} Default properties to be set on the protocol.
44 OpenLayers.Protocol.WFS.fromWMSLayer = function(layer, options) {
45 var typeName, featurePrefix;
46 var param = layer.params["LAYERS"];
47 var parts = (param instanceof Array ? param[0] : param).split(":");
48 if(parts.length > 1) {
49 featurePrefix = parts[0];
51 typeName = parts.pop();
52 var protocolOptions = {
54 featureType: typeName,
55 featurePrefix: featurePrefix,
56 srsName: layer.projection && layer.projection.getCode() ||
57 layer.map && layer.map.getProjectionObject().getCode(),
60 return new OpenLayers.Protocol.WFS(OpenLayers.Util.applyDefaults(
61 options, protocolOptions
66 * Constant: OpenLayers.Protocol.WFS.DEFAULTS
68 OpenLayers.Protocol.WFS.DEFAULTS = {