From 9c7b4b6b9ee91c0cf8b79e658ebf506d70369d46 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Wed, 30 Jul 2014 08:37:43 +0200 Subject: [PATCH] Fix WfsCapabilities reader for WFS 1.1.0. See https://github.com/geoext/geoext2/issues/281. This is a port of the approach taken in GeoExt 1: https://github.com/geoext/geoext/pull/30. --- src/GeoExt/data/reader/WfsCapabilities.js | 13 +- tests/data/reader/WfsCapabilities.html | 20 +++ tests/data/reader/WfsCapabilities.js | 156 +++++++++++++++++++++- 3 files changed, 187 insertions(+), 2 deletions(-) diff --git a/src/GeoExt/data/reader/WfsCapabilities.js b/src/GeoExt/data/reader/WfsCapabilities.js index 70e502e36..3d44c8abe 100644 --- a/src/GeoExt/data/reader/WfsCapabilities.js +++ b/src/GeoExt/data/reader/WfsCapabilities.js @@ -84,8 +84,19 @@ Ext.define('GeoExt.data.reader.WfsCapabilities', { var featureType, metadata, field, v, parts, layer; var layerOptions, protocolOptions; + var wfs11version = 1.1, + url, + opMeta; + if (parseFloat(data.version) >= wfs11version) { + // WFS 1.1.0 needs special treatment + opMeta = data.operationsMetadata; + url = opMeta && opMeta.GetFeature.dcp.http.post[0].url; + } else { + url = data.capability.request.getfeature.href.post; + } + var protocolDefaults = { - url: data.capability.request.getfeature.href.post + url: url }; var records = []; diff --git a/tests/data/reader/WfsCapabilities.html b/tests/data/reader/WfsCapabilities.html index 9e6300b9f..b27c2016a 100644 --- a/tests/data/reader/WfsCapabilities.html +++ b/tests/data/reader/WfsCapabilities.html @@ -53,6 +53,26 @@ reader.destroy(); } + /** + * See https://github.com/geoext/geoext2/issues/281 and + * https://github.com/geoext/geoext/pull/30 + */ + function test_readWFS11(t) { + t.plan(1); + + var reader = Ext.create("GeoExt.data.reader.WfsCapabilities"); + var records = reader.read({ + responseXML : doc11, + responseText: true + }); + var record = records.records[0]; + var layer = record.getLayer(); + var expectedUrl = "http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap?"; + + t.eq(layer.protocol.url, expectedUrl, + "[0] protocol has correct URL (WFS 1.1.0)"); + } + function test_read_layerOptions(t) { t.plan(6); var reader = Ext.create("GeoExt.data.reader.WfsCapabilities", { diff --git a/tests/data/reader/WfsCapabilities.js b/tests/data/reader/WfsCapabilities.js index 925e03678..a63ddbc21 100644 --- a/tests/data/reader/WfsCapabilities.js +++ b/tests/data/reader/WfsCapabilities.js @@ -326,4 +326,158 @@ var doc = (new OpenLayers.Format.XML).read( ''+ ''+ '' -); \ No newline at end of file +); +var doc11 = (new OpenLayers.Format.XML).read( +'' + +'' + +' ' + +' GMap WMS Demo Server' + +' ' + +' OGC WFS' + +' 1.1.0' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' WFS' + +' ' + +' ' + +' 1.0.0' + +' 1.1.0' + +' ' + +' ' + +' text/xml' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' XMLSCHEMA' + +' text/xml; subtype=gml/2.1.2' + +' text/xml; subtype=gml/3.1.1' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' results' + +' ' + +' ' + +' text/xml; subtype=gml/3.1.1' + +' ' + +' ' + +' ' + +' ' + +' ' + +' Query' + +' ' + +' ' + +' park' + +' Parks' + +' EPSG:42304' + +' ' + +' text/xml; subtype=gml/3.1.1' + +' ' + +' ' + +' -173.433267989715 41.4271118471489' + +' -13.0481388603488 83.7465953038598' + +' ' + +' ' + +' ' + +' popplace' + +' Cities' + +' EPSG:42304' + +' ' + +' text/xml; subtype=gml/3.1.1' + +' ' + +' ' + +' -172.301407169865 36.354098687089' + +' -12.9698018843271 83.4831811841595' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' gml:Point' + +' gml:LineString' + +' gml:Polygon' + +' gml:Envelope' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +' LessThan' + +' GreaterThan' + +' LessThanEqualTo' + +' GreaterThanEqualTo' + +' EqualTo' + +' NotEqualTo' + +' Like' + +' Between' + +' ' + +' ' + +' ' + +' ' + +' ' + +' ' + +'' +);