Skip to content

Commit

Permalink
Merge pull request openlayers#614 from sbrunner/wmts-fix
Browse files Browse the repository at this point in the history
correct units in WMTS capabilities
  • Loading branch information
sbrunner committed Aug 3, 2012
2 parents 159ee7c + 9d31c57 commit 65cacaa
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/OpenLayers/Format/WMTSCapabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
33 changes: 32 additions & 1 deletion tests/Format/WMTSCapabilities/v1_0_0.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
}

function test_createLayer(t) {
t.plan(27);
t.plan(34);

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

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 65cacaa

Please sign in to comment.