From 3f5c2a8fb910a19fcf3fcfda926eb561651f0639 Mon Sep 17 00:00:00 2001 From: Schuyler Erle Date: Wed, 9 Aug 2006 14:47:26 +0000 Subject: [PATCH] Moved INCHES_PER_UNIT and DOTS_PER_INCH into Util.js. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1159 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/Scale.js | 15 ++------------- lib/OpenLayers/Util.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/OpenLayers/Control/Scale.js b/lib/OpenLayers/Control/Scale.js index 7e023a4fb4..9bf1dadd7e 100644 --- a/lib/OpenLayers/Control/Scale.js +++ b/lib/OpenLayers/Control/Scale.js @@ -10,24 +10,12 @@ OpenLayers.Control.Scale = Class.create(); OpenLayers.Control.Scale.prototype = Object.extend( new OpenLayers.Control(), { - INCHES_PER_UNIT: { // borrowed from MapServer mapscale.c - inches: 1.0, - ft: 12.0, - mi: 63360.0, - m: 39.3701, - km: 39370.1, - dd: 4374754 - }, - /** @type DOMElement */ element: null, /** @type String */ units: 'dd', - /** @type Integer */ - dpi: 72, - /** * @constructor * @@ -68,7 +56,8 @@ OpenLayers.Control.Scale.prototype = var res = this.map.getResolution(); if (!res) return; - var scale = res * this.INCHES_PER_UNIT[this.units] * this.dpi; + var scale = res * OpenLayers.INCHES_PER_UNIT[this.units] + * OpenLayers.DOTS_PER_INCH; if (scale >= 9500 && scale <= 950000) { scale = Math.round(scale / 1000) + "K"; } else if (scale >= 950000) { diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 8c28ea4432..e30960ab0b 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1115,3 +1115,18 @@ OpenLayers.Util.createUniqueID = function(prefix) { } return prefix + Math.round(Math.random() * 10000); }; + +/** 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, +}; + +/** sensible default */ +OpenLayers.DOTS_PER_INCH = 72;