5
5
import { GeoJSON as GeoJSONFormat } from '@supermap/iclient-common/format/GeoJSON' ;
6
6
import { getMeterPerMapUnit as MeterPerMapUnit } from '@supermap/iclient-common/util/MapCalculateUtil' ;
7
7
8
- /**
9
- * @name Util
10
- * @namespace
8
+ /**
9
+ * @function toGeoJSON
11
10
* @category BaseTypes Util
12
- * @description 工具类。
11
+ * @description 将传入对象转为 GeoJSON 格式。
12
+ * @param {Object } feature - 待转参数。
13
13
* @usage
14
14
* ```
15
15
* // 浏览器
16
16
* <script type="text/javascript" src="{cdn}"></script>
17
17
* <script>
18
- * const util = {namespace}.Util;
18
+ * {namespace}.Util.toGeoJSON(feature) ;
19
19
*
20
20
* </script>
21
+ *
21
22
* // ES6 Import
22
- * import { Util } from '{npm}';
23
+ * import { toGeoJSON } from '{npm}';
23
24
*
25
+ * toGeoJSON(feature);
24
26
* ```
25
27
*/
26
- export var toGeoJSON = function ( feature ) {
28
+ export var toGeoJSON = function ( feature ) {
27
29
if ( ! feature ) {
28
30
return feature ;
29
31
}
30
32
return new GeoJSONFormat ( ) . toGeoJSON ( feature ) ;
31
33
} ;
34
+
35
+ /**
36
+ * @function toSuperMapGeometry
37
+ * @category BaseTypes Util
38
+ * @description 将 GeoJSON 对象转为 SuperMap 几何图形。
39
+ * @param {GeoJSONObject } geometry - GeoJSON 对象。
40
+ * @usage
41
+ * ```
42
+ * // 浏览器
43
+ * <script type="text/javascript" src="{cdn}"></script>
44
+ * <script>
45
+ * {namespace}.Util.toSuperMapGeometry(geometry);
46
+ *
47
+ * </script>
48
+ *
49
+ * // ES6 Import
50
+ * import { toSuperMapGeometry } from '{npm}';
51
+ *
52
+ * toSuperMapGeometry(geometry);
53
+ * ```
54
+ */
32
55
export var toSuperMapGeometry = function ( geometry ) {
33
56
if ( ! geometry ) {
34
57
return geometry ;
@@ -59,6 +82,30 @@ export var toSuperMapGeometry = function(geometry) {
59
82
} ;
60
83
export var getMeterPerMapUnit = MeterPerMapUnit ;
61
84
85
+
86
+ /**
87
+ * @function resolutionToScale
88
+ * @category BaseTypes Util
89
+ * @description 通过分辨率计算比例尺。
90
+ * @param {number } resolution - 分辨率。
91
+ * @param {number } dpi - 屏幕分辨率。
92
+ * @param {string } mapUnit - 地图单位。
93
+ * @returns {number } 比例尺。
94
+ * @usage
95
+ * ```
96
+ * // 浏览器
97
+ * <script type="text/javascript" src="{cdn}"></script>
98
+ * <script>
99
+ * {namespace}.Util.resolutionToScale(resolution, dpi, mapUnit);
100
+ *
101
+ * </script>
102
+ *
103
+ * // ES6 Import
104
+ * import { resolutionToScale } from '{npm}';
105
+ *
106
+ * resolutionToScale(resolution, dpi, mapUnit);
107
+ * ```
108
+ */
62
109
export var resolutionToScale = function ( resolution , dpi , mapUnit ) {
63
110
var inchPerMeter = 1 / 0.0254 ;
64
111
// 地球半径。
@@ -67,6 +114,30 @@ export var resolutionToScale = function(resolution, dpi, mapUnit) {
67
114
scale = 1 / scale ;
68
115
return scale ;
69
116
} ;
117
+
118
+ /**
119
+ * @function scaleToResolution
120
+ * @category BaseTypes Util
121
+ * @description 通过比例尺计算分辨率。
122
+ * @param {number } scale - 比例尺。
123
+ * @param {number } dpi - 屏幕分辨率。
124
+ * @param {string } mapUnit - 地图单位。
125
+ * @returns {number } 分辨率。
126
+ * @usage
127
+ * ```
128
+ * // 浏览器
129
+ * <script type="text/javascript" src="{cdn}"></script>
130
+ * <script>
131
+ * {namespace}.Util.scaleToResolution(scale, dpi, mapUnit);
132
+ *
133
+ * </script>
134
+ *
135
+ * // ES6 Import
136
+ * import { scaleToResolution } from '{npm}';
137
+ *
138
+ * scaleToResolution(scale, dpi, mapUnit);
139
+ * ```
140
+ */
70
141
export var scaleToResolution = function ( scale , dpi , mapUnit ) {
71
142
var inchPerMeter = 1 / 0.0254 ;
72
143
var meterPerMapUnitValue = getMeterPerMapUnit ( mapUnit ) ;
@@ -75,10 +146,55 @@ export var scaleToResolution = function(scale, dpi, mapUnit) {
75
146
return resolution ;
76
147
} ;
77
148
149
+ /**
150
+ * @function NormalizeScale
151
+ * @category BaseTypes Util
152
+ * @description 转换比例尺。
153
+ * @param {number } scale - 比例尺。
154
+ * @returns {number } 正常的 scale 值。
155
+ * @usage
156
+ * ```
157
+ * // 浏览器
158
+ * <script type="text/javascript" src="{cdn}"></script>
159
+ * <script>
160
+ * {namespace}.Util.NormalizeScale(scale);
161
+ *
162
+ * </script>
163
+ *
164
+ * // ES6 Import
165
+ * import { NormalizeScale } from '{npm}';
166
+ *
167
+ * NormalizeScale(scale);
168
+ * ```
169
+ */
78
170
export var NormalizeScale = function ( scale ) {
79
171
return scale > 1.0 ? 1.0 / scale : scale ;
80
172
} ;
81
173
174
+ /**
175
+ * @function GetResolutionFromScaleDpi
176
+ * @category BaseTypes Util
177
+ * @description 根据比例尺和 dpi 计算屏幕分辨率。
178
+ * @param {number } scale - 比例尺。
179
+ * @param {number } dpi - 图像分辨率,表示每英寸内的像素个数。
180
+ * @param {string } [coordUnit] - 投影坐标系统的地图单位。
181
+ * @param {number } [datumAxis=6378137] - 地理坐标系统椭球体长半轴。用户自定义地图的 Options 时,若未指定该参数的值,则 DPI 默认按照 WGS84 参考系的椭球体长半轴 6378137 来计算。
182
+ * @returns {number } 当前比例尺下的屏幕分辨率。
183
+ * @usage
184
+ * ```
185
+ * // 浏览器
186
+ * <script type="text/javascript" src="{cdn}"></script>
187
+ * <script>
188
+ * {namespace}.Util.GetResolutionFromScaleDpi(scale, dpi, coordUnit, datumAxis);
189
+ *
190
+ * </script>
191
+ *
192
+ * // ES6 Import
193
+ * import { GetResolutionFromScaleDpi } from '{npm}';
194
+ *
195
+ * GetResolutionFromScaleDpi(scale, dpi, coordUnit, datumAxis);
196
+ * ```
197
+ */
82
198
export var GetResolutionFromScaleDpi = function ( scale , dpi , coordUnit , datumAxis ) {
83
199
var resolution = null ,
84
200
ratio = 10000 ;
0 commit comments