@supermapgis/iclient-ol 12.0.1-r → 12.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/control/ChangeTileVersion.js +1 -1
  2. package/control/Logo.js +1 -1
  3. package/control/ScaleLine.js +1 -1
  4. package/control/index.js +1 -1
  5. package/core/MapExtend.js +1 -1
  6. package/core/StyleUtils.js +1 -10
  7. package/core/Util.js +18 -7
  8. package/core/index.js +1 -1
  9. package/css/index.js +1 -1
  10. package/dist/iclient-openlayers-es6.js +67256 -59323
  11. package/dist/iclient-openlayers-es6.min.js +3 -3
  12. package/dist/iclient-openlayers.css +2 -2
  13. package/dist/iclient-openlayers.js +147394 -138648
  14. package/dist/iclient-openlayers.min.css +2 -2
  15. package/dist/iclient-openlayers.min.js +3 -3
  16. package/index.js +1 -1
  17. package/mapping/BaiduMap.js +1 -1
  18. package/mapping/ImageSuperMapRest.js +16 -5
  19. package/mapping/ImageTileSuperMapRest.js +2 -2
  20. package/mapping/InitMap.js +1 -1
  21. package/mapping/SuperMapCloud.js +1 -1
  22. package/mapping/Tianditu.js +6 -6
  23. package/mapping/TileSuperMapRest.js +266 -153
  24. package/mapping/WebMap.js +84 -30
  25. package/mapping/index.js +1 -1
  26. package/namespace.js +1 -1
  27. package/overlay/DataFlow.js +5 -5
  28. package/overlay/FGB.js +1 -1
  29. package/overlay/Graph.js +1 -1
  30. package/overlay/GraphMap.js +4 -4
  31. package/overlay/Graphic.js +1 -1
  32. package/overlay/HeatMap.js +1 -1
  33. package/overlay/Label.js +1 -1
  34. package/overlay/Mapv.js +1 -1
  35. package/overlay/Range.js +1 -1
  36. package/overlay/RankSymbol.js +1 -1
  37. package/overlay/Turf.js +1 -1
  38. package/overlay/Unique.js +1 -1
  39. package/overlay/VectorTileSuperMapRest.js +2 -2
  40. package/overlay/graphic/CanvasRenderer.js +1 -1
  41. package/overlay/graphic/CloverShape.js +1 -1
  42. package/overlay/graphic/Graphic.js +1 -1
  43. package/overlay/graphic/HitCloverShape.js +1 -1
  44. package/overlay/graphic/WebGLRenderer.js +1 -1
  45. package/overlay/graphic/index.js +1 -1
  46. package/overlay/index.js +1 -1
  47. package/overlay/mapv/MapvCanvasLayer.js +1 -1
  48. package/overlay/mapv/MapvLayer.js +1 -1
  49. package/overlay/mapv/index.js +1 -1
  50. package/overlay/theme/GeoFeature.js +1 -1
  51. package/overlay/theme/Theme.js +2 -2
  52. package/overlay/theme/ThemeFeature.js +1 -1
  53. package/overlay/theme/index.js +1 -1
  54. package/overlay/vectortile/DeafultCanvasStyle.js +1 -1
  55. package/overlay/vectortile/MapboxStyles.js +2 -2
  56. package/overlay/vectortile/StyleMap.js +1 -1
  57. package/overlay/vectortile/VectorTileStyles.js +2 -2
  58. package/overlay/vectortile/index.js +1 -1
  59. package/overlay/vectortile/olExtends.js +1 -9
  60. package/package.json +2 -2
  61. package/services/AddressMatchService.js +3 -3
  62. package/services/ChartService.js +55 -6
  63. package/services/DataFlowService.js +9 -9
  64. package/services/DatasetService.js +5 -5
  65. package/services/DatasourceService.js +5 -5
  66. package/services/FeatureService.js +10 -15
  67. package/services/FieldService.js +3 -3
  68. package/services/GeoprocessingService.js +1 -1
  69. package/services/GridCellInfosService.js +3 -4
  70. package/services/ImageCollectionService.js +3 -3
  71. package/services/ImageService.js +3 -3
  72. package/services/KnowledgeGraphService.js +3 -3
  73. package/services/LayerInfoService.js +2 -2
  74. package/services/MapService.js +3 -3
  75. package/services/MeasureService.js +4 -5
  76. package/services/NetworkAnalyst3DService.js +3 -5
  77. package/services/NetworkAnalystService.js +4 -6
  78. package/services/ProcessingService.js +3 -3
  79. package/services/QueryService.js +8 -9
  80. package/services/ServiceBase.js +12 -6
  81. package/services/SpatialAnalystService.js +4 -9
  82. package/services/ThemeService.js +5 -4
  83. package/services/TrafficTransferAnalystService.js +3 -3
  84. package/services/WebPrintingJobService.js +3 -3
  85. package/services/index.js +1 -1
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
1
+ /* Copyright© 2000 - 2026 SuperMap Software Co.Ltd. All rights reserved.
2
2
  * This program are made available under the terms of the Apache License, Version 2.0
3
3
  * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4
4
  export * from '@supermapgis/iclient-common/index.common';
@@ -1,4 +1,4 @@
1
- /* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
1
+ /* Copyright© 2000 - 2026 SuperMap Software Co.Ltd. All rights reserved.
2
2
  * This program are made available under the terms of the Apache License, Version 2.0
3
3
  * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4
4
  import TileImage from 'ol/source/TileImage';
@@ -1,4 +1,4 @@
1
- /* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
1
+ /* Copyright© 2000 - 2026 SuperMap Software Co.Ltd. All rights reserved.
2
2
  * This program are made available under the terms of the Apache License, Version 2.0
3
3
  * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4
4
  import { SecurityManager } from '@supermapgis/iclient-common/security/SecurityManager';
@@ -8,8 +8,6 @@ import { ServerGeometry } from '@supermapgis/iclient-common/iServer/ServerGeomet
8
8
  import { Util } from '../core/Util';
9
9
  import ImageSource from 'ol/source/Image';
10
10
  import ImageWrapper, { decode } from 'ol/Image';
11
- import Geometry from 'ol/geom/Geometry';
12
- import GeoJSON from 'ol/format/GeoJSON';
13
11
  import { containsExtent, getCenter, getHeight, getWidth, getForViewAndSize } from 'ol/extent';
14
12
 
15
13
  /**
@@ -41,6 +39,16 @@ import { containsExtent, getCenter, getHeight, getWidth, getForViewAndSize } fro
41
39
  * @param {string} [options.tileversion] - 切片版本名称,_cache 为 true 时有效。
42
40
  * @param {string} [options.tileProxy] - 代理地址。
43
41
  * @param {NDVIParameter|HillshadeParameter} [options.rasterfunction] - 栅格分析参数。
42
+ * @param {Object} [options.displayFilters] - 图层的显示过滤条件,利用该参数控制图层中可显示的要素。
43
+ * 参数结构:
44
+ * {
45
+ * "<layerName1>": "{displayFilter}",
46
+ * "<layerName2>": "{displayFilter}"
47
+ * }
48
+ * 其中,
49
+ * <layerName> 为地图中某图层名称,可从 layer 资源响应体参数 name 中获取;
50
+ * {displayFilter} 为属性过滤条件,仅对数据中存在的属性生效。
51
+ * 当前仅支持对工作空间数据源发布的地图进行属性过滤,支持对多图层同时过滤。
44
52
  * @param {string} [options.format = 'png'] - 瓦片表述类型,支持 "png" 、"webp"、"bmp" 、"jpg"、"gif" 等图片类型。
45
53
  * @deprecated {Function} [options.imageLoadFunction] - 加载图片的方法。默认为function(imageTile, src) {imageTile.getImage().src = src;};
46
54
  * @param {string} [options.ratio=1.5] - 请求图片大小比例。 1 表示请求图片大小和地图视窗范围一致,2 表示请求图片大小是地图视窗范围的2倍,以此类推。
@@ -109,8 +117,8 @@ export class ImageSuperMapRest extends ImageSource {
109
117
  if (options.prjCoordSys) {
110
118
  params['prjCoordSys'] = JSON.stringify(options.prjCoordSys);
111
119
  }
112
- if (options.clipRegionEnabled && options.clipRegion instanceof Geometry) {
113
- options.clipRegion = Util.toSuperMapGeometry(new GeoJSON().writeGeometryObject(options.clipRegion));
120
+ if (options.clipRegionEnabled) {
121
+ options.clipRegion = Util.toSuperMapGeometry(options.clipRegion);
114
122
  options.clipRegion = CommonUtil.toJSON(ServerGeometry.fromGeometry(options.clipRegion));
115
123
  params['clipRegionEnabled'] = options.clipRegionEnabled;
116
124
  params['clipRegion'] = JSON.stringify(options.clipRegion);
@@ -126,6 +134,9 @@ export class ImageSuperMapRest extends ImageSource {
126
134
  if (options.rasterfunction) {
127
135
  params['rasterfunction'] = JSON.stringify(options.rasterfunction);
128
136
  }
137
+ if (options.displayFilters) {
138
+ params['displayFilters'] = JSON.stringify(options.displayFilters);
139
+ }
129
140
  //是否反走样地图,默认为false
130
141
  if (options.antialias !== undefined) {
131
142
  params['antialias'] = options.antialias;
@@ -1,4 +1,4 @@
1
- /* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
1
+ /* Copyright© 2000 - 2026 SuperMap Software Co.Ltd. All rights reserved.
2
2
  * This program are made available under the terms of the Apache License, Version 2.0
3
3
  * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4
4
 
@@ -21,7 +21,7 @@ import { Util as CommonUtil } from '@supermapgis/iclient-common/commontypes/Util
21
21
  * @param {Array.<string>} [options.names] 返回影像集合中指定名称影像的瓦片资源。影像名称包含文件后缀,如 S-60-45.tif。
22
22
  * @param {string} [options.format='png'] - 瓦片表述类型,瓦片格式目前支持 png、jpg 和 webp 三种格式。
23
23
  * @param {boolean} [options.transparent=true] - 瓦片是否透明。默认透明。
24
- * @param {boolean} [options.cacheEnabled=true] - 是否启用缓存。
24
+ * @param {boolean} [options.cacheEnabled=true] - 是否缓存到本地。为 true 时,访问发布的服务时就可以在本地生成地图瓦片,从而可以提高后续服务浏览访问的速度。
25
25
  * @param {string} [options.tileProxy] - 代理地址。
26
26
  * @param {string} [options.attribution='Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' title='SuperMap iServer' target='_blank'>SuperMap iServer</a></span>'] - 版权描述信息。
27
27
  * @extends {ol.source.XYZ}
@@ -23,7 +23,7 @@ window.proj4 = proj4;
23
23
  * @param {Object} [options.layerOptions] - 图层配置,参数设置参考 {@link https://openlayers.org/en/v6.15.1/apidoc/module-ol_layer_Tile-TileLayer.html} ,未设置的情况下,默认使用 SuperMap iServer 服务参数进行设置。
24
24
  * @param {Object} [options.sourceOptions] - 数据源配置,参数设置参考 {@link TileSuperMapRest} ,未设置的情况下,默认使用 SuperMap iServer 服务参数进行设置。
25
25
  * @param {string} [options.proxy] - 服务代理地址。
26
- * @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
26
+ * @param {boolean} [options.withCredentials] - 请求是否携带凭据。默认情况下,仅同源请求包含凭据。
27
27
  * @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
28
28
  * @param {Object} [options.headers] - 请求头。
29
29
  * @returns {Object} 实例对象,对象包括地图实例,图层实例,数据源实例。
@@ -1,4 +1,4 @@
1
- /* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
1
+ /* Copyright© 2000 - 2026 SuperMap Software Co.Ltd. All rights reserved.
2
2
  * This program are made available under the terms of the Apache License, Version 2.0
3
3
  * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4
4
 
@@ -1,4 +1,4 @@
1
- /* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
1
+ /* Copyright© 2000 - 2026 SuperMap Software Co.Ltd. All rights reserved.
2
2
  * This program are made available under the terms of the Apache License, Version 2.0
3
3
  * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4
4
 
@@ -12,8 +12,8 @@ import WMTSTileGrid from 'ol/tilegrid/WMTS';
12
12
  * @classdesc 天地图图层源。
13
13
  * @modulecategory Mapping
14
14
  * @param {Object} opt_options - 参数。
15
- * @param {string} [opt_options.url='http://t{0-7}.tianditu.gov.cn/{layer}_{proj}/wmts?'] - 服务地址。
16
- * @param {string} opt_options.key - 天地图服务密钥。详见{@link http://lbs.tianditu.gov.cn/server/MapService.html}
15
+ * @param {string} [opt_options.url='https://t{0-7}.tianditu.gov.cn/{layer}_{proj}/wmts?'] - 服务地址。
16
+ * @param {string} opt_options.key - 天地图服务密钥。详见{@link https://lbs.tianditu.gov.cn/server/MapService.html}
17
17
  * @param {string} [opt_options.layerType='vec'] - 图层类型。(vec:矢量图层,img:影像图层,ter:地形图层)
18
18
  * @param {string} [opt_options.attributions] - 版权描述信息。
19
19
  * @param {number} [opt_options.cacheSize = 2048] - 缓冲大小。
@@ -39,14 +39,14 @@ export class Tianditu extends WMTS {
39
39
  "img": 18
40
40
  }
41
41
  var options = opt_options || {};
42
- var attributions = options.attributions || "Map Data <a href='http://www.tianditu.gov.cn' target='_blank'><img style='background-color:transparent;bottom:2px;opacity:1;' " +
43
- "src='http://api.tianditu.gov.cn/img/map/logo.png' width='53px' height='22px' opacity='0'></a> with " +
42
+ var attributions = options.attributions || "Map Data <a href='https://www.tianditu.gov.cn' target='_blank'><img style='background-color:transparent;bottom:2px;opacity:1;' " +
43
+ "src='https://api.tianditu.gov.cn/img/map/logo.png' width='53px' height='22px' opacity='0'></a> with " +
44
44
  "<span>© SuperMap iClient</span>"
45
45
  options.layerType = options.layerType || "vec";
46
46
  options.layerType = options.isLabel ? layerLabelMap[options.layerType] : options.layerType;
47
47
  options.matrixSet = (options.projection === 'EPSG:4326' || options.projection === 'EPSG:4490') ? "c" : "w";
48
48
  if (!options.url && !options.urls) {
49
- options.url = "http://t{0-7}.tianditu.gov.cn/{layer}_{proj}/wmts?"
49
+ options.url = "https://t{0-7}.tianditu.gov.cn/{layer}_{proj}/wmts?"
50
50
  }
51
51
  if (options.key) {
52
52
  options.url = `${options.url}tk=${options.key}`;
@@ -1,4 +1,4 @@
1
- /* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
1
+ /* Copyright© 2000 - 2026 SuperMap Software Co.Ltd. All rights reserved.
2
2
  * This program are made available under the terms of the Apache License, Version 2.0
3
3
  * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4
4
  import { SecurityManager } from '@supermapgis/iclient-common/security/SecurityManager';
@@ -7,20 +7,59 @@ import { Util as CommonUtil } from '@supermapgis/iclient-common/commontypes/Util
7
7
  import { ServerGeometry } from '@supermapgis/iclient-common/iServer/ServerGeometry';
8
8
  import { Util } from '../core/Util';
9
9
  import TileImage from 'ol/source/TileImage';
10
+ import TileRange from 'ol/TileRange';
10
11
  import Geometry from 'ol/geom/Geometry';
11
- import GeoJSON from 'ol/format/GeoJSON';
12
12
  import * as olSize from 'ol/size';
13
13
  import * as olTilegrid from 'ol/tilegrid';
14
14
  import TileGrid from 'ol/tilegrid/TileGrid';
15
15
 
16
+ function getOverflowTileCount(overflowTiles) {
17
+ return Math.max(0, Math.floor(Number(overflowTiles) || 0));
18
+ }
19
+
20
+ function wrapTileGridWithOverflow(tileGrid, overflowTiles) {
21
+ const overflowTileCount = getOverflowTileCount(overflowTiles);
22
+ if (!tileGrid || !overflowTileCount) {
23
+ return tileGrid;
24
+ }
25
+
26
+ const wrappedTileGrid = Object.create(tileGrid);
27
+ wrappedTileGrid.overflowTiles = overflowTileCount;
28
+ wrappedTileGrid.getTileRangeForExtentAndZ = function (extent, z, tempTileRange) {
29
+ const tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z, tempTileRange);
30
+ if (!tileRange) {
31
+ return tileRange;
32
+ }
33
+ tileRange.minX -= overflowTileCount;
34
+ tileRange.maxX += overflowTileCount;
35
+ tileRange.minY -= overflowTileCount;
36
+ tileRange.maxY += overflowTileCount;
37
+ return tileRange;
38
+ };
39
+ wrappedTileGrid.getFullTileRange = function (z) {
40
+ const tileRange = tileGrid.getFullTileRange ? tileGrid.getFullTileRange(z) : null;
41
+ if (!tileRange) {
42
+ return tileRange;
43
+ }
44
+ return new TileRange(
45
+ tileRange.minX - overflowTileCount,
46
+ tileRange.maxX + overflowTileCount,
47
+ tileRange.minY - overflowTileCount,
48
+ tileRange.maxY + overflowTileCount
49
+ );
50
+ };
51
+ return wrappedTileGrid;
52
+ }
53
+
16
54
  /**
17
55
  * @class TileSuperMapRest
18
56
  * @browsernamespace ol.source
19
57
  * @category iServer Map Tile
20
58
  * @modulecategory Mapping
21
- * @classdesc SuperMap iServer TileImage 图层源。
59
+ * @classdesc 以地图瓦片的方式展示 SuperMap iServer 的 REST 地图服务的地图。它通过调用 TileImage 接口获取地图瓦片。
22
60
  * @param {Object} options - 参数。
23
- * @param {string} options.url - 服务地址,例如: http://{ip}:{port}/iserver/services/map-world/rest/maps/World。
61
+ * @param {string} options.url - 服务地址,例如: http://{ip}:{port}/iserver/services/map-world/rest/maps/World。
62
+ * @param {Array.<string>} options.urls - 服务地址数组,例如: http://{ip}:{port}/iserver/services/map-world/rest/maps/World。
24
63
  * @param {ol.tilegrid.TileGrid} [options.tileGrid] - 瓦片网格对象。当不指定时,会通过 options.extent 或投影范围生成。
25
64
  * @param {boolean} [options.redirect = false] - 是否重定向。
26
65
  * @param {boolean} [options.transparent = true] - 瓦片是否透明。
@@ -35,181 +74,251 @@ import TileGrid from 'ol/tilegrid/TileGrid';
35
74
  * @param {string} [options.tileProxy] - 服务代理地址。
36
75
  * @param {string} [options.format = 'png'] - 瓦片表述类型,支持 "png" 、"webp"、"bmp" 、"jpg"、"gif" 等图片类型。
37
76
  * @param {(NDVIParameter|HillshadeParameter)} [options.rasterfunction] - 栅格分析参数。
38
- * @param {ChartSetting} [options.chartSetting] - 海图显示参数设置类,用于管理海图显示环境,包括海图的显示模式、显示类型名称、颜色模式、安全水深线等各种显示风格。
77
+ * @param {Object} [options.displayFilters] - 图层的显示过滤条件,利用该参数控制图层中可显示的要素。
78
+ * 参数结构:
79
+ * {
80
+ * "&lt;layerName1&gt;": "{displayFilter}",
81
+ * "&lt;layerName2&gt;": "{displayFilter}"
82
+ * }
83
+ * 其中,
84
+ * &lt;layerName&gt; 为地图中某图层名称,可从 layer 资源响应体参数 name 中获取;
85
+ * {displayFilter} 为属性过滤条件,仅对数据中存在的属性生效。
86
+ * 当前仅支持对工作空间数据源发布的地图进行属性过滤,支持对多图层同时过滤。
87
+ * @param {ChartSettingS57|ChartSettingS100} [options.chartSetting] - 海图显示参数设置类,用于管理海图显示环境,包括海图的显示模式、显示类型名称、颜色模式、安全水深线等各种显示风格。
88
+ * @param {number} [options.overflowTiles = 0] - 在当前视口范围外额外渲染的瓦片圈数。为 1 时上下左右各多请求一圈瓦片,可用于缓解符号在图层范围边缘被裁切的问题。
39
89
  * @extends {ol.source.TileImage}
40
90
  * @usage
41
91
  */
