@@ -264,172 +264,3 @@ function getCRS(epsgCodeStr, { bounds, dpi, resolutions }) {
264
264
}
265
265
return new CRS ( epsgCodeStr , options ) ;
266
266
}
267
-
268
- // async function getOtherEpsgCRS(url, epsgCodeStr, { bounds, dpi, visibleScales }) {
269
- // const projDef = await FetchRequest.get(`${url}/prjCoordSys.wkt`, null, {
270
- // withoutFormatSuffix: true
271
- // }).then(function (response) {
272
- // return response.text();
273
- // });
274
- // console.log(proj4def);
275
- // proj4.defs(epsgCodeStr, projDef);
276
- // return getCRS(epsgCodeStr, { bounds, dpi, visibleScales, def: projDef });
277
- // }
278
- // /**
279
- // * @private
280
- // * @function getMapOptions
281
- // * @description 获取extent。
282
- // * @param {Object } url - 服务地址,例如: http://{ip}:{port}/iserver/services/map-world/rest/maps/World。
283
- // * @returns {Promise } Promise 对象。
284
- // */
285
- // async function getProjectionExtent(url) {
286
- // const extentInfo = await FetchRequest.get(url + '/prjCoordSys/projection/extent.json').then(function (response) {
287
- // if (response && response.status === 204) {
288
- // return null;
289
- // }
290
- // return response.json();
291
- // });
292
- // return extentInfo || null;
293
- // }
294
-
295
- // /**
296
- // * @private
297
- // * @function getEnvelop
298
- // * @description 获取地图参数。
299
- // * @param {Object } url - 服务地址,例如: http://{ip}:{port}/iserver/services/map-world/rest/maps/World。
300
- // * @param {Object } bounds - bounds。
301
- // * @returns {Promise } Promise 对象。
302
- // */
303
- // async function getEnvelop(url, bounds) {
304
- // const envelope = await getProjectionExtent(url);
305
- // if (!envelope) {
306
- // return bounds;
307
- // }
308
- // return envelope;
309
- // }
310
-
311
- // /**
312
- // * @private
313
- // * @function setBaseMapCRS
314
- // * @description 作为底图后,设置底图为自定义比例尺。
315
- // * @param {L.Map } map - Leaflet Map 对象。
316
- // * @param {CRS } originCrs - 图层或地图配置的CRS。
317
- // * @param {Object } mapJSONObj - 地图 JSON 对象。
318
- // */
319
- // function getBaseMapCRS(mapJSONObj, originCrs) {
320
- // let code = typeof originCrs === 'string' ? originCrs : originCrs.code;
321
- // let { bounds, visibleScales, visibleScalesEnabled, dpi } = mapJSONObj;
322
- // if (visibleScalesEnabled) {
323
- // let crs = new CRS(code, {
324
- // dpi,
325
- // origin: [bounds.left, bounds.top],
326
- // scales: visibleScales
327
- // });
328
- // return crs;
329
- // }
330
-
331
- // let crs = new CRS(code, {
332
- // dpi,
333
- // origin: [bounds.left, bounds.top],
334
- // bounds: getCRSBounds(bounds)
335
- // });
336
- // return crs;
337
- // // return originCrs;
338
- // }
339
-
340
- // function getCRSBounds(bounds) {
341
- // const { left, top, bottom, right } = bounds;
342
- // return [
343
- // [left, top],
344
- // [right, bottom]
345
- // ];
346
- // }
347
-
348
- // /**
349
- // * @private
350
- // * @function getLayerParams
351
- // * @description 获取图层参数。
352
- // * @param {Object } mapJSONObj - 地图 JSON 对象。
353
- // * @returns {Object } 图层参数。
354
- // */
355
- // function getLayerParams(mapJSONObj) {
356
- // const { clipRegionEnabled, clipRegion, cacheEnabled, overlapDisplayed, overlapDisplayedOptions } = mapJSONObj;
357
- // return {
358
- // clipRegionEnabled,
359
- // clipRegion,
360
- // cacheEnabled,
361
- // // prjCoordSys,
362
- // overlapDisplayed,
363
- // overlapDisplayedOptions: JSON.stringify(overlapDisplayedOptions)
364
- // };
365
- // }
366
- // /**
367
- // * @private
368
- // * @function _getMapCRS
369
- // * @description 获取mapCrs。
370
- // * @param {Object } url - 服务地址,例如: http://{ip}:{port}/iserver/services/map-world/rest/maps/World。
371
- // * @param {Object } mapJSONObj - 地图 JSON 对象。
372
- // * @param {Object } mapJSONObj.visibleScales - visibleScales
373
- // * @param {Object } mapJSONObj.prjCoordSys - prjCoordSys
374
- // * @param {number } mapJSONObj.dpi - dpi
375
- // * @param {Object } mapJSONObj.bounds - bounds。
376
- // * @returns {Promise } Promise 对象, crs
377
- // */
378
- // function _getMapCRS({ prjCoordSys, bounds, dpi, visibleScales }, def) {
379
- // let mapcrs = L.CRS.EPSG3857;
380
- // const { type, epsgCode } = prjCoordSys;
381
- // if (epsgCode == '4326' || epsgCode == '3857') {
382
- // mapcrs = getCRS('EPSG:' + epsgCode, { bounds, dpi, visibleScales });
383
- // } else if (type == 'PCS_NON_EARTH') {
384
- // mapcrs = getNonEarthCRS(bounds);
385
- // } else {
386
- // mapcrs = getCRS(url, 'EPSG:' + epsgCode, { bounds, dpi, visibleScales });
387
- // }
388
- // return mapcrs;
389
- // }
390
- // /**
391
- // * @private
392
- // * @function getVisibleScales
393
- // * @description 获取VisibleScales。
394
- // * @param {Object } url - 服务地址,例如: http://{ip}:{port}/iserver/services/map-world/rest/maps/World。
395
- // * @param {Object } mapJSONObj - 地图 JSON 对象。
396
- // * @param {Object } mapJSONObj.visibleScales - visibleScales
397
- // * @param {Object } mapJSONObj.prjCoordSys - prjCoordSys
398
- // * @param {number } mapJSONObj.dpi - dpi
399
- // * @param {Object } mapJSONObj.bounds - bounds。
400
- // * @param {Object } [mapOptions] - 地图参数。
401
- // * @param {Object } [mapOptions.maxZoom=22] - 地图最大缩放级别。
402
- // * @returns {Promise } Promise 对象, visibleScales。
403
- // */
404
- // function getVisibleScales({ visibleScales, prjCoordSys, dpi, bounds }, { maxZoom }) {
405
- // if (prjCoordSys && visibleScales.length == 0) {
406
- // return getScales(bounds, prjCoordSys.coordUnit, dpi, { maxZoom });
407
- // }
408
- // return visibleScales;
409
- // }
410
- // /**
411
- // * @private
412
- // * @function getMapOptions
413
- // * @description 获取地图参数。
414
- // * @param {Object } url - 服务地址,例如: http://{ip}:{port}/iserver/services/map-world/rest/maps/World。
415
- // * @param {Object } bounds - bounds.
416
- // * @param {string } coordUnit - coordUnit
417
- // * @param {number } dpi - dpi
418
- // * @param {Object } [mapOptions] - 地图参数。
419
- // * @param {Object } [mapOptions.maxZoom=22] - 地图最大缩放级别。
420
- // * @returns {Promise } Promise 对象。
421
- // */
422
- // function getScales(bounds, coordUnit, dpi, { maxZoom }) {
423
- // const resolution = Math.abs(bounds.left - bounds.right) / 256;
424
- // let temp = resolutionToScale(resolution, dpi, coordUnit);
425
- // let scales = [];
426
- // for (let i = 0; i < maxZoom; i++) {
427
- // if (i == 0) {
428
- // scales[i] = temp;
429
- // continue;
430
- // }
431
- // temp = temp * 2;
432
- // scales[i] = temp;
433
- // }
434
- // return scales;
435
- // }
0 commit comments