Skip to content

Commit 9d31c57

Browse files
author
Stéphane Brunner
committed
correct units in WMTS capabilities
1 parent 940c0e8 commit 9d31c57

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

lib/OpenLayers/Format/WMTSCapabilities.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ OpenLayers.Format.WMTSCapabilities = OpenLayers.Class(OpenLayers.Format.XML.Vers
155155
var projection = config.projection || matrixSet.supportedCRS.replace(
156156
/urn:ogc:def:crs:(\w+):(.*:)?(\w+)$/, "$1:$3");
157157
var units = config.units ||
158-
projection === "EPSG:4326" ? "degrees" : "m";
158+
(projection === "EPSG:4326" ? "degrees" : "m");
159159

160160
var resolutions = [];
161161
if (config.isBaseLayer !== false) {

tests/Format/WMTSCapabilities/v1_0_0.html

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
}
141141

142142
function test_createLayer(t) {
143-
t.plan(27);
143+
t.plan(34);
144144

145145
var format = new OpenLayers.Format.WMTSCapabilities();
146146

@@ -230,6 +230,37 @@
230230
t.eq(layer.dimensions.length, 1, "correct dimensions length");
231231
t.eq(layer.dimensions[0], "Time", "correct dimensions");
232232
t.eq(layer.params['TIME'], "2012", "correct params");
233+
234+
// test projection and units
235+
layer = format.createLayer(caps, {
236+
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
237+
matrixSet: "21781",
238+
units: 'degrees'
239+
});
240+
t.eq(layer.units, "degrees", "correct units");
241+
layer = format.createLayer(caps, {
242+
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
243+
matrixSet: "21781",
244+
projection: "EPSG:4326"
245+
});
246+
t.eq(layer.projection.getCode(), "EPSG:4326", "correct projection");
247+
t.eq(layer.units, "degrees", "correct units");
248+
layer = format.createLayer(caps, {
249+
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
250+
matrixSet: "21781",
251+
projection: "EPSG:4326",
252+
units: 'm'
253+
});
254+
t.eq(layer.projection.getCode(), "EPSG:4326", "correct projection");
255+
t.eq(layer.units, "m", "correct units");
256+
layer = format.createLayer(caps, {
257+
layer: "ch.are.agglomerationen_isolierte_staedte-2000",
258+
matrixSet: "21781",
259+
projection: "EPSG:900913",
260+
units: 'degrees'
261+
});
262+
t.eq(layer.projection.getCode(), "EPSG:900913", "correct projection");
263+
t.eq(layer.units, "degrees", "correct units");
233264
}
234265

235266
function test_parse_projection(t) {

0 commit comments

Comments
 (0)