From da67953c6161f06b853b6b0b368a6b88a586db5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Sat, 3 Mar 2012 17:54:42 +0100 Subject: [PATCH 1/9] add a REST example in wmts-capabilities --- examples/wmts-capabilities.html | 14 ++++++--- examples/wmts-capabilities.js | 52 ++++++++++++++++++++++++++++----- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/examples/wmts-capabilities.html b/examples/wmts-capabilities.html index 21b3cae0c7..638d335a3c 100644 --- a/examples/wmts-capabilities.html +++ b/examples/wmts-capabilities.html @@ -20,15 +20,21 @@

Web Map Tile Service (WMTS) Capabilities Parsing

wmts, capabilities, getcapabilities -
+

The WMTS Capabilities format allows for parsing of capabilities - documents from OGC Web Map Tile Service (WMTS) version 1.0.0 + documents from OGC Web Map Tile Service (WMTS) version 1.0.0 implementations.

- + +

KVP version.

+
- + +

REST version.

+ +
+

This example creates an OpenLayers.Layer.WMTS layer to based diff --git a/examples/wmts-capabilities.js b/examples/wmts-capabilities.js index dc12941058..d507d1bec0 100644 --- a/examples/wmts-capabilities.js +++ b/examples/wmts-capabilities.js @@ -1,15 +1,20 @@ OpenLayers.ProxyHost = "/proxy/?url="; var map, format; +var map2, format2; function init() { - + + /* + * KVP version + */ + format = new OpenLayers.Format.WMTSCapabilities({ /** * This particular service is not in compliance with the WMTS spec and * is providing coordinates in y, x order regardless of the CRS. To - * work around this, we can provide the format a table of CRS URN that - * should be considered y, x order. These will extend the defaults on + * work around this, we can provide the format a table of CRS URN that + * should be considered y, x order. These will extend the defaults on * the format. */ yx: { @@ -38,22 +43,53 @@ function init() { isBaseLayer: false }); map.addLayer(layer); - }, + }, failure: function() { alert("Trouble getting capabilities doc"); OpenLayers.Console.error.apply(OpenLayers.Console, arguments); } }); - + map = new OpenLayers.Map({ div: "map", projection: "EPSG:900913" - }); - + }); + var osm = new OpenLayers.Layer.OSM(); map.addLayer(osm); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.setCenter(new OpenLayers.LonLat(-13677832, 5213272), 13); - + + + /* + * REST version + */ + format2 = new OpenLayers.Format.WMTSCapabilities(); + + OpenLayers.Request.GET({ + url: "http://wmts.geo.admin.ch/1.0.0/WMTSCapabilities.xml", + success: function(request) { + var doc = request.responseXML; + if (!doc || !doc.documentElement) { + doc = request.responseText; + } + var capabilities = format2.read(doc); + var layer = format2.createLayer(capabilities, { + layer: "ch.are.gemeindetyp-1990-9klassen", + // not avalable in the WMTS Capabilities in native projection + maxExtent: [485869.5728, 76443.1884, 837076.5648, 299941.7864] + }); + map2.addLayer(layer); + map2.setCenter(new OpenLayers.LonLat(540000, 160000), 17); + }, + failure: function() { + alert("Trouble getting capabilities doc"); + OpenLayers.Console.error.apply(OpenLayers.Console, arguments); + } + }); + + map2 = new OpenLayers.Map({ + div: "map2" + }); } From a662f82a1b5a57eda2e8dff89d7e70d0f304280c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Sat, 3 Mar 2012 17:57:22 +0100 Subject: [PATCH 2/9] improve createLayer from WMTS Capabilities --- lib/OpenLayers/Format/WMTSCapabilities.js | 147 +++++++++++++++------- lib/OpenLayers/Layer/WMTS.js | 1 + 2 files changed, 106 insertions(+), 42 deletions(-) diff --git a/lib/OpenLayers/Format/WMTSCapabilities.js b/lib/OpenLayers/Format/WMTSCapabilities.js index 1d2b82c4c3..3ad1f72ba8 100644 --- a/lib/OpenLayers/Format/WMTSCapabilities.js +++ b/lib/OpenLayers/Format/WMTSCapabilities.js @@ -6,27 +6,27 @@ /** * @requires OpenLayers/Format/XML/VersionedOGC.js */ - + /** * Class: OpenLayers.Format.WMTSCapabilities * Read WMTS Capabilities. - * + * * Inherits from: * - */ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.VersionedOGC, { - + /** * APIProperty: defaultVersion * {String} Version number to assume if none found. Default is "1.0.0". */ defaultVersion: "1.0.0", - + /** * APIProperty: yx * {Object} Members in the yx object are used to determine if a CRS URN * corresponds to a CRS with y,x axis order. Member names are CRS URNs - * and values are boolean. By default, the following CRS URN are + * and values are boolean. By default, the following CRS URN are * assumed to correspond to a CRS with y,x axis order: * * * urn:ogc:def:crs:EPSG::4326 @@ -48,8 +48,8 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers * APIMethod: read * Read capabilities data from a string, and return information about * the service (offering and observedProperty mostly). - * - * Parameters: + * + * Parameters: * data - {String} or {DOMElement} data to read/parse. * * Returns: @@ -61,36 +61,34 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers * Create a WMTS layer given a capabilities object. * * Parameters: - * capabilities - {Object} The object returned from a call to this + * capabilities - {Object} The object returned from a call to this * format. * config - {Object} Configuration properties for the layer. Defaults for * the layer will apply if not provided. * * Required config properties: * layer - {String} The layer identifier. - * matrixSet - {String} The matrix set identifier. + * + * Optional config properties: + * matrixSet - {String} The matrix set identifier, required if there is + * more than one matrix set in the layer capabilities. + * style - {String} The name of the style + * param - {Object} The dimensions values eg: {"Year": "2012"} * * Returns: * {} A properly configured WMTS layer. Throws an * error if an incomplete config is provided. Returns undefined if no * layer could be created with the provided config. - */ + */ createLayer: function(capabilities, config) { var layer; // confirm required properties are supplied in config - var required = { - layer: true, - matrixSet: true - }; - for (var prop in required) { - if (!(prop in config)) { - throw new Error("Missing property '" + prop + "' in layer configuration."); - } + if (!('layer' in config)) { + throw new Error("Missing property 'layer' in configuration."); } var contents = capabilities.contents; - var matrixSet = contents.tileMatrixSets[config.matrixSet]; // find the layer definition with the given identifier var layers = contents.layers; @@ -101,32 +99,97 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers break; } } - - if (layerDef && matrixSet) { - // get the default style for the layer - var style; - for (var i=0, ii=layerDef.styles.length; i} The top left corner of the * matrix. Must be provided if different than the layer . * tileWidth - {Number} The tile width for the matrix. Must be provided From 8d1d08b0c2991caa8b6f6e690ebb606b69b7d715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Sat, 3 Mar 2012 19:58:41 +0100 Subject: [PATCH 3/9] add tests to create a REST WMTS Layer --- tests/Format/WMTSCapabilities/v1_0_0.html | 238 +++++++++++++++++++--- 1 file changed, 206 insertions(+), 32 deletions(-) diff --git a/tests/Format/WMTSCapabilities/v1_0_0.html b/tests/Format/WMTSCapabilities/v1_0_0.html index f8b5a37215..99dbcda238 100644 --- a/tests/Format/WMTSCapabilities/v1_0_0.html +++ b/tests/Format/WMTSCapabilities/v1_0_0.html @@ -43,15 +43,15 @@ undefined, "ows:OperationsMetadata GetTile Constraints Get is correct"); } - + function test_layers(t) { t.plan(37); var xml = document.getElementById("ogcsample").firstChild.nodeValue; var doc = new OpenLayers.Format.XML().read(xml); - + var obj = new OpenLayers.Format.WMTSCapabilities().read(doc); var contents = obj.contents; - + var numOfLayers = contents.layers.length; t.eq(numOfLayers, 1, "correct count of layers"); @@ -89,11 +89,11 @@ t.eq(wgs84Bbox.top, 90.0, "wgs84BoudingBox top is correct"); t.eq(layer.resourceUrl.tile.format, "image/png", "resourceUrl.tile.format is correct"); - t.eq(layer.resourceUrl.tile.template, "http://www.example.com/wmts/coastlines/{TileMatrix}/{TileRow}/{TileCol}.png", + t.eq(layer.resourceUrl.tile.template, "http://www.example.com/wmts/coastlines/{TileMatrix}/{TileRow}/{TileCol}.png", "resourceUrl.tile.template is correct"); t.eq(layer.resourceUrl.FeatureInfo.format, "application/gml+xml; version=3.1", "resourceUrl.FeatureInfo.format is correct"); - t.eq(layer.resourceUrl.FeatureInfo.template, "http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml", + t.eq(layer.resourceUrl.FeatureInfo.template, "http://www.example.com/wmts/coastlines/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml", "resourceUrl.FeatureInfo.template is correct"); var dimensions = layer.dimensions; @@ -112,7 +112,7 @@ t.plan(19); var xml = document.getElementById("ogcsample").firstChild.nodeValue; var doc = new OpenLayers.Format.XML().read(xml); - + var obj = new OpenLayers.Format.WMTSCapabilities().read(doc); var tileMatrixSets = obj.contents.tileMatrixSets; @@ -138,54 +138,100 @@ t.eq(bigWorld.matrixIds[1].topLeftCorner.lon, -180, "tileMatrix 1 topLeftCorner.lon is correct"); t.eq(bigWorld.matrixIds[1].topLeftCorner.lat, 84, "tileMatrix 1 topLeftCorner.lat is correct"); } - + function test_createLayer(t) { - t.plan(7); - + t.plan(27); + var format = new OpenLayers.Format.WMTSCapabilities(); var xml = document.getElementById("ogcsample").firstChild.nodeValue; var doc = new OpenLayers.Format.XML().read(xml); - + var caps = format.read(doc); var layer; - + var success = true; try { - // incomplete config (missing matrixSet) + // incomplete config (missing layer) layer = format.createLayer(caps, { - layer: "coastlines" }); } catch (err) { success = false; } t.ok(!success, "createLayer throws error if provided incomplete layer config"); - + // bogus layer identifier - layer = format.createLayer(caps, { - layer: "foo", - matrixSet: "BigWorld" - }); - t.eq(layer, undefined, "createLayer returns undefined given bad layer identifier"); - + try { + layer = format.createLayer(caps, { + layer: "foo", + matrixSet: "BigWorld" + }); + } catch (err) { + success = false; + } + t.ok(!success, "createLayer returns undefined given bad layer identifier"); + // bogus matrixSet identifier - layer = format.createLayer(caps, { - layer: "coastlines", - matrixSet: "TheWorld" - }); - t.eq(layer, undefined, "createLayer returns undefined given bad matrixSet identifier"); - + try { + layer = format.createLayer(caps, { + layer: "coastlines", + matrixSet: "TheWorld" + }); + } catch (err) { + success = false; + } + t.ok(!success, "createLayer returns undefined given bad matrixSet identifier"); + layer = format.createLayer(caps, { layer: "coastlines", matrixSet: "BigWorld" }); t.ok(layer instanceof OpenLayers.Layer.WMTS, "correct instance"); - + + // autodetect matrixSet + layer = format.createLayer(caps, { + layer: "coastlines" + }); + t.ok(layer instanceof OpenLayers.Layer.WMTS, "correct instance, with autodetected matrixSet"); + t.eq(layer.matrixIds.length, 2, "correct matrixIds length"); t.eq(layer.name, "Coastlines", "correct layer title"); t.eq(layer.style, "DarkBlue", "correct style identifier"); + t.eq(layer.requestEncoding, "KVP", "correct requestEncoding"); + + xml = document.getElementById("restsample").firstChild.nodeValue; + doc = new OpenLayers.Format.XML().read(xml); + caps = format.read(doc); + layer = format.createLayer(caps, { + layer: "ch.are.agglomerationen_isolierte_staedte-2000", + matrixSet: "21781" + }); + t.ok(layer instanceof OpenLayers.Layer.WMTS, "correct instance"); + t.eq(layer.url, "http://wmts.geo.admin.ch/1.0.0/ch.are.agglomerationen_isolierte_staedte-2000/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png", "correct url"); + t.eq(layer.matrixIds.length, 3, "correct matrixIds length"); + t.eq(layer.requestEncoding, "REST", "correct requestEncoding"); + t.eq(layer.name, "Agglomérations et villes isolées", "correct layer title"); + t.eq(layer.style, "ch.are.agglomerationen_isolierte_staedte-2000", "correct style identifier"); + t.eq(layer.projection.getCode(), "EPSG:21781", "correct projection"); + t.eq(layer.units, "m", "correct untis"); + t.eq(layer.resolutions.length, 3, "correct resolutions length"); + t.ok((layer.resolutions[0] - 4000) < 1, "correct first resolution"); + t.eq(layer.dimensions.length, 1, "correct dimensions length"); + t.eq(layer.dimensions[0], "Time", "correct dimensions"); + t.eq(layer.params['TIME'], "20090101", "correct params"); + + layer = format.createLayer(caps, { + layer: "ch.are.agglomerationen_isolierte_staedte-2000", + style: "toto", + params: {"Time": "2012"} + }); + t.eq(layer.matrixIds.length, 3, "correct matrixIds length"); + t.eq(layer.style, "toto", "correct style identifier"); + t.eq(layer.dimensions.length, 1, "correct dimensions length"); + t.eq(layer.dimensions[0], "Time", "correct dimensions"); + t.eq(layer.params['TIME'], "2012", "correct params"); } - + @@ -300,15 +346,15 @@ http://schemas.opengis.net/wmts/1.0/examples/wmtsGetCapabilities_response.xml BigWorld - + BigWorld urn:ogc:def:crs:OGC:1.3:CRS84 1e6 - 1e6 - -180 84 + 1e6 + -180 84 256 - 256 + 256 60000 50000 @@ -354,5 +400,133 @@ http://schemas.opengis.net/wmts/1.0/examples/wmtsGetCapabilities_response.xml -->

+ +
From 0e78d40da229350c272c37f09b90bdcd99bb18ee Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 25 Jun 2012 14:19:26 +0200 Subject: [PATCH 4/9] Update WMS base layer in strategy-cluster-threshold.html --- examples/strategy-cluster-threshold.html | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/strategy-cluster-threshold.html b/examples/strategy-cluster-threshold.html index 13abd2c1ea..a47e08d8e1 100644 --- a/examples/strategy-cluster-threshold.html +++ b/examples/strategy-cluster-threshold.html @@ -37,10 +37,8 @@ function init() { map = new OpenLayers.Map('map'); var base = new OpenLayers.Layer.WMS("OpenLayers WMS", - ["http://t3.tilecache.osgeo.org/wms-c/Basic.py", - "http://t2.tilecache.osgeo.org/wms-c/Basic.py", - "http://t1.tilecache.osgeo.org/wms-c/Basic.py"], - {layers: 'satellite'} + "http://vmap0.tiles.osgeo.org/wms/vmap0", + {layers: 'basic'} ); var style = new OpenLayers.Style({ From 8058a800ed102d0fe7deccfcb9020accd7425ac9 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 25 Jun 2012 14:56:40 +0200 Subject: [PATCH 5/9] mobile-wmts-vienna example: requestEncoding already set in defaults --- examples/mobile-wmts-vienna.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/mobile-wmts-vienna.js b/examples/mobile-wmts-vienna.js index 04cd9b4148..01de358fc1 100644 --- a/examples/mobile-wmts-vienna.js +++ b/examples/mobile-wmts-vienna.js @@ -163,13 +163,13 @@ var map; var doc = request.responseText, caps = format.read(doc); fmzk = format.createLayer(caps, OpenLayers.Util.applyDefaults( - {layer:"fmzk", requestEncoding:"REST", transitionEffect:"resize"}, defaults + {layer:"fmzk", transitionEffect:"resize"}, defaults )); aerial = format.createLayer(caps, OpenLayers.Util.applyDefaults( - {layer:"lb", requestEncoding:"REST", transitionEffect:"resize"}, defaults + {layer:"lb", transitionEffect:"resize"}, defaults )); labels = format.createLayer(caps, OpenLayers.Util.applyDefaults( - {layer:"beschriftung", requestEncoding:"REST", className:"nofade", isBaseLayer: false}, + {layer:"beschriftung", className:"nofade", isBaseLayer: false}, defaults )); map.addLayers([fmzk, aerial, labels]); From 81dffce4f45e54683c3d34e3d14990ab884fb600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Mon, 25 Jun 2012 14:55:44 +0200 Subject: [PATCH 6/9] remove unworking example in wmts-capabilities --- examples/wmts-capabilities.html | 6 ------ examples/wmts-capabilities.js | 37 --------------------------------- 2 files changed, 43 deletions(-) diff --git a/examples/wmts-capabilities.html b/examples/wmts-capabilities.html index 638d335a3c..58aabd5f20 100644 --- a/examples/wmts-capabilities.html +++ b/examples/wmts-capabilities.html @@ -27,14 +27,8 @@ implementations.

-

KVP version.

-
-

REST version.

- -
-

This example creates an OpenLayers.Layer.WMTS layer to based diff --git a/examples/wmts-capabilities.js b/examples/wmts-capabilities.js index d507d1bec0..0b2e011c99 100644 --- a/examples/wmts-capabilities.js +++ b/examples/wmts-capabilities.js @@ -1,14 +1,9 @@ OpenLayers.ProxyHost = "/proxy/?url="; var map, format; -var map2, format2; function init() { - /* - * KVP version - */ - format = new OpenLayers.Format.WMTSCapabilities({ /** * This particular service is not in compliance with the WMTS spec and @@ -60,36 +55,4 @@ function init() { map.addLayer(osm); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.setCenter(new OpenLayers.LonLat(-13677832, 5213272), 13); - - - /* - * REST version - */ - format2 = new OpenLayers.Format.WMTSCapabilities(); - - OpenLayers.Request.GET({ - url: "http://wmts.geo.admin.ch/1.0.0/WMTSCapabilities.xml", - success: function(request) { - var doc = request.responseXML; - if (!doc || !doc.documentElement) { - doc = request.responseText; - } - var capabilities = format2.read(doc); - var layer = format2.createLayer(capabilities, { - layer: "ch.are.gemeindetyp-1990-9klassen", - // not avalable in the WMTS Capabilities in native projection - maxExtent: [485869.5728, 76443.1884, 837076.5648, 299941.7864] - }); - map2.addLayer(layer); - map2.setCenter(new OpenLayers.LonLat(540000, 160000), 17); - }, - failure: function() { - alert("Trouble getting capabilities doc"); - OpenLayers.Console.error.apply(OpenLayers.Console, arguments); - } - }); - - map2 = new OpenLayers.Map({ - div: "map2" - }); } From 293d173079712f95c10dea9c65b63837a7e5d109 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Mon, 25 Jun 2012 17:18:32 +0200 Subject: [PATCH 7/9] Simple example with an OSM map, a marker and a popup. --- examples/osm-marker-popup.html | 32 ++++++++++++++++++++++++++++ examples/osm-marker-popup.js | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 examples/osm-marker-popup.html create mode 100644 examples/osm-marker-popup.js diff --git a/examples/osm-marker-popup.html b/examples/osm-marker-popup.html new file mode 100644 index 0000000000..8744ec811e --- /dev/null +++ b/examples/osm-marker-popup.html @@ -0,0 +1,32 @@ + + + + + + + OpenLayers OSM and Google Example + + + + + + +

OSM with Marker and Popup

+

+ Demonstrate use of an OSM layer with a marker and a popup. +

+
+ openstreetmap osm marker popup +
+
+
+

+ A common use case for OpenLayers is to display a marker at a + location on the map, and add some information in a popup. It + is also easy to add a tooltip with a short description. + See the + osm-marker-popup.js source to see how this is done. +

+
+ + diff --git a/examples/osm-marker-popup.js b/examples/osm-marker-popup.js new file mode 100644 index 0000000000..e8f39b5357 --- /dev/null +++ b/examples/osm-marker-popup.js @@ -0,0 +1,39 @@ +var map; +function init() { + + // The overlay layer for our marker, with a simple diamond as symbol + var overlay = new OpenLayers.Layer.Vector('Overlay', { + styleMap: new OpenLayers.StyleMap({ + externalGraphic: '../img/marker.png', + graphicWidth: 20, graphicHeight: 24, graphicYOffset: -24, + title: '${tooltip}' + }) + }); + + // The location of our marker and popup. We usually think in geographic + // coordinates ('EPSG:4326'), but the map is projected ('EPSG:3857'). + var myLocation = new OpenLayers.Geometry.Point(10.2, 48.9) + .transform('EPSG:4326', 'EPSG:3857'); + + // We add the marker with a tooltip text to the overlay + overlay.addFeatures([ + new OpenLayers.Feature.Vector(myLocation, {tooltip: 'OpenLayers'}) + ]); + + // A popup with some information about our location + var popup = new OpenLayers.Popup.FramedCloud("Popup", + myLocation.getBounds().getCenterLonLat(), null, + 'We ' + + 'could be here.
Or elsewhere.', null, + true // <-- true if we want a close (X) button, false otherwise + ); + + // Finally we create the map + map = new OpenLayers.Map({ + div: "map", projection: "EPSG:3857", + layers: [new OpenLayers.Layer.OSM(), overlay], + center: myLocation.getBounds().getCenterLonLat(), zoom: 15 + }); + // and add the popup to it. + map.addPopup(popup); +} From 419ead9191cdc59ce8bd65927cc8041d379dacfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 26 Jun 2012 16:09:38 +0200 Subject: [PATCH 8/9] fix projection syntax --- lib/OpenLayers/Format/WMTSCapabilities.js | 2 +- tests/Format/WMTSCapabilities/v1_0_0.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Format/WMTSCapabilities.js b/lib/OpenLayers/Format/WMTSCapabilities.js index 3ad1f72ba8..157042cb55 100644 --- a/lib/OpenLayers/Format/WMTSCapabilities.js +++ b/lib/OpenLayers/Format/WMTSCapabilities.js @@ -153,7 +153,7 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers } var projection = config.projection || matrixSet.supportedCRS.replace( - /urn:ogc:def:crs:(\w+):.+:(\w+)$/, "$1:$2"); + /urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, "$1:$3"); var units = config.units || projection === "EPSG:4326" ? "degrees" : "m" diff --git a/tests/Format/WMTSCapabilities/v1_0_0.html b/tests/Format/WMTSCapabilities/v1_0_0.html index 99dbcda238..81686b1fff 100644 --- a/tests/Format/WMTSCapabilities/v1_0_0.html +++ b/tests/Format/WMTSCapabilities/v1_0_0.html @@ -495,7 +495,7 @@ http://schemas.opengis.net/wmts/1.0/examples/wmtsGetCapabilities_response.xml 21781 - urn:ogc:def:crs:EPSG:21781 + urn:ogc:def:crs:EPSG::21781 0 14285750.5715 From 484eda2ee5116dd41c8572aacff26c17221bdd43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 26 Jun 2012 16:14:12 +0200 Subject: [PATCH 9/9] add alternate projection parsing --- tests/Format/WMTSCapabilities/v1_0_0.html | 174 ++++++++++++++++++++++ 1 file changed, 174 insertions(+) diff --git a/tests/Format/WMTSCapabilities/v1_0_0.html b/tests/Format/WMTSCapabilities/v1_0_0.html index 81686b1fff..43de62a077 100644 --- a/tests/Format/WMTSCapabilities/v1_0_0.html +++ b/tests/Format/WMTSCapabilities/v1_0_0.html @@ -232,6 +232,29 @@ t.eq(layer.params['TIME'], "2012", "correct params"); } + function test_parse_projection(t) { + t.plan(2); + + var format = new OpenLayers.Format.WMTSCapabilities(); + + var xml = document.getElementById("restsample-alternate-proj1").firstChild.nodeValue; + var doc = new OpenLayers.Format.XML().read(xml); + var caps = format.read(doc); + var layer = format.createLayer(caps, { + layer: "ch.are.agglomerationen_isolierte_staedte-2000", + matrixSet: "21781" + }); + t.eq(layer.projection.getCode(), "EPSG:21781", "correct projection"); + + xml = document.getElementById("restsample-alternate-proj2").firstChild.nodeValue; + doc = new OpenLayers.Format.XML().read(xml); + caps = format.read(doc); + layer = format.createLayer(caps, { + layer: "ch.are.agglomerationen_isolierte_staedte-2000", + matrixSet: "21781" + }); + t.eq(layer.projection.getCode(), "EPSG:21781", "correct projection"); + } @@ -528,5 +551,156 @@ http://schemas.opengis.net/wmts/1.0/examples/wmtsGetCapabilities_response.xml -->
+ +
+ +
+