From e3df606001f84668732e3e9c35d06c7ccaac417e Mon Sep 17 00:00:00 2001 From: crschmidt Date: Wed, 9 Aug 2006 15:52:23 +0000 Subject: [PATCH] Quote indexes into array. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1161 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/KaMap.js | 9 +++++---- lib/OpenLayers/Map.js | 15 ++++++++++++--- lib/OpenLayers/Util.js | 16 ++++++++-------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/lib/OpenLayers/Layer/KaMap.js b/lib/OpenLayers/Layer/KaMap.js index c2f65c9b37..26cf3774cb 100644 --- a/lib/OpenLayers/Layer/KaMap.js +++ b/lib/OpenLayers/Layer/KaMap.js @@ -18,10 +18,8 @@ OpenLayers.Layer.KaMap.prototype = isBaseLayer: true, units: 'degrees', - scales: {inches: 1, feet: 12, miles: 63360.0, meters: 39.3701, kilometers: 39370.1, degrees: 4374754}, - - resolution: 72, + resolution: OpenLayers.DOTS_PER_INCH, DEFAULT_PARAMS: { i: 'jpeg', @@ -57,7 +55,10 @@ OpenLayers.Layer.KaMap.prototype = var zoom = this.map.getZoom(); var maxRes = this.map.maxResolution; var mapRes = this.map.getResolution(); - var scale = Math.round( (((this.tileSize.w * this.map.maxResolution * this.resolution) * (this.scales[this.units])) / this.tileSize.w) / Math.pow(2, zoom) * 10000 ) / 10000; + var scale = Math.round( (((this.tileSize.w * this.map.maxResolution * this.resolution) * + (OpenLayers.INCHES_PER_UNIT[this.units])) / + this.tileSize.w) + / Math.pow(2, zoom) * 10000 ) / 10000; var cellSize = new OpenLayers.Size(mapRes*this.tileSize.w, mapRes*this.tileSize.h); var pX = Math.round(((bounds.left) / cellSize.w) * this.tileSize.w); diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 4b2b239760..431b0596b4 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -98,6 +98,13 @@ OpenLayers.Map.prototype = { /** @type OpenLayers.Size */ tileSize: null, + /** @type String */ + units: 'degrees', + + /** @type Float */ + minScale: null, + + /** * @constructor @@ -203,14 +210,16 @@ OpenLayers.Map.prototype = { // if maxResolution is specified as "auto", calculate it // based on the maxExtent and the viewSize // - if (this.maxResolution == "auto" || this.maxResolution == null) { + + if (this.maxResolution == null && this.minScale) { + this.maxResolution = OpenLayers.Util.getResolutionFromScale(this.minScale, this.units); + } else if (this.maxResolution == "auto" || this.maxResolution == null) { var maxExtent = this.getMaxExtent(); var viewSize = this.getSize(); this.maxResolution = Math.max(maxExtent.getWidth() / viewSize.w, maxExtent.getHeight() / viewSize.h ); } - }, /** @@ -675,7 +684,7 @@ OpenLayers.Map.prototype = { * @type String */ getMaxResolution: function() { - var maxResolution = null + var maxResolution = null; if (this.baseLayer != null) { maxResolution = this.baseLayer.getMaxResolution(); diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index ccfddbfd2a..69cd650eff 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1115,14 +1115,14 @@ OpenLayers.Util.createUniqueID = function(prefix) { /** constant inches per unit */ OpenLayers.INCHES_PER_UNIT = { // borrowed from MapServer mapscale.c - inches: 1.0, - in: 1.0, - ft: 12.0, - mi: 63360.0, - m: 39.3701, - km: 39370.1, - dd: 4374754, - degrees: 4374754, + 'inches': 1.0, + 'in': 1.0, + 'ft': 12.0, + 'mi': 63360.0, + 'm': 39.3701, + 'km': 39370.1, + 'dd': 4374754, + 'degrees': 4374754 }; /** sensible default */