[OpenLayers-Commits] r12295 - sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Aug 31 05:06:54 EDT 2011


Author: erilem
Date: 2011-08-31 02:06:53 -0700 (Wed, 31 Aug 2011)
New Revision: 12295

Modified:
   sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/WMTS.js
Log:
add serverResolutions for offset support in WMTS

Modified: sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/WMTS.js
===================================================================
--- sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/WMTS.js	2011-08-31 09:01:58 UTC (rev 12294)
+++ sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/WMTS.js	2011-08-31 09:06:53 UTC (rev 12295)
@@ -154,11 +154,16 @@
     /**
      * APIProperty: serverResolutions
      * {Array} A list of all resolutions available on the server.  Only set this
-     *     property if the map resolutions differ from the server. The map can
-     *     work with resolutions that aren't supported by the server, i.e. that
-     *     aren't in <serverResolutions>. When the map is displayed in such a
-     *     resolution data for the closest server-supported resolution is
-     *     loaded and the layer div is stretched as necessary.
+     *     property if the map resolutions differ from the server. This
+     *     property serves two purposes. (a) <serverResolutions> can include
+     *     resolutions that the server supports and that you don't want to
+     *     provide with this layer; you can also look at <zoomOffset>, which is
+     *     an alternative to <serverResolutions> for that specific purpose.
+     *     (b) The map can work with resolutions that aren't supported by
+     *     the server, i.e. that aren't in <serverResolutions>. When the
+     *     map is displayed in such a resolution data for the closest
+     *     server-supported resolution is loaded and the layer div is
+     *     stretched as necessary.
      */
     serverResolutions: null,
 
@@ -325,10 +330,13 @@
      * Get the appropriate matrix definition for the current map resolution.
      */
     getMatrix: function() {
-        var matrix, zoom;
+        var matrix, identifier;
         if (!this.matrixIds || this.matrixIds.length === 0) {
-            zoom = this.getServerSupportedZoom();
-            matrix = {identifier: zoom + this.zoomOffset};
+            identifier = this.serverResolutions != null ?
+                OpenLayers.Util.indexOf(this.serverResolutions,
+                                        this.getServerSupportedResolution()) :
+                this.getServerSupportedZoom() + this.zoomOffset;
+            matrix = {identifier: identifier};
         } else {
             // get appropriate matrix given the map scale if possible
             if ("scaleDenominator" in this.matrixIds[0]) {
@@ -348,8 +356,11 @@
                 }
             } else {
                 // fall back on zoom as index
-                zoom = this.getServerSupportedZoom();
-                matrix = this.matrixIds[zoom + this.zoomOffset];
+                identifier = this.serverResolutions != null ?
+                    OpenLayers.Util.indexOf(this.serverResolutions,
+                                            this.getServerSupportedResolution()) :
+                    this.getServerSupportedZoom() + this.zoomOffset;
+                matrix = this.matrixIds[identifier];
             }
         }
         return matrix;



More information about the Commits mailing list