[OpenLayers-Commits] r12298 - in sandbox/camptocamp/clientzoom:
lib/OpenLayers/Layer tests/Layer
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Wed Aug 31 05:40:23 EDT 2011
Author: erilem
Date: 2011-08-31 02:40:23 -0700 (Wed, 31 Aug 2011)
New Revision: 12298
Modified:
sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/WMTS.js
sandbox/camptocamp/clientzoom/tests/Layer/WMTS.html
Log:
add tests for serverResolutions and zoomOffset in WMTS, plus minor refactoring in WMTS
Modified: sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/WMTS.js
===================================================================
--- sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/WMTS.js 2011-08-31 09:24:14 UTC (rev 12297)
+++ sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/WMTS.js 2011-08-31 09:40:23 UTC (rev 12298)
@@ -324,19 +324,26 @@
// copy/set any non-init, non-simple values here
return obj;
},
+
+ /**
+ * Method: getIdentifier
+ * Get the current index in the matrixIds array.
+ */
+ getIdentifier: function() {
+ return this.serverResolutions != null ?
+ OpenLayers.Util.indexOf(this.serverResolutions,
+ this.getServerSupportedResolution()) :
+ this.getServerSupportedZoom() + this.zoomOffset;
+ },
/**
* Method: getMatrix
* Get the appropriate matrix definition for the current map resolution.
*/
getMatrix: function() {
- var matrix, identifier;
+ var matrix;
if (!this.matrixIds || this.matrixIds.length === 0) {
- identifier = this.serverResolutions != null ?
- OpenLayers.Util.indexOf(this.serverResolutions,
- this.getServerSupportedResolution()) :
- this.getServerSupportedZoom() + this.zoomOffset;
- matrix = {identifier: identifier};
+ matrix = {identifier: this.getIdentifier()};
} else {
// get appropriate matrix given the map scale if possible
if ("scaleDenominator" in this.matrixIds[0]) {
@@ -356,11 +363,7 @@
}
} else {
// fall back on zoom as index
- identifier = this.serverResolutions != null ?
- OpenLayers.Util.indexOf(this.serverResolutions,
- this.getServerSupportedResolution()) :
- this.getServerSupportedZoom() + this.zoomOffset;
- matrix = this.matrixIds[identifier];
+ matrix = this.matrixIds[this.getIdentifier()];
}
}
return matrix;
Modified: sandbox/camptocamp/clientzoom/tests/Layer/WMTS.html
===================================================================
--- sandbox/camptocamp/clientzoom/tests/Layer/WMTS.html 2011-08-31 09:24:14 UTC (rev 12297)
+++ sandbox/camptocamp/clientzoom/tests/Layer/WMTS.html 2011-08-31 09:40:23 UTC (rev 12298)
@@ -258,6 +258,37 @@
t.ok( layer2.grid == null, "tiles appropriately destroyed");
map.destroy();
}
+
+ function test_getIdentifier(t) {
+ t.plan(2);
+
+ var map = new OpenLayers.Map('map');
+ var layer, identifier;
+
+ layer = new OpenLayers.Layer.WMTS({
+ name: "Blue Marble WMTS",
+ url: "http://example.com/wmts/",
+ layer: "world",
+ style: "blue_marble",
+ matrixSet: "arcgis_online",
+ tileSize: new OpenLayers.Size(512, 512),
+ requestEncoding: "REST",
+ });
+ map.addLayer(layer);
+ map.setCenter(new OpenLayers.LonLat(0,0), 5);
+
+ layer.zoomOffset = 2;
+ identifier = layer.getIdentifier();
+ t.eq(identifier, 7, '[zoomOffset] getIdentifier return value is correct');
+
+ layer.serverResolutions = ['offset', 1.40625, 0.703125, 0.3515625, 0.17578125,
+ 0.087890625, 0.0439453125];
+ identifier = layer.getIdentifier();
+ t.eq(identifier, 6, '[serverResolutions] getIdentifier return value is correct');
+
+ map.destroy();
+ }
+
</script>
</head>
<body>
More information about the Commits
mailing list