-
Glenn Vorhes authoredGlenn Vorhes authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
zoomResolutionConvert.js 6.68 KiB
/**
* Created by gavorhes on 12/14/2015.
*/
"use strict";
var provide_1 = require("../util/provide");
var nm = provide_1.default('olHelpers.zoomResolutionConvert');
var _zoomResLookup = [
156543.03392804097,
78271.51696402048,
39135.75848201024,
19567.87924100512,
9783.93962050256,
4891.96981025128,
2445.98490512564,
1222.99245256282,
611.49622628141,
305.748113140705,
152.8740565703525,
76.43702828517625,
38.21851414258813,
19.109257071294063,
9.554628535647032,
4.777314267823516,
2.388657133911758,
1.194328566955879,
0.5971642834779395,
0.29858214173896974,
0.14929107086948487,
0.07464553543474244,
0.03732276771737122,
0.01866138385868561,
0.009330691929342804,
0.004665345964671402,
0.002332672982335701,
0.0011663364911678506,
0.0005831682455839253 //28
];
/**
* Get the resolution given the zoom level
* @param {number} zoomLevel - the zoom level
* @returns {number|*} the map resolution
*/
function zoomToResolution(zoomLevel) {
"use strict";
if (typeof zoomLevel == 'number') {
if (zoomLevel % 1 === 0 && zoomLevel >= 0 && zoomLevel <= 28) {
return _zoomResLookup[zoomLevel];
}
else {
console.log("invalid zoom level provided: " + zoomLevel);
return undefined;
}
}
else {
return undefined;
}
}
exports.zoomToResolution = zoomToResolution;
nm.zoomToResolution = zoomToResolution;
/**
* Get resolution from the zoom level
* @param {number} resolution - the resolution
* @returns {number|*} the zoom level
*/
function resolutionToZoom(resolution) {
for (var i = 0; i < _zoomResLookup.length; i++) {
if (resolution >= _zoomResLookup[i]) {
return i;
}
}
return 0;
}
exports.resolutionToZoom = resolutionToZoom;
nm.resolutionToZoom = resolutionToZoom;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiem9vbVJlc29sdXRpb25Db252ZXJ0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL29sSGVscGVycy96b29tUmVzb2x1dGlvbkNvbnZlcnQud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vblxyXG4gKiBAcmV0dXJucyB7bnVtYmVyfCp9IHRoZSB6b29tIGxldmVsXHJcbiAqL1xyXG5leHBvcnQgZnVuY3Rpb24gcmVzb2x1dGlvblRvWm9vbShyZXNvbHV0aW9uKXtcclxuICAgIGZvciAobGV0IGkgPSAwOyBpIDwgX3pvb21SZXNMb29rdXAubGVuZ3RoOyBpKyspe1xyXG4gICAgICAgIGlmIChyZXNvbHV0aW9uID49IF96b29tUmVzTG9va3VwW2ldICl7XHJcbiAgICAgICAgICAgIHJldHVybiBpO1xyXG4gICAgICAgIH1cclxuICAgIH1cclxuXHJcbiAgICByZXR1cm4gMDtcclxufVxyXG5cclxubm0ucmVzb2x1dGlvblRvWm9vbSA9IHJlc29sdXRpb25Ub1pvb207XHJcbiJdfQ==