42
92
  export class TileSuperMapRest extends TileImage {
43
93
  constructor(options) {
44
- options = options || {};
45
- options.attributions =
46
- options.attributions || "Map Data <span>© SuperMap iServer</span> with <span>© SuperMap iClient</span>";
94
+ options = options || {};
95
+ options.attributions =
96
+ options.attributions || 'Map Data <span>© SuperMap iServer</span> with <span>© SuperMap iClient</span>';
47
97
 
48
- options.format = options.format ? options.format : 'png';
98
+ options.format = options.format ? options.format : 'png';
99
+ const tileGrid = wrapTileGridWithOverflow(options.tileGrid, options.overflowTiles);
49
100
 
50
- super({
51
- attributions: options.attributions,
52
- cacheSize: options.cacheSize,
53
- crossOrigin: options.crossOrigin,
54
- logo: Util.getOlVersion() === '4' ? options.logo : null,
55
- opaque: options.opaque,
56
- projection: options.projection,
57
- reprojectionErrorThreshold: options.reprojectionErrorThreshold,
58
- state: options.state,
59
- tileClass: options.tileClass,
60
- tileGrid: options.tileGrid,
61
- tileLoadFunction: options.tileLoadFunction,
62
- tilePixelRatio: options.tilePixelRatio,
63
- tileUrlFunction: tileUrlFunction,
64
- wrapX: options.wrapX !== undefined ? options.wrapX : false,
65
- cacheEnabled: options.cacheEnabled,
66
- layersID: options.layersID
67
- });
68
- if (options.tileProxy) {
69
- this.tileProxy = options.tileProxy;
101
+ super({
102
+ attributions: options.attributions,
103
+ cacheSize: options.cacheSize,
104
+ crossOrigin: options.crossOrigin,
105
+ logo: Util.getOlVersion() === '4' ? options.logo : null,
106
+ opaque: options.opaque,
107
+ projection: options.projection,
108
+ reprojectionErrorThreshold: options.reprojectionErrorThreshold,
109
+ state: options.state,
110
+ tileClass: options.tileClass,
111
+ tileGrid: tileGrid,
112
+ tileLoadFunction: options.tileLoadFunction,
113
+ tilePixelRatio: options.tilePixelRatio,
114
+ tileUrlFunction: options.tileUrlFunction || tileUrlFunction,
115
+ wrapX: options.wrapX !== undefined ? options.wrapX : false,
116
+ cacheEnabled: options.cacheEnabled,
117
+ layersID: options.layersID
118
+ });
119
+ if (options.tileProxy) {
120
+ this.tileProxy = options.tileProxy;
121
+ }
122
+ options.tileGrid = tileGrid;
123
+ this.options = options;
124
+ //当前切片在切片集中的index
125
+ this.tileSetsIndex = -1;
126
+ this.tempIndex = -1;
127
+ this._paramsVersion = 0;
128
+ this.dpi = this.options.dpi || 96;
129
+ if (options.url) {
130
+ this._urls = expandUrl(options.url);
131
+ if (this._urls.length === 1) {
132
+ this._tileImageUrl = CommonUtil.urlPathAppend(this._urls[0], 'tileImage.' + options.format);
70
133
  }
71
- this.options = options;
72
- this._url = options.url;
73
- //当前切片在切片集中的index
74
- this.tileSetsIndex = -1;
75
- this.tempIndex = -1;
76
- this.dpi = this.options.dpi || 96;
77
- var me = this;
78
- var layerUrl = CommonUtil.urlPathAppend(options.url, 'tileImage.' + options.format);
134
+ } else {
135
+ this._urls = options.urls;
136
+ }
137
+ var me = this;
79
138
 
80
- /**
81
- * @function TileSuperMapRest.prototype.getAllRequestParams
82
- * @description 获取全部请求参数。
83
- */
84
- function getAllRequestParams() {
85
- var me = this,
86
- params = {};
139
+ /**
140
+ * @function TileSuperMapRest.prototype.getAllRequestParams
141
+ * @description 获取全部请求参数。
142
+ */
143
+ function getAllRequestParams(layerUrlPrefix) {
144
+ var me = this,
145
+ params = {};
87
146
 
88
- params['redirect'] = options.redirect !== undefined ? options.redirect : false;
89
- //切片是否透明
90
- params['transparent'] = options.transparent !== undefined ? options.transparent : true;
91
- params['cacheEnabled'] = !(options.cacheEnabled === false);
92
- //存储一个cacheEnabled参数
93
- me.cacheEnabled = params['cacheEnabled'];
94
- params['_cache'] = params['cacheEnabled'];
147
+ params['redirect'] = options.redirect !== undefined ? options.redirect : false;
148
+ //切片是否透明
149
+ params['transparent'] = options.transparent !== undefined ? options.transparent : true;
150
+ params['cacheEnabled'] = !(options.cacheEnabled === false);
151
+ //存储一个cacheEnabled参数
152
+ me.cacheEnabled = params['cacheEnabled'];
153
+ params['_cache'] = params['cacheEnabled'];
95
154
 
96
- //设置切片原点
97
- if (this.origin) {
98
- params['origin'] = JSON.stringify({
99
- x: this.origin[0],
100
- y: this.origin[1]
101
- });
102
- }
155
+ //设置切片原点
156
+ if (this.origin) {
157
+ params['origin'] = JSON.stringify({
158
+ x: this.origin[0],
159
+ y: this.origin[1]
160
+ });
161
+ }
103
162
 
104
- if (options.prjCoordSys) {
105
- params['prjCoordSys'] = JSON.stringify(options.prjCoordSys);
106
- }
163
+ if (options.prjCoordSys) {
164
+ params['prjCoordSys'] = JSON.stringify(options.prjCoordSys);
165
+ }
107
166
 
108
- if (options.layersID) {
109
- params['layersID'] = options.layersID.toString();
110
- }
167
+ if (options.layersID) {
168
+ params['layersID'] = options.layersID.toString();
169
+ }
111
170
 
112
- if (options.clipRegion instanceof Geometry) {
113
- options.clipRegionEnabled = true;
114
- options.clipRegion = Util.toSuperMapGeometry(new GeoJSON().writeGeometryObject(options.clipRegion));
115
- options.clipRegion = CommonUtil.toJSON(ServerGeometry.fromGeometry(options.clipRegion));
116
- params['clipRegionEnabled'] = options.clipRegionEnabled;
117
- params['clipRegion'] = JSON.stringify(options.clipRegion);
118
- }
171
+ if (options.clipRegion instanceof Geometry) {
172
+ options.clipRegionEnabled = true;
173
+ options.clipRegion = Util.toSuperMapGeometry(options.clipRegion);
174
+ options.clipRegion = CommonUtil.toJSON(ServerGeometry.fromGeometry(options.clipRegion));
175
+ params['clipRegionEnabled'] = options.clipRegionEnabled;
176
+ params['clipRegion'] = JSON.stringify(options.clipRegion);
177
+ }
119
178
 
120
- if (!options.overlapDisplayed) {
121
- params['overlapDisplayed'] = false;
122
- if (options.overlapDisplayedOptions) {
123
- params['overlapDisplayedOptions'] = me.overlapDisplayedOptions.toString();
124
- }
125
- } else {
126
- params['overlapDisplayed'] = true;
127
- }
179
+ if (!options.overlapDisplayed) {
180
+ params['overlapDisplayed'] = false;
181
+ if (options.overlapDisplayedOptions) {
182
+ params['overlapDisplayedOptions'] = me.overlapDisplayedOptions.toString();
183
+ }
184
+ } else {
185
+ params['overlapDisplayed'] = true;
186
+ }
128
187
 
129
- if (params.cacheEnabled && options.tileversion) {
130
- params['tileversion'] = options.tileversion.toString();
131
- }
132
- if (options.rasterfunction) {
133
- params['rasterfunction'] = JSON.stringify(options.rasterfunction);
134
- }
135
- if (options.chartSetting) {
136
- params["chartSetting"] = JSON.stringify(options.chartSetting);
137
- }
188
+ if (params.cacheEnabled && options.tileversion) {
189
+ params['tileversion'] = options.tileversion.toString();
190
+ }
191
+ if (options.rasterfunction) {
192
+ params['rasterfunction'] = JSON.stringify(options.rasterfunction);
193
+ }
194
+ if (options.displayFilters) {
195
+ params['displayFilters'] = JSON.stringify(options.displayFilters);
196
+ }
197
+ if (options.chartSetting) {
198
+ params['chartSetting'] = JSON.stringify(options.chartSetting);
199
+ }
200
+ const credential = SecurityManager.getCredential(layerUrlPrefix);
201
+ if (credential) {
202
+ params[credential.name] = credential.value;
203
+ }
204
+ return params;
205
+ }
138
206
 
139
- return params;
207
+ /**
208
+ * @function TileSuperMapRest.prototype.getFullRequestUrl
209
+ * @description 获取完整的请求地址。
210
+ */
211
+ function getFullRequestUrl(tileCoord) {
212
+ //非urls的情况,尽可能复用url,减少拼接字符串
213
+ if (this._tileImageUrl) {
214
+ if (this._paramsChanged) {
215
+ this._tileImageWithParamsUrl = createLayerUrl.call(this, this._tileImageUrl);
216
+ this._paramsChanged = false;
217
+ }
218
+ return this._tileImageWithParamsUrl || createLayerUrl.call(this, this._tileImageUrl);
140
219
  }
141
220
 
142
- /**
143
- * @function TileSuperMapRest.prototype.getFullRequestUrl
144
- * @description 获取完整的请求地址。
145
- */
146
- function getFullRequestUrl() {
147
- if (this._paramsChanged) {
148
- this._layerUrl = createLayerUrl.call(this);
149
- this._paramsChanged = false;
150
- }
151
- return this._layerUrl || createLayerUrl.call(this);
221
+ const layerUrlPrefix = CommonUtil.urlPathAppend(
222
+ random(tileCoord, this._urls),
223
+ `tileImage.${this.options.format}`
224
+ );
225
+ if (this._paramsChanged) {
226
+ this._paramsChanged = false;
152
227
  }
228
+ return createLayerUrl.call(this, layerUrlPrefix);
229
+ }
153
230
 
154
- /**
155
- * @function TileSuperMapRest.prototype.createLayerUrl
156
- * @description 获取新建图层地址。
157
- */
158
- function createLayerUrl() {
159
- this.requestParams = this.requestParams || getAllRequestParams.call(this);
160
- this._layerUrl = CommonUtil.urlAppend(layerUrl, CommonUtil.getParameterString(this.requestParams));
161
- //为url添加安全认证信息片段
162
- this._layerUrl = SecurityManager.appendCredential(this._layerUrl);
163
- return this._layerUrl;
231
+ /**
232
+ * @function TileSuperMapRest.prototype.createLayerUrl
233
+ * @description 获取新建图层地址。
234
+ */
235
+ function createLayerUrl(layerUrlPrefix) {
236
+ this.requestParams = this.requestParams || getAllRequestParams.call(this, layerUrlPrefix);
237
+ return CommonUtil.urlAppend(layerUrlPrefix, CommonUtil.getParameterString(this.requestParams));
238
+ }
239
+ /**
240
+ * Copyright 2005-present, OpenLayers Contributors
241
+ */
242
+ function expandUrl(url) {
243
+ const urls = [];
244
+ let match = /\{([a-z])-([a-z])\}/.exec(url);
245
+ if (match) {
246
+ // char range
247
+ const startCharCode = match[1].charCodeAt(0);
248
+ const stopCharCode = match[2].charCodeAt(0);
249
+ let charCode;
250
+ for (charCode = startCharCode; charCode <= stopCharCode; ++charCode) {
251
+ urls.push(url.replace(match[0], String.fromCharCode(charCode)));
252
+ }
253
+ return urls;
164
254
  }
255
+ match = /\{(\d+)-(\d+)\}/.exec(url);
256
+ if (match) {
257
+ // number range
258
+ const stop = parseInt(match[2], 10);
259
+ for (let i = parseInt(match[1], 10); i <= stop; i++) {
260
+ urls.push(url.replace(match[0], i.toString()));
261
+ }
262
+ return urls;
263
+ }
264
+ urls.push(url);
265
+ return urls;
266
+ }
267
+ function random(tileCoord, urls) {
268
+ const a = (tileCoord[1] << tileCoord[0]) + tileCoord[2];
269
+ const b = urls.length;
270
+ const r = a % b;
271
+ return urls[r * b < 0 ? r + b : r];
272
+ }
165
273
 
166
- function tileUrlFunction(tileCoord, pixelRatio, projection) {
167
- if (!me.tileGrid) {
168
- if (options.extent) {
169
- me.tileGrid = TileSuperMapRest.createTileGrid(options.extent);
170
- if (me.resolutions) {
171
- me.tileGrid.resolutions = me.resolutions;
172
- }
173
- } else {
174
- if (projection.getCode() === 'EPSG:3857') {
175
- me.tileGrid = TileSuperMapRest.createTileGrid([
176
- -20037508.3427892,
177
- -20037508.3427892,
178
- 20037508.3427892,
179
- 20037508.3427892
180
- ]);
181
- me.extent = [-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892];
182
- }
183
- if (projection.getCode() === 'EPSG:4326') {
184
- me.tileGrid = TileSuperMapRest.createTileGrid([-180, -90, 180, 90]);
185
- me.extent = [-180, -90, 180, 90];
186
- }
187
- }
274
+ function tileUrlFunction(tileCoord, pixelRatio, projection) {
275
+ if (!me.tileGrid) {
276
+ if (options.extent) {
277
+ me.tileGrid = wrapTileGridWithOverflow(TileSuperMapRest.createTileGrid(options.extent), options.overflowTiles);
278
+ if (me.resolutions) {
279
+ me.tileGrid.resolutions = me.resolutions;
188
280
  }
189
- me.origin = me.tileGrid.getOrigin(0);
190
- var z = tileCoord[0];
191
- var x = tileCoord[1];
192
- var y = ['4', '5'].indexOf(Util.getOlVersion()) > -1 ? -tileCoord[2] - 1 : tileCoord[2];
193
- var resolution = me.tileGrid.getResolution(z);
194
- var dpi = me.dpi || 96;
195
- var unit = projection.getUnits() || Unit.DEGREE;
196
- var scale = Util.resolutionToScale(resolution, dpi, unit);
197
- var tileSize = olSize.toSize(me.tileGrid.getTileSize(z, me.tmpSize));
198
- var layerUrl = getFullRequestUrl.call(me);
199
- var url =
200
- layerUrl +
201
- encodeURI(
202
- '&x=' + x + '&y=' + y + '&width=' + tileSize[0] + '&height=' + tileSize[1] + '&scale=' + scale
203
- );
204
- //支持代理
205
- if (me.tileProxy) {
206
- url = me.tileProxy + encodeURIComponent(url);
281
+ } else {
282
+ if (projection.getCode() === 'EPSG:3857') {
283
+ me.tileGrid = wrapTileGridWithOverflow(
284
+ TileSuperMapRest.createTileGrid([
285
+ -20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892
286
+ ]),
287
+ options.overflowTiles
288
+ );
289
+ me.extent = [-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892];
207
290
  }
208
- if (!me.cacheEnabled) {
209
- url += '&_t=' + new Date().getTime();
291
+ if (projection.getCode() === 'EPSG:4326') {
292
+ me.tileGrid = wrapTileGridWithOverflow(
293
+ TileSuperMapRest.createTileGrid([-180, -90, 180, 90]),
294
+ options.overflowTiles
295
+ );
296
+ me.extent = [-180, -90, 180, 90];
210
297
  }
211
- return url;
298
+ }
299
+ }
300
+ me.origin = me.tileGrid.getOrigin(0);
301
+ var z = tileCoord[0];
302
+ var x = tileCoord[1];
303
+ var y = ['4', '5'].indexOf(Util.getOlVersion()) > -1 ? -tileCoord[2] - 1 : tileCoord[2];
304
+ var resolution = me.tileGrid.getResolution(z);
305
+ var dpi = me.dpi || 96;
306
+ var unit = projection.getUnits() || Unit.DEGREE;
307
+ var scale = Util.resolutionToScale(resolution, dpi, unit);
308
+ var tileSize = olSize.toSize(me.tileGrid.getTileSize(z, me.tmpSize));
309
+ var layerUrl = getFullRequestUrl.call(me, tileCoord);
310
+ var url =
311
+ layerUrl +
312
+ encodeURI('&x=' + x + '&y=' + y + '&width=' + tileSize[0] + '&height=' + tileSize[1] + '&scale=' + scale);
313
+ //支持代理
314
+ if (me.tileProxy) {
315
+ url = me.tileProxy + encodeURIComponent(url);
316
+ }
317
+ if (!me.cacheEnabled) {
318
+ url += '&_t=' + new Date().getTime();
212
319
  }
320
+ return url;
321
+ }
213
322
  }
214
323
 
215
324
  /**
@@ -367,8 +476,12 @@ export class TileSuperMapRest extends TileImage {
367
476
  * @version 11.2.0
368
477
  */
369
478
  updateParams(params) {
370
- Object.assign(this.requestParams, params);
479
+ Object.assign(this.options, params);
480
+ if (this.requestParams) {
481
+ Object.assign(this.requestParams, params);
482
+ }
371
483
  this._paramsChanged = true;
484
+ this.setKey(String(++this._paramsVersion));
372
485
  this.refresh();
373
486
  }
374
487
  }