* 处理坐标系(底图) * @private * @param {string} crs 必传参数,值是webmap2中定义的坐标系,可能是 1、EGSG:xxx 2、WKT string * @param {string} baseLayerUrl 可选参数,地图的服务地址;用于EPSG:-1 的时候,用于请求iServer提供的wkt * @return {Object}
(crs, baseLayerUrl)
| 385 | * @return {Object} |
| 386 | */ |
| 387 | async handleCRS(crs, baseLayerUrl) { |
| 388 | let that = this, |
| 389 | handleResult = {}; |
| 390 | let newCrs = crs, |
| 391 | action = 'OpenMap'; |
| 392 | |
| 393 | if (this.isCustomProjection(crs)) { |
| 394 | // 去iServer请求wkt 否则只能预览出图 |
| 395 | await FetchRequest.get(that.getRequestUrl(`${baseLayerUrl}/prjCoordSys.wkt`), null, { |
| 396 | withCredentials: that.isCredentail(baseLayerUrl), |
| 397 | withoutFormatSuffix: true |
| 398 | }) |
| 399 | .then(function (response) { |
| 400 | return response.text(); |
| 401 | }) |
| 402 | .then(async function (result) { |
| 403 | if (result.indexOf('<!doctype html>') === -1) { |
| 404 | that.addProjctionFromWKT(result, crs); |
| 405 | handleResult = { action, newCrs }; |
| 406 | } else { |
| 407 | throw 'ERROR'; |
| 408 | } |
| 409 | }) |
| 410 | .catch(function () { |
| 411 | action = 'BrowseMap'; |
| 412 | handleResult = { action, newCrs }; |
| 413 | }); |
| 414 | } else { |
| 415 | if (crs.indexOf('EPSG') === 0 && crs.split(':')[1] <= 0) { |
| 416 | // 自定义坐标系 rest map EPSG:-1(自定义坐标系) 支持编辑 |
| 417 | // 未知坐标系情况特殊处理,只支持预览 1、rest map EPSG:-1000(没定义坐标系) 2、wms/wmts EPSG:0 (自定义坐标系) |
| 418 | action = 'BrowseMap'; |
| 419 | } else if (crs === 'EPSG:910111' || crs === 'EPSG:910112') { |
| 420 | // 早期数据存在的自定义坐标系 "EPSG:910111": "GCJ02MERCATOR", "EPSG:910112": "BDMERCATOR" |
| 421 | newCrs = 'EPSG:3857'; |
| 422 | } else if (crs === 'EPSG:910101' || crs === 'EPSG:910102') { |
| 423 | // 早期数据存在的自定义坐标系 "EPSG:910101": "GCJ02", "EPSG:910102": "BD", |
| 424 | newCrs = 'EPSG:4326'; |
| 425 | } else if (crs.indexOf('EPSG') !== 0) { |
| 426 | // wkt |
| 427 | that.addProjctionFromWKT(newCrs); |
| 428 | newCrs = that.getEpsgInfoFromWKT(crs); |
| 429 | } |
| 430 | handleResult = { action, newCrs }; |
| 431 | } |
| 432 | return handleResult; |
| 433 | } |
| 434 | |
| 435 | /** |
| 436 | * @private |
no test coverage detected