From 9d31c57e2a3a4b9fa0521639182413e922b45b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Mon, 30 Jul 2012 23:17:11 +0200 Subject: [PATCH] correct units in WMTS capabilities --- lib/OpenLayers/Format/WMTSCapabilities.js | 2 +- tests/Format/WMTSCapabilities/v1_0_0.html | 33 ++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Format/WMTSCapabilities.js b/lib/OpenLayers/Format/WMTSCapabilities.js index 6f8795bfad..2b8c5e9ce1 100644 --- a/lib/OpenLayers/Format/WMTSCapabilities.js +++ b/lib/OpenLayers/Format/WMTSCapabilities.js @@ -155,7 +155,7 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers var projection = config.projection || matrixSet.supportedCRS.replace( /urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, "$1:$3"); var units = config.units || - projection === "EPSG:4326" ? "degrees" : "m"; + (projection === "EPSG:4326" ? "degrees" : "m"); var resolutions = []; if (config.isBaseLayer !== false) { diff --git a/tests/Format/WMTSCapabilities/v1_0_0.html b/tests/Format/WMTSCapabilities/v1_0_0.html index 43de62a077..cb4b55c7d9 100644 --- a/tests/Format/WMTSCapabilities/v1_0_0.html +++ b/tests/Format/WMTSCapabilities/v1_0_0.html @@ -140,7 +140,7 @@ } function test_createLayer(t) { - t.plan(27); + t.plan(34); var format = new OpenLayers.Format.WMTSCapabilities(); @@ -230,6 +230,37 @@ 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"); + + // test projection and units + layer = format.createLayer(caps, { + layer: "ch.are.agglomerationen_isolierte_staedte-2000", + matrixSet: "21781", + units: 'degrees' + }); + t.eq(layer.units, "degrees", "correct units"); + layer = format.createLayer(caps, { + layer: "ch.are.agglomerationen_isolierte_staedte-2000", + matrixSet: "21781", + projection: "EPSG:4326" + }); + t.eq(layer.projection.getCode(), "EPSG:4326", "correct projection"); + t.eq(layer.units, "degrees", "correct units"); + layer = format.createLayer(caps, { + layer: "ch.are.agglomerationen_isolierte_staedte-2000", + matrixSet: "21781", + projection: "EPSG:4326", + units: 'm' + }); + t.eq(layer.projection.getCode(), "EPSG:4326", "correct projection"); + t.eq(layer.units, "m", "correct units"); + layer = format.createLayer(caps, { + layer: "ch.are.agglomerationen_isolierte_staedte-2000", + matrixSet: "21781", + projection: "EPSG:900913", + units: 'degrees' + }); + t.eq(layer.projection.getCode(), "EPSG:900913", "correct projection"); + t.eq(layer.units, "degrees", "correct units"); } function test_parse_projection(t) {