|
6 | 6 | L.supermap = L.supermap || {}; |
7 | 7 | require('../Core/format/GeoJSON'); |
8 | 8 | require('./NonEarthCRS'); |
9 | | - |
| 9 | +require('./proj4leaflet'); |
| 10 | +require('./ExtendsCRS'); |
10 | 11 | L.Util.toGeoJSON = function (feature) { |
11 | 12 | if (!feature) { |
12 | 13 | return feature; |
13 | 14 | } |
14 | | - var result, format = new SuperMap.Format.GeoJSON(); |
15 | | - if (feature.geometry) { |
16 | | - result = JSON.parse(format.write(feature.geometry)); |
17 | | - } else { |
18 | | - result = JSON.parse(format.write(feature)); |
19 | | - } |
20 | | - return result; |
| 15 | + return JSON.parse(new SuperMap.Format.GeoJSON().write(feature)); |
21 | 16 | }; |
22 | | - |
| 17 | +L.Util.supermap_callbacks = {}; |
23 | 18 | L.Util.toSuperMapGeometry = function (geometry) { |
24 | 19 | if (!geometry) { |
25 | 20 | return geometry; |
@@ -47,7 +42,30 @@ L.Util.toSuperMapGeometry = function (geometry) { |
47 | 42 | return (serverResult && serverResult.geometry) ? serverResult.geometry : serverResult; |
48 | 43 |
|
49 | 44 | }; |
50 | | - |
| 45 | +L.Util.GetResolutionFromScaleDpi = function (scale, dpi, coordUnit, datumAxis) { |
| 46 | + var resolution = null, |
| 47 | + ratio = 10000; |
| 48 | + //用户自定义地图的Options时,若未指定该参数的值,则系统默认为6378137米,即WGS84参考系的椭球体长半轴。 |
| 49 | + datumAxis = datumAxis || 6378137; |
| 50 | + coordUnit = coordUnit || ""; |
| 51 | + if (scale > 0 && dpi > 0) { |
| 52 | + scale = L.Util.NormalizeScale (scale); |
| 53 | + if (coordUnit.toLowerCase() === "degree" || coordUnit.toLowerCase() === "degrees" || coordUnit.toLowerCase() === "dd") { |
| 54 | + //scale = SuperMap.Util.normalizeScale(scale); |
| 55 | + resolution = 0.0254 * ratio / dpi / scale / ((Math.PI * 2 * datumAxis) / 360) / ratio; |
| 56 | + return resolution; |
| 57 | + } else { |
| 58 | + resolution = 0.0254 * ratio / dpi / scale / ratio; |
| 59 | + return resolution; |
| 60 | + } |
| 61 | + } |
| 62 | + return -1; |
| 63 | +}; |
| 64 | +L.Util.NormalizeScale = function (scale) { |
| 65 | + var normScale = (scale > 1.0) ? (1.0 / scale) |
| 66 | + : scale; |
| 67 | + return normScale; |
| 68 | +}; |
51 | 69 | L.Util.Csv2GeoJSON = function (csv, options) { |
52 | 70 | var defaultOptions = { |
53 | 71 | titles: ['lon', 'lat'], |
|
0 commit comments