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:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user