(scales, bounds, dpi, mapUnit, level = 22, baseScale)
| 181 | * ``` |
| 182 | */ |
| 183 | export function scalesToResolutions(scales, bounds, dpi, mapUnit, level = 22, baseScale) { |
| 184 | const dpiValue = dpi === '' || dpi === null || dpi === undefined ? 96 : dpi; |
| 185 | var resolutions = []; |
| 186 | if (scales && scales.length > 0) { |
| 187 | for (let i = 0; i < scales.length; i++) { |
| 188 | resolutions.push(scaleToResolution(scales[i], dpiValue, mapUnit)); |
| 189 | } |
| 190 | } else if (baseScale){ |
| 191 | const maxReolution = Math.abs(bounds.left - bounds.right) / 256; |
| 192 | const baseRes = scaleToResolution(baseScale, dpiValue, mapUnit); |
| 193 | let topRes = baseRes; |
| 194 | for (let i = 0; i < level; i++) { |
| 195 | const temp = baseRes * Math.pow(2, i); |
| 196 | if(Math.abs(temp - maxReolution) <= 1E-6 || temp > maxReolution){ |
| 197 | topRes = temp; |
| 198 | break; |
| 199 | } |
| 200 | } |
| 201 | for (let i = 0; i < level; i++) { |
| 202 | resolutions.push(topRes / Math.pow(2, i)); |
| 203 | } |
| 204 | } else { |
| 205 | const maxReolution = Math.abs(bounds.left - bounds.right) / 256; |
| 206 | for (let i = 0; i < level; i++) { |
| 207 | resolutions.push(maxReolution / Math.pow(2, i)); |
| 208 | } |
| 209 | } |
| 210 | return resolutions.sort(function (a, b) { |
| 211 | return b - a; |
| 212 | }); |
| 213 | } |
| 214 | /** |
| 215 | * @private |
| 216 | * @function getZoomByResolution |
no test coverage detected