don't use null geometryName for WFS versions < 1.1. r=elemoine (closes #3415)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@12216 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2011-08-08 13:22:59 +00:00
parent c518df57e7
commit 51efcde523
3 changed files with 13 additions and 11 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ OpenLayers.Protocol.WFS = function(options) {
* *
* This function is designed to auto-configure <url>, <featureType>, * This function is designed to auto-configure <url>, <featureType>,
* <featurePrefix> and <srsName> for WFS <version> 1.1.0. Note that * <featurePrefix> and <srsName> for WFS <version> 1.1.0. Note that
* srsName matching with the WMS layer will not work with WFS 1.0.0.. * srsName matching with the WMS layer will not work with WFS 1.0.0.
* *
* Parameters: * Parameters:
* layer - {<OpenLayers.Layer.WMS>} WMS layer that has a matching WFS * layer - {<OpenLayers.Layer.WMS>} WMS layer that has a matching WFS
+8 -8
View File
@@ -43,7 +43,7 @@ OpenLayers.Protocol.WFS.v1 = OpenLayers.Class(OpenLayers.Protocol, {
/** /**
* Property: geometryName * Property: geometryName
* {String} Name of the geometry attribute for features. Default is * {String} Name of the geometry attribute for features. Default is
* "the_geom". * "the_geom" for WFS <version> 1.0, and null for higher versions.
*/ */
geometryName: "the_geom", geometryName: "the_geom",
@@ -102,19 +102,16 @@ OpenLayers.Protocol.WFS.v1 = OpenLayers.Class(OpenLayers.Protocol, {
* for this featureType). * for this featureType).
* featurePrefix - {String} Feature namespace alias (optional - only used * featurePrefix - {String} Feature namespace alias (optional - only used
* for writing if featureNS is provided). Default is 'feature'. * for writing if featureNS is provided). Default is 'feature'.
* geometryName - {String} Name of geometry attribute. If featureNS is not * geometryName - {String} Name of geometry attribute. The default is
* configured, the default is null to avoid failing on BBOX filters, * 'the_geom' for WFS <version> 1.0, and null for higher versions. If
* and it will be set on <read>. Otherwise, the default is 'the_geom'. * 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 * multi - {Boolean} If set to true, geometries will be casted to Multi
* geometries before they are written in a transaction. No casting will * geometries before they are written in a transaction. No casting will
* be done when reading features. * be done when reading features.
*/ */
initialize: function(options) { initialize: function(options) {
OpenLayers.Protocol.prototype.initialize.apply(this, [options]); OpenLayers.Protocol.prototype.initialize.apply(this, [options]);
if (!options.geometryName && !options.featureNS) {
// poorly configured protocol - try to not fail on BBOX filters
this.geometryName = null;
}
if(!options.format) { if(!options.format) {
this.format = OpenLayers.Format.WFST(OpenLayers.Util.extend({ this.format = OpenLayers.Format.WFST(OpenLayers.Util.extend({
version: this.version, version: this.version,
@@ -126,6 +123,9 @@ OpenLayers.Protocol.WFS.v1 = OpenLayers.Class(OpenLayers.Protocol, {
schema: this.schema schema: this.schema
}, this.formatOptions)); }, this.formatOptions));
} }
if (!options.geometryName && parseFloat(this.format.version) > 1.0) {
this.setGeometryName(null);
}
}, },
/** /**
+4 -2
View File
@@ -111,7 +111,8 @@
var protocol = new OpenLayers.Protocol.WFS({ var protocol = new OpenLayers.Protocol.WFS({
url: "http://some.url.org", url: "http://some.url.org",
featurePrefix: "topp", featurePrefix: "topp",
featureType: "tasmania_roads" featureType: "tasmania_roads",
geometryName: null
}); });
protocol.parseResponse({responseText: document.getElementById("query_response").firstChild.nodeValue}); protocol.parseResponse({responseText: document.getElementById("query_response").firstChild.nodeValue});
@@ -299,7 +300,7 @@
} }
function test_fromWMSLayer(t) { function test_fromWMSLayer(t) {
t.plan(8); t.plan(9);
var map = new OpenLayers.Map("map", { var map = new OpenLayers.Map("map", {
projection: "EPSG:1234" projection: "EPSG:1234"
}); });
@@ -313,6 +314,7 @@
t.eq(protocol.featureType, "states", "typeName correctly extracted"); t.eq(protocol.featureType, "states", "typeName correctly extracted");
t.eq(protocol.srsName, "EPSG:1234", "srsName set correctly"); t.eq(protocol.srsName, "EPSG:1234", "srsName set correctly");
t.eq(protocol.version, "1.1.0", "version set correctly"); t.eq(protocol.version, "1.1.0", "version set correctly");
t.eq(protocol.format.geometryName, null, "format's geometryName set to null");
layer.params["LAYERS"] = ["topp:street_centerline", "topp:states"]; layer.params["LAYERS"] = ["topp:street_centerline", "topp:states"];
layer.projection = new OpenLayers.Projection("EPSG:900913"); layer.projection = new OpenLayers.Projection("EPSG:900913");