|
31 | 31 | * // ES6 Import
|
32 | 32 | * import { Util } from '{npm}';
|
33 | 33 | *
|
34 |
| - * const result = Util.getOlVersion(); |
| 34 | + * const result = Util.setMask(); |
35 | 35 | * ```
|
36 | 36 | */
|
37 | 37 | export const Util = {
|
|
54 | 54 | * @function Util.toGeoJSON
|
55 | 55 | * @description 将传入对象转为 GeoJSON 格式。
|
56 | 56 | * @param {Object} smObj - 待转换参数。
|
| 57 | + * @private |
57 | 58 | */
|
58 | 59 | toGeoJSON(smObj) {
|
59 | 60 | if (!smObj) {
|
|
66 | 67 | * @function Util.toSuperMapGeometry
|
67 | 68 | * @description 将 GeoJSON 对象转为 SuperMap 几何图形。
|
68 | 69 | * @param {GeoJSONObject} geoJSON - GeoJSON 对象。
|
| 70 | + * @private |
69 | 71 | */
|
70 | 72 | toSuperMapGeometry(geoJSON) {
|
71 | 73 | if (!geoJSON || !geoJSON.type) {
|
|
82 | 84 | * @param {number} dpi - 屏幕分辨率。
|
83 | 85 | * @param {string} mapUnit - 地图单位。
|
84 | 86 | * @returns {number} 比例尺。
|
| 87 | + * @private |
85 | 88 | */
|
86 | 89 | resolutionToScale(resolution, dpi, mapUnit) {
|
87 | 90 | const inchPerMeter = 1 / 0.0254;
|
|
96 | 99 | * @description 转为 SuperMapBounds 格式。
|
97 | 100 | * @param {Array.<number>} bounds - bounds 数组。
|
98 | 101 | * @returns {Bounds} 返回 SuperMap 的 Bounds 对象。
|
| 102 | + * @private |
99 | 103 | */
|
100 | 104 | toSuperMapBounds(bounds) {
|
101 | 105 | if (bounds instanceof Bounds) {
|
|
109 | 113 | * @description 将 Region 节点数组转为 Processing 服务需要的分析参数。
|
110 | 114 | * @param {Array} points - Region 各个节点数组。
|
111 | 115 | * @returns processing 服务裁剪、查询分析的分析参数。
|
| 116 | + * @private |
112 | 117 | */
|
113 | 118 | toProcessingParam(points) {
|
114 | 119 | if (points.length < 1) {
|
|
134 | 139 | * @param {number} dpi - 屏幕分辨率。
|
135 | 140 | * @param {string} mapUnit - 地图单位。
|
136 | 141 | * @returns {number} 分辨率。
|
| 142 | + * @private |
137 | 143 | */
|
138 | 144 | scaleToResolution(scale, dpi, mapUnit) {
|
139 | 145 | const inchPerMeter = 1 / 0.0254;
|
|
148 | 154 | * @description 获取每地图单位多少米。
|
149 | 155 | * @param {string} mapUnit - 地图单位。
|
150 | 156 | * @returns {number} 返回每地图单位多少米。
|
| 157 | + * @private |
151 | 158 | */
|
152 | 159 | getMeterPerMapUnit,
|
153 | 160 |
|
|
156 | 163 | * @description 判断是否为数组格式。
|
157 | 164 | * @param {Object} obj - 待判断对象。
|
158 | 165 | * @returns {boolean} 是否是数组。
|
| 166 | + * @private |
159 | 167 | */
|
160 | 168 | isArray,
|
161 | 169 |
|
|
164 | 172 | * @description 将 csv 格式转为 GeoJSON。
|
165 | 173 | * @param {Object} csv - csv 对象。
|
166 | 174 | * @param {Object} options - 转换参数。
|
| 175 | + * @private |
167 | 176 | */
|
168 | 177 | Csv2GeoJSON(csv, options) {
|
169 | 178 | const defaultOptions = {
|
|
252 | 261 | * @description 创建 2D 画布。
|
253 | 262 | * @param {number} opt_width - 画布宽度。
|
254 | 263 | * @param {number} opt_height - 画布高度。
|
| 264 | + * @private |
255 | 265 | */
|
256 | 266 | createCanvasContext2D(opt_width, opt_height) {
|
257 | 267 | const canvas = document.createElement('CANVAS');
|
|
266 | 276 | /**
|
267 | 277 | * @function Util.supportWebGL2
|
268 | 278 | * @description 是否支持 webgl2。
|
| 279 | + * @private |
269 | 280 | */
|
270 | 281 | supportWebGL2() {
|
271 | 282 | const canvas = document.createElement('canvas');
|
|
277 | 288 | * @description 是否为字符串
|
278 | 289 | * @param {string} str - 需要判断的内容
|
279 | 290 | * @returns {boolean}
|
| 291 | + * @private |
280 | 292 | */
|
281 | 293 | isString,
|
282 | 294 | /**
|
283 | 295 | * @function Util.isObject
|
284 | 296 | * @description 是否为对象
|
285 | 297 | * @param {any} obj - 需要判断的内容
|
286 | 298 | * @returns {boolean}
|
| 299 | + * @private |
287 | 300 | */
|
288 | 301 | isObject(obj) {
|
289 | 302 | return Object.prototype.toString.call(obj) === '[object Object]';
|
|
294 | 307 | * @description 字符串裁剪两边的空格
|
295 | 308 | * @param {string} str - 需要裁剪的字符串
|
296 | 309 | * @returns {boolean}
|
| 310 | + * @private |
297 | 311 | */
|
298 | 312 | trim(str = '') {
|
299 | 313 | return str.replace(/(^\s*)|(\s*$)/g, '');
|
|
303 | 317 | * @description 随机生成id
|
304 | 318 | * @param {string} attr - 几位数字的id
|
305 | 319 | * @returns {string}
|
| 320 | + * @private |
306 | 321 | */
|
307 | 322 | newGuid(attr) {
|
308 | 323 | let len = attr || 32;
|
|
318 | 333 | * @description 检测数据是否为number
|
319 | 334 | * @param {string} value - 值,未知数据类型
|
320 | 335 | * @returns {boolean}
|
| 336 | + * @private |
321 | 337 | */
|
322 | 338 | isNumber(value) {
|
323 | 339 | if (value === '') {
|
|
336 | 352 | * @param {string} featureName 原始数据中的地名
|
337 | 353 | * @param {string} fieldName 需要匹配的地名
|
338 | 354 | * @returns {boolean} 是否匹配
|
| 355 | + * @private |
339 | 356 | */
|
340 | 357 | isMatchAdministrativeName,
|
341 | 358 |
|
|
344 | 361 | * @param {string} featureName 初始匹配的要素数组
|
345 | 362 | * @param {string} fieldName 要匹配的地名
|
346 | 363 | * @returns {boolean} 是否匹配
|
| 364 | + * @private |
347 | 365 | */
|
348 | 366 | getHighestMatchAdministration(features, fieldName) {
|
349 | 367 | let filterFeatures = features.filter((item) => {
|
|
0 commit comments