(scale, dpi, coordUnit, datumAxis)
| 195 | * ``` |
| 196 | */ |
| 197 | export var getResolutionFromScaleDpi = function(scale, dpi, coordUnit, datumAxis) { |
| 198 | var resolution = null, |
| 199 | ratio = 10000; |
| 200 | //用户自定义地图的Options时,若未指定该参数的值,则系统默认为6378137米,即WGS84参考系的椭球体长半轴。 |
| 201 | datumAxis = datumAxis || 6378137; |
| 202 | coordUnit = coordUnit || ''; |
| 203 | if (scale > 0 && dpi > 0) { |
| 204 | scale = normalizeScale(scale); |
| 205 | if ( |
| 206 | coordUnit.toLowerCase() === 'degree' || |
| 207 | coordUnit.toLowerCase() === 'degrees' || |
| 208 | coordUnit.toLowerCase() === 'dd' |
| 209 | ) { |
| 210 | //scale = CommonUtil.normalizeScale(scale); |
| 211 | resolution = (0.0254 * ratio) / dpi / scale / ((Math.PI * 2 * datumAxis) / 360) / ratio; |
| 212 | return resolution; |
| 213 | } else { |
| 214 | resolution = (0.0254 * ratio) / dpi / scale / ratio; |
| 215 | return resolution; |
| 216 | } |
| 217 | } |
| 218 | return -1; |
| 219 | }; |
| 220 | export { |
| 221 | getZoomByResolution, |
| 222 | scalesToResolutions, |
no test coverage detected