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:
@@ -418,6 +418,40 @@
|
||||
|
||||
|
||||
}
|
||||
|
||||
function test_13_Util_normalizeScale(t) {
|
||||
t.plan(2);
|
||||
|
||||
//normal scale
|
||||
var scale = 1/5;
|
||||
t.eq( OpenLayers.Util.normalizeScale(scale), scale, "normalizing a normal scale does nothing");
|
||||
|
||||
//funky scale
|
||||
var scale = 5;
|
||||
t.eq( OpenLayers.Util.normalizeScale(scale), 1/5, "normalizing a wrong scale works!");
|
||||
|
||||
|
||||
}
|
||||
|
||||
function test_13_Util_getScaleResolutionTranslation(t) {
|
||||
t.plan(4);
|
||||
|
||||
var scale = 1/150000000;
|
||||
var resolution = OpenLayers.Util.getResolutionFromScale(scale);
|
||||
t.eq(resolution.toFixed(6), "0.476217", "Calculated correct resolution for " + scale);
|
||||
|
||||
var scale = 1/150000000;
|
||||
var resolution = OpenLayers.Util.getResolutionFromScale(scale, 'm');
|
||||
t.eq(resolution.toFixed(6), "52916.638092", "Calculated correct resolution for " + scale);
|
||||
|
||||
scale = 150000000;
|
||||
resolution = OpenLayers.Util.getResolutionFromScale(scale);
|
||||
t.eq(resolution.toFixed(6), "0.476217", "Calculated correct resolution for " + scale);
|
||||
|
||||
scale = 1/150000000;
|
||||
resolution = OpenLayers.Util.getResolutionFromScale(scale);
|
||||
t.eq(OpenLayers.Util.getScaleFromResolution(resolution), scale, "scale->resolution->scale works");
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user