added getScaleFromResolution() function to util, also added tests for both directions of the scale<->resolution tranformation functions, as well as the normalizeScale() function

git-svn-id: http://svn.openlayers.org/trunk/openlayers@1534 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-10-03 03:21:45 +00:00
parent 642c438c2c
commit a758efb2f2
2 changed files with 54 additions and 0 deletions

View File

@@ -518,6 +518,26 @@ OpenLayers.Util.getResolutionFromScale = function (scale, units) {
return resolution;
};
/**
* @param {float} resolution
* @param {String} units Index into OpenLayers.INCHES_PER_UNIT hashtable.
* Default is degrees
*
* @returns The corresponding scale given passed-in resolution and unit
* parameters.
* @type float
*/
OpenLayers.Util.getScaleFromResolution = function (resolution, units) {
if (units == null) {
units = "degrees";
}
var scale = 1 / (resolution * OpenLayers.INCHES_PER_UNIT[units]
* OpenLayers.DOTS_PER_INCH);
return scale;
};
/** Safely stop the propagation of an event *without* preventing
* the default browser action from occurring.
*