@supermapgis/iclient-ol 11.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 (91) hide show
  1. package/README.md +56 -0
  2. package/control/ChangeTileVersion.js +438 -0
  3. package/control/Logo.js +99 -0
  4. package/control/ScaleLine.js +164 -0
  5. package/control/index.js +6 -0
  6. package/core/MapExtend.js +49 -0
  7. package/core/StyleUtils.js +1253 -0
  8. package/core/Util.js +478 -0
  9. package/core/index.js +6 -0
  10. package/css/ChangeTileVersion.css +347 -0
  11. package/css/index.js +5 -0
  12. package/dist/iclient-openlayers-es6.js +121806 -0
  13. package/dist/iclient-openlayers-es6.min.js +8 -0
  14. package/dist/iclient-openlayers.css +668 -0
  15. package/dist/iclient-openlayers.js +132335 -0
  16. package/dist/iclient-openlayers.min.css +8 -0
  17. package/dist/iclient-openlayers.min.js +8 -0
  18. package/index.js +9 -0
  19. package/mapping/BaiduMap.js +121 -0
  20. package/mapping/ImageSuperMapRest.js +252 -0
  21. package/mapping/ImageTileSuperMapRest.js +99 -0
  22. package/mapping/InitMap.js +125 -0
  23. package/mapping/SuperMapCloud.js +56 -0
  24. package/mapping/Tianditu.js +152 -0
  25. package/mapping/TileSuperMapRest.js +358 -0
  26. package/mapping/WebMap.js +5185 -0
  27. package/mapping/index.js +11 -0
  28. package/mapping/webmap/Util.js +176 -0
  29. package/mapping/webmap/config/MunicipalCenter.json +1 -0
  30. package/mapping/webmap/config/ProvinceCenter.json +1 -0
  31. package/mapping/webmap/config/SampleDataInfo.json +55 -0
  32. package/namespace.js +150 -0
  33. package/overlay/DataFlow.js +114 -0
  34. package/overlay/FGB.js +97 -0
  35. package/overlay/Graph.js +436 -0
  36. package/overlay/GraphMap.js +91 -0
  37. package/overlay/Graphic.js +587 -0
  38. package/overlay/HeatMap.js +444 -0
  39. package/overlay/Label.js +964 -0
  40. package/overlay/Mapv.js +146 -0
  41. package/overlay/Range.js +127 -0
  42. package/overlay/RankSymbol.js +94 -0
  43. package/overlay/Turf.js +298 -0
  44. package/overlay/Unique.js +123 -0
  45. package/overlay/VectorTileSuperMapRest.js +466 -0
  46. package/overlay/graphic/CanvasRenderer.js +177 -0
  47. package/overlay/graphic/CloverShape.js +133 -0
  48. package/overlay/graphic/Graphic.js +174 -0
  49. package/overlay/graphic/HitCloverShape.js +63 -0
  50. package/overlay/graphic/WebGLRenderer.js +356 -0
  51. package/overlay/graphic/index.js +9 -0
  52. package/overlay/index.js +21 -0
  53. package/overlay/mapv/MapvCanvasLayer.js +104 -0
  54. package/overlay/mapv/MapvLayer.js +410 -0
  55. package/overlay/mapv/index.js +5 -0
  56. package/overlay/theme/GeoFeature.js +275 -0
  57. package/overlay/theme/Theme.js +585 -0
  58. package/overlay/theme/ThemeFeature.js +46 -0
  59. package/overlay/theme/index.js +6 -0
  60. package/overlay/vectortile/DeafultCanvasStyle.js +125 -0
  61. package/overlay/vectortile/MapboxStyles.js +375 -0
  62. package/overlay/vectortile/StyleMap.js +252 -0
  63. package/overlay/vectortile/VectorTileStyles.js +554 -0
  64. package/overlay/vectortile/index.js +7 -0
  65. package/overlay/vectortile/olExtends.js +382 -0
  66. package/package.json +29 -0
  67. package/services/AddressMatchService.js +60 -0
  68. package/services/ChartService.js +74 -0
  69. package/services/DataFlowService.js +118 -0
  70. package/services/DatasetService.js +104 -0
  71. package/services/DatasourceService.js +76 -0
  72. package/services/FeatureService.js +196 -0
  73. package/services/FieldService.js +53 -0
  74. package/services/GeoprocessingService.js +156 -0
  75. package/services/GridCellInfosService.js +53 -0
  76. package/services/ImageCollectionService.js +92 -0
  77. package/services/ImageService.js +69 -0
  78. package/services/KnowledgeGraphService.js +82 -0
  79. package/services/LayerInfoService.js +85 -0
  80. package/services/MapService.js +85 -0
  81. package/services/MeasureService.js +77 -0
  82. package/services/NetworkAnalyst3DService.js +88 -0
  83. package/services/NetworkAnalystService.js +252 -0
  84. package/services/ProcessingService.js +478 -0
  85. package/services/QueryService.js +116 -0
  86. package/services/ServiceBase.js +26 -0
  87. package/services/SpatialAnalystService.js +432 -0
  88. package/services/ThemeService.js +50 -0
  89. package/services/TrafficTransferAnalystService.js +88 -0
  90. package/services/WebPrintingJobService.js +112 -0
  91. package/services/index.js +27 -0
package/overlay/FGB.js ADDED
@@ -0,0 +1,97 @@
1
+ /* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
2
+ * This program are made available under the terms of the Apache License, Version 2.0
3
+ * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4
+ import VectorSource from 'ol/source/Vector';
5
+ import { deserialize } from 'flatgeobuf/lib/mjs/geojson';
6
+ import { FetchRequest } from '@supermapgis/iclient-common/util/FetchRequest';
7
+ import { all, bbox } from 'ol/loadingstrategy';
8
+ import { getIntersection } from '@supermapgis/iclient-common/util/MapCalculateUtil';
9
+ import GeoJSON from 'ol/format/GeoJSON';
10
+ /**
11
+ * @class FGB
12
+ * @browsernamespace ol.source
13
+ * @category Visualization FGB
14
+ * @classdesc FGB 图层源,该图层源把 {@link FlatGeobuf} 格式解析为点线面要素。
15
+ * @modulecategory Overlay
16
+ * @version 11.1.0
17
+ * @param {Object} opt_options - 参数。
18
+ * @param {string} opt_options.url - FGB 地址,例如:http://localhost:8090/iserver/services/xxx/rest/data/featureResults/newResourceId.fgb。
19
+ * @param {ol.loadingstrategy} [opt_options.strategy= ol.loadingstrategy.bbox] - ol.loadingstrategy.all为全量加载,要素会以流的方式渲染到地图。 ol.loadingstrategy.bbox为当前可见范围加载,当地图范围改变时会重新加载要素,此时可以通过idField 参数来标识已被加载过的要素,被标识的要素无需再次加载。idField 参数无效时会清空要素,重新加载。
20
+ * @param {Array} [opt_options.extent] - 加载范围, 参数规范为: [minX, minY, maxX, maxY], 传递此参数后, 图层将使用局部加载。
21
+ * @param {function} [opt_options.featureLoader] - 要素加载回调函数
22
+ * @param {boolean} [opt_options.overlaps] - 是否优化重叠要素的填充与描边操作
23
+ * @param {boolean} [opt_options.useSpatialIndex] - 是否启用要素空间索引
24
+ * @param {boolean} [opt_options.wrapX] - 是否平铺地图
25
+ * @param {boolean} [opt_options.idField='SmID'] - 要素属性中表示唯一标识的字段,当 strategy 为 ol.loadingstrategy.bbox时生效。
26
+ * @extends {ol.source.Vector}
27
+ * @usage
28
+ */
29
+ export class FGB extends VectorSource {
30
+ constructor(options) {
31
+ const baseOptions = Object.assign({ strategy: bbox }, options);
32
+ delete baseOptions.url;
33
+ delete baseOptions.extent;
34
+ delete baseOptions.idField;
35
+ super(baseOptions);
36
+ this.options = options || {};
37
+ this.strategy = baseOptions.strategy;
38
+ this.url = this.options.url;
39
+ this.extent = this.options.extent;
40
+ this._idField = this.options.idField || 'SmID';
41
+ this._validatedId = false;
42
+ this._checked = false;
43
+ this.setLoader(async function (extent) {
44
+ if (this.strategy === bbox) {
45
+ if (!this._validatedId) {
46
+ this.clear();
47
+ }
48
+ if (this.extent) {
49
+ const intersectExtent = getIntersection(this.extent, extent);
50
+ extent = (intersectExtent && intersectExtent.length) ? intersectExtent : this.extent;
51
+ }
52
+ }
53
+ if (!this.extent && (this.strategy === all || !isFinite(extent[0]))) {
54
+ extent = [];
55
+ }
56
+ let fgbStream;
57
+ if (!Object.keys(extent).length) {
58
+ fgbStream = await this._getStream(this.url);
59
+ }
60
+ this._handleFeatures((fgbStream && fgbStream.body) || this.url, extent);
61
+ });
62
+ }
63
+
64
+ async _handleFeatures(url, extent) {
65
+ let rect = {};
66
+ if (extent && extent.length) {
67
+ rect = {
68
+ minX: extent[0],
69
+ minY: extent[1],
70
+ maxX: extent[2],
71
+ maxY: extent[3]
72
+ };
73
+ }
74
+ const fgb = deserialize(url, rect);
75
+ for await (let feature of fgb) {
76
+ let id = feature.properties[this._idField];
77
+ if (id && !this._validatedId) {
78
+ this._validatedId = true;
79
+ this._checked = true;
80
+ }
81
+ feature = new GeoJSON().readFeature(feature);
82
+ if (id && this._checked) {
83
+ feature.setId(id);
84
+ }
85
+ if (this.options.featureLoader && typeof this.options.featureLoader === 'function') {
86
+ feature = this.options.featureLoader(feature);
87
+ }
88
+ this.addFeature(feature);
89
+ }
90
+ }
91
+
92
+ async _getStream(url) {
93
+ return await FetchRequest.get(url, {}, { withoutFormatSuffix: true }).then(function (response) {
94
+ return response;
95
+ });
96
+ }
97
+ }
@@ -0,0 +1,436 @@
1
+ /* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
2
+ * This program are made available under the terms of the Apache License, Version 2.0
3
+ * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4
+ import { Util as CommonUtil} from '@supermapgis/iclient-common/commontypes/Util';
5
+ import { Theme as FeatureTheme } from "@supermapgis/iclient-common/overlay/feature/Theme";
6
+ import { LonLat } from '@supermapgis/iclient-common/commontypes/LonLat';
7
+ import { Bounds } from '@supermapgis/iclient-common/commontypes/Bounds';
8
+ import {
9
+ Theme
10
+ } from './theme/Theme';
11
+
12
+ /**
13
+ * @class Graph
14
+ * @browsernamespace ol.source
15
+ * @category Visualization Theme
16
+ * @classdesc 统计专题图图层基类。
17
+ * @modulecategory Overlay
18
+ * @param {string} chartsType - 图表类别。
19
+ * @param {string} name - 图层名称。
20
+ * @param {Object} opt_options - 参数。
21
+ * @param {ol.Map} opt_options.map - 当前 Map 对象。
22
+ * @param {string} opt_options.chartsType - 图表类型。目前可用:"Bar","Bar3D","Line","Point","Pie","Ring"。
23
+ * @param {Object} opt_options.chartsSetting - 各类型图表的 chartsSetting 对象可设属性请参考具体图表模型类的注释中对 chartsSetting 对象可设属性的描述。chartsSetting 对象通常都具有以下几个基础可设属性。
24
+ * @param {number} opt_options.chartsSetting.width - 专题要素(图表)宽度。
25
+ * @param {number} opt_options.chartsSetting.height - 专题要素(图表)高度。
26
+ * @param {Array.<number>} opt_options.chartsSetting.codomain - 值域,长度为 2 的一维数组,第一个元素表示值域下限,第二个元素表示值域上限。
27
+ * @param {number} [opt_options.chartsSetting.XOffset] - 专题要素(图表)在 X 方向上的偏移值,单位像素。
28
+ * @param {number} [opt_options.chartsSetting.YOffset] - 专题要素(图表)在 Y 方向上的偏移值,单位像素。
29
+ * @param {Array.<number>} [opt_options.chartsSetting.dataViewBoxParameter] - 数据视图框 dataViewBox 参数,它是指图表框 chartBox(由图表位置、图表宽度、图表高度构成的图表范围框)在左、下,右,上四个方向上的内偏距值,长度为 4 的一维数组。
30
+ * @param {number} [opt_options.chartsSetting.decimalNumber] - 数据值数组 dataValues 元素值小数位数,数据的小数位处理参数,取值范围:[0, 16]。如果不设置此参数,在取数据值时不对数据做小数位处理。
31
+ * @param {string} opt_options.themeFields - 指定创建专题图字段。
32
+ * @param {string} [opt_options.id] - 专题图层 ID。默认使用 CommonUtil.createUniqueID("themeLayer_") 创建专题图层 ID。
33
+ * @param {number} [opt_options.opacity = 1] - 图层透明度。
34
+ * @param {string} [opt_options.logo] - Logo(openLayers 5.0.0 及更高版本不再支持此参数)。
35
+ * @param {ol.proj.Projection} [opt_options.projection] - {@link ol.proj.Projection} 投影信息。
36
+ * @param {number} [opt_options.ratio=1.5] - 视图比, 1 表示画布是地图视口的大小,2 表示地图视口的宽度和高度的两倍,依此类推。必须是 1 或更高。
37
+ * @param {Array.<number>} [opt_options.resolutions] - 分辨率数组。
38
+ * @param {boolean} [opt_options.isOverLay=true] - 是否进行压盖处理,如果设为 true,图表绘制过程中将隐藏对已在图层中绘制的图表产生压盖的图表。
39
+ * @param {ol.source.State} [opt_options.state] - 资源状态。
40
+ * @param {(string|Object)} [opt_options.attributions='Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a></span>'] - 版权信息。
41
+ * @extends {Theme}
42
+ * @usage
43
+ */
44
+ export class Graph extends Theme {
45
+
46
+ constructor(name, chartsType, opt_options) {
47
+ super(name, opt_options);
48
+ this.chartsSetting = opt_options.chartsSetting || {};
49
+ this.themeFields = opt_options.themeFields || null;
50
+ this.overlayWeightField = opt_options.overlayWeightField || null;
51
+ this.isOverLay = opt_options.isOverLay === undefined ? true : opt_options.isOverLay;
52
+ this.charts = opt_options.charts || [];
53
+ this.cache = opt_options.cache || {};
54
+ this.chartsType = chartsType;
55
+ }
56
+
57
+ /**
58
+ * @function Graph.prototype.destroy
59
+ * @description 释放资源,将引用资源的属性置空。
60
+ */
61
+ destroy() {
62
+ this.chartsType = null;
63
+ this.chartsSetting = null;
64
+ this.themeFields = null;
65
+ this.overlayWeightField = null;
66
+ this.isOverLay = null;
67
+ Theme.prototype.destroy.apply(this, arguments);
68
+ // charts cache 为缓存,需要在父类destory后置为null(父类destory中有方法会初始化缓存参数)
69
+ this.charts = null;
70
+ this.cache = null;
71
+ }
72
+
73
+ /**
74
+ * @function Graph.prototype.setChartsType
75
+ * @description 设置图表类型,此函数可动态改变图表类型。在调用此函数前请通过 chartsSetting 为新类型的图表做相关配置。
76
+ * @param {string} chartsType - 图表类型。目前可用:"Bar","Bar3D","Line","Point","Pie","Ring"。
77
+ */
78
+ setChartsType(chartsType) {
79
+ this.chartsType = chartsType;
80
+ this.redraw();
81
+ }
82
+
83
+ /**
84
+ * @function Graph.prototype.addFeatures
85
+ * @description 向专题图图层中添加数据。
86
+ * @param {(ServerFeature|ThemeFeature)} features - 待添加的要素。
87
+ */
88
+ addFeatures(features) {
89
+ var ret = this.dispatchEvent({
90
+ type: 'beforefeaturesadded',
91
+ value: {
92
+ features: features
93
+ }
94
+ });
95
+ if (ret === false) {
96
+ return;
97
+ }
98
+ //转换 features 形式
99
+ this.features = this.toiClientFeature(features);
100
+ //绘制专题要素
101
+ if (this.renderer) {
102
+ this.changed();
103
+ }
104
+ }
105
+
106
+ /**
107
+ * @function Graph.prototype.redrawThematicFeatures
108
+ * @description 重绘所有专题要素。
109
+ * 此方法包含绘制专题要素的所有步骤,包含用户数据到专题要素的转换,抽稀,缓存等步骤。
110
+ * 地图漫游时调用此方法进行图层刷新。
111
+ * @param {Object} extent - 重绘的范围。
112
+ *
113
+ */
114
+ redrawThematicFeatures(extent) {
115
+ //清除当前所有可视元素
116
+ this.renderer.clearAll();
117
+ var features = this.features;
118
+ for (var i = 0, len = features.length; i < len; i++) {
119
+ var feature = features[i];
120
+ // 要素范围判断
121
+ var feaBounds = feature.geometry.getBounds();
122
+ //剔除当前视图(地理)范围以外的数据
123
+ if (extent) {
124
+ var bounds = new Bounds(extent[0], extent[1], extent[2], extent[3]);
125
+ if (!bounds.intersectsBounds(feaBounds)) {
126
+ continue;
127
+ }
128
+ }
129
+ var cache = this.cache;
130
+ // 用 feature id 做缓存标识
131
+ var cacheField = feature.id;
132
+ // 数据对应的图表是否已缓存,没缓存则重新创建图表
133
+ if (cache[cacheField]) {
134
+ continue;
135
+ }
136
+ cache[cacheField] = cacheField;
137
+ var chart = this.createThematicFeature(feature);
138
+ // 压盖处理权重值
139
+ if (chart && this.overlayWeightField) {
140
+ if (feature.attributes[this.overlayWeightField] && !isNaN(feature.attributes[this.overlayWeightField])) {
141
+ chart["__overlayWeight"] = feature.attributes[this.overlayWeightField];
142
+ }
143
+ }
144
+ if (chart) {
145
+ this.charts.push(chart);
146
+ }
147
+ }
148
+ this.drawCharts();
149
+ }
150
+
151
+ /**
152
+ * @function Graph.prototype.createThematicFeature
153
+ * @description 向专题图图层中添加数据, 支持的 feature 类型为:iServer 返回的 feature JSON 对象。
154
+ * @param {ServerFeature} feature - 待添加的要素。
155
+ *
156
+ */
157
+ createThematicFeature(feature) {
158
+ var thematicFeature;
159
+ // 检查图表创建条件并创建图形
160
+ if (FeatureTheme[this.chartsType] && this.themeFields && this.chartsSetting) {
161
+ thematicFeature = new FeatureTheme[this.chartsType](feature, this, this.themeFields, this.chartsSetting);
162
+ }
163
+ // thematicFeature 是否创建成功
164
+ if (!thematicFeature) {
165
+ return false;
166
+ }
167
+ // 对专题要素执行图形装载
168
+ thematicFeature.assembleShapes();
169
+ return thematicFeature;
170
+ }
171
+
172
+ /**
173
+ * @function Graph.prototype.drawCharts
174
+ * @description 绘制图表。包含压盖处理。
175
+ *
176
+ */
177
+ drawCharts() {
178
+ // 判断 rendere r就绪
179
+ if (!this.renderer) {
180
+ return;
181
+ }
182
+ var charts = this.charts;
183
+ // 图表权重值处理
184
+ if (this.overlayWeightField) {
185
+ charts.sort(function (cs, ce) {
186
+ if (typeof (cs["__overlayWeight"]) == "undefined" && typeof (ce["__overlayWeight"]) == "undefined") {
187
+ return 0;
188
+ } else if (typeof (cs["__overlayWeight"]) != "undefined" && typeof (ce["__overlayWeight"]) == "undefined") {
189
+ return -1;
190
+ } else if (typeof (cs["__overlayWeight"]) == "undefined" && typeof (ce["__overlayWeight"]) != "undefined") {
191
+ return 1;
192
+ } else if (typeof (cs["__overlayWeight"]) != "undefined" && typeof (ce["__overlayWeight"]) != "undefined") {
193
+ if (parseFloat(cs["__overlayWeight"]) < parseFloat(ce["__overlayWeight"])) {
194
+ return 1;
195
+ } else {
196
+ return -1;
197
+ }
198
+ }
199
+ return 0;
200
+ });
201
+ }
202
+ // 不进行避让
203
+ if (!this.isOverLay) {
204
+ for (var m = 0, len_m = charts.length; m < len_m; m++) {
205
+ var chart_m = charts[m];
206
+ // 图形参考位置 (reSetLocation 会更新 chartBounds)
207
+ var shapeROP_m = chart_m.resetLocation();
208
+ // 添加图形
209
+ var shapes_m = chart_m.shapes;
210
+ for (var n = 0, slen_n = shapes_m.length; n < slen_n; n++) {
211
+ shapes_m[n].refOriginalPosition = shapeROP_m;
212
+ this.renderer.addShape(shapes_m[n]);
213
+ }
214
+ }
215
+ } else {
216
+ // 压盖判断所需 chartsBounds 集合
217
+ var chartsBounds = [];
218
+ var extent = this.map.getView().calculateExtent();
219
+ var mapBounds = new Bounds(extent[0], extent[1], extent[2], extent[3]);
220
+ // 获取地图像素 bounds
221
+ var mapPxLT = this.getLocalXY(new LonLat(mapBounds.left, mapBounds.top));
222
+ var mapPxRB = this.getLocalXY(new LonLat(mapBounds.right, mapBounds.bottom));
223
+ var mBounds = new Bounds(mapPxLT[0], mapPxRB[1], mapPxRB[0], mapPxLT[1]);
224
+ // 压盖处理 & 添加图形
225
+ for (var i = 0, len = charts.length; i < len; i++) {
226
+ var chart = charts[i];
227
+ // 图形参考位置 (reSetLocation 会更新 chartBounds)
228
+ var shapeROP = chart.resetLocation();
229
+ // 图表框
230
+ var cbs = chart.chartBounds;
231
+ var cBounds = [{
232
+ "x": cbs.left,
233
+ "y": cbs.top
234
+ }, {
235
+ "x": cbs.left,
236
+ "y": cbs.bottom
237
+ }, {
238
+ "x": cbs.right,
239
+ "y": cbs.bottom
240
+ }, {
241
+ "x": cbs.right,
242
+ "y": cbs.top
243
+ }, {
244
+ "x": cbs.left,
245
+ "y": cbs.top
246
+ }];
247
+ // 地图范围外不绘制
248
+ if (mBounds) {
249
+ if (!this.isChartInMap(mBounds, cBounds)) {
250
+ continue;
251
+ }
252
+ }
253
+ // 是否压盖
254
+ var isOL = false;
255
+ if (i !== 0) {
256
+ for (let j = 0; j < chartsBounds.length; j++) {
257
+ //压盖判断
258
+ if (this.isQuadrilateralOverLap(cBounds, chartsBounds[j])) {
259
+ isOL = true;
260
+ break;
261
+ }
262
+ }
263
+ }
264
+ if (isOL) {
265
+ continue;
266
+ } else {
267
+ chartsBounds.push(cBounds);
268
+ }
269
+ // 添加图形
270
+ var shapes = chart.shapes;
271
+ for (let j = 0, slen = shapes.length; j < slen; j++) {
272
+ shapes[j].refOriginalPosition = shapeROP;
273
+ this.renderer.addShape(shapes[j]);
274
+ }
275
+ }
276
+ }
277
+ // 绘制图形
278
+ this.renderer.render();
279
+ }
280
+
281
+ /**
282
+ * @function Graph.prototype.getShapesByFeatureID
283
+ * @description 通过 FeatureID 获取 feature 关联的所有图形。如果不传入此参数,函数将返回所有图形。
284
+ * @param {number} featureID - 要素 ID。
285
+ */
286
+ getShapesByFeatureID(featureID) {
287
+ var list = [];
288
+ var shapeList = this.renderer.getAllShapes();
289
+ if (!featureID) {
290
+ return shapeList
291
+ }
292
+ for (var i = 0, len = shapeList.length; i < len; i++) {
293
+ var si = shapeList[i];
294
+ if (si.refDataID && featureID === si.refDataID) {
295
+ list.push(si);
296
+ }
297
+ }
298
+ return list;
299
+ }
300
+
301
+ /**
302
+ * @function Graph.prototype.isQuadrilateralOverLap
303
+ * @description 判断两个四边形是否有压盖。
304
+ * @param {Array.<Object>} quadrilateral - 四边形节点数组。
305
+ * @param {Array.<Object>} quadrilateral2 - 第二个四边形节点数组。
306
+ */
307
+ isQuadrilateralOverLap(quadrilateral, quadrilateral2) {
308
+ var quadLen = quadrilateral.length,
309
+ quad2Len = quadrilateral2.length;
310
+ if (quadLen !== 5 || quad2Len !== 5) {
311
+ return null;
312
+ } //不是四边形
313
+
314
+ var OverLap = false;
315
+ //如果两四边形互不包含对方的节点,则两个四边形不相交
316
+ for (let i = 0; i < quadLen; i++) {
317
+ if (this.isPointInPoly(quadrilateral[i], quadrilateral2)) {
318
+ OverLap = true;
319
+ break;
320
+ }
321
+ }
322
+ for (let i = 0; i < quad2Len; i++) {
323
+ if (this.isPointInPoly(quadrilateral2[i], quadrilateral)) {
324
+ OverLap = true;
325
+ break;
326
+ }
327
+ }
328
+ //加上两矩形十字相交的情况
329
+ for (let i = 0; i < quadLen - 1; i++) {
330
+ if (OverLap) {
331
+ break;
332
+ }
333
+ for (let j = 0; j < quad2Len - 1; j++) {
334
+ var isLineIn = CommonUtil.lineIntersection(quadrilateral[i], quadrilateral[i + 1], quadrilateral2[j], quadrilateral2[j + 1]);
335
+ if (isLineIn.CLASS_NAME === "SuperMap.Geometry.Point") {
336
+ OverLap = true;
337
+ break;
338
+ }
339
+ }
340
+ }
341
+ return OverLap;
342
+ }
343
+
344
+ /**
345
+ * @function Graph.prototype.isPointInPoly
346
+ * @description 判断一个点是否在多边形里面(射线法)。
347
+ * @param {Object} pt - 需要判定的点对象,该对象含有属性 x(横坐标),属性 y(纵坐标)。
348
+ * @param {Array.<Object>} poly - 多边形节点数组。
349
+ */
350
+ isPointInPoly(pt, poly) {
351
+ for (var isIn = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i) {
352
+ ((poly[i].y <= pt.y && pt.y < poly[j].y) || (poly[j].y <= pt.y && pt.y < poly[i].y)) &&
353
+ (pt.x < (poly[j].x - poly[i].x) * (pt.y - poly[i].y) / (poly[j].y - poly[i].y) + poly[i].x) &&
354
+ (isIn = !isIn);
355
+ }
356
+ return isIn;
357
+ }
358
+
359
+ /**
360
+ * @function Graph.prototype.isChartInMap
361
+ * @description 判断图表是否在地图里。
362
+ * @param {Bounds} mapPxBounds - 地图像素范围。
363
+ * @param {Array.<Object>} chartPxBounds - 图表范围的四边形节点数组。
364
+ */
365
+ isChartInMap(mapPxBounds, chartPxBounds) {
366
+ var mb = mapPxBounds;
367
+ var isIn = false;
368
+ for (var i = 0, len = chartPxBounds.length; i < len; i++) {
369
+ var cb = chartPxBounds[i];
370
+
371
+ if (cb.x >= mb.left && cb.x <= mb.right && cb.y >= mb.top && cb.y <= mb.bottom) {
372
+ isIn = true;
373
+ break;
374
+ }
375
+ }
376
+ return isIn;
377
+ }
378
+
379
+ /**
380
+ * @function Graph.prototype.clearCache
381
+ * @description 清除缓存。
382
+ */
383
+ clearCache() {
384
+ this.cache = {};
385
+ this.charts = [];
386
+ }
387
+
388
+ /**
389
+ * @function Graph.prototype.removeFeatures
390
+ * @description 从专题图中删除 feature。这个函数删除所有传递进来的矢量要素。参数中的 features 数组中的每一项,必须是已经添加到当前图层中的 feature。
391
+ * @param {Array.<FeatureVector>|FeatureVector|Function} features - 要删除的要素。
392
+ */
393
+ removeFeatures(features) {
394
+ this.clearCache();
395
+ super.removeFeatures(features);
396
+ }
397
+
398
+ /**
399
+ * @function Graph.prototype.removeAllFeatures
400
+ * @description 移除所有的要素。
401
+ */
402
+ removeAllFeatures() {
403
+ this.clearCache();
404
+ super.removeAllFeatures();
405
+ }
406
+
407
+ /**
408
+ * @function Graph.prototype.redraw
409
+ * @description 重绘该图层。
410
+ */
411
+ redraw() {
412
+ this.clearCache();
413
+ if (this.renderer) {
414
+ this.redrawThematicFeatures(this.map.getView().calculateExtent());
415
+ return true;
416
+ }
417
+ return false
418
+ }
419
+
420
+ /**
421
+ * @function Graph.prototype.clear
422
+ * @description 清除的内容包括数据(features)、专题要素、缓存。
423
+ */
424
+ clear() {
425
+ if (this.renderer) {
426
+ this.renderer.clearAll();
427
+ this.renderer.refresh();
428
+ }
429
+ this.removeAllFeatures();
430
+ this.clearCache();
431
+ }
432
+
433
+ canvasFunctionInternal_(extent, resolution, pixelRatio, size, projection) { // eslint-disable-line no-unused-vars
434
+ return Theme.prototype.canvasFunctionInternal_.apply(this, arguments);
435
+ }
436
+ }
@@ -0,0 +1,91 @@
1
+ /* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
2
+ * This program are made available under the terms of the Apache License, Version 2.0
3
+ * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4
+ import Observable from 'ol/Observable';
5
+ import { KnowledgeGraphService } from '../services/KnowledgeGraphService';
6
+ import { KnowledgeGraph } from '@supermapgis/iclient-common/overlay/KnowledgeGraph';
7
+ import { transformExpandCollapseHiddenData } from '@supermapgis/iclient-common/overlay/knowledge-graph/format';
8
+
9
+ /**
10
+ * @class GraphMap
11
+ * @classdesc 对接 iServer GraphMap。
12
+ * @category iServer KnowledgeGraph
13
+ * @version 11.1.0
14
+ * @param {string} serviceUrl - GraphMap服务地址, 例如:http://{iserver}/services/{knowledgeGraph-provider}/restjsr/graph/graphmaps/{graphmap}。
15
+ * @param {Object} [options] - 参数。
16
+ * @param {KnowledgeGraph.Config} [options.config] - KnowledgeGraph的配置项。
17
+ * @param {string} [options.proxy] - 服务代理地址。
18
+ * @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
19
+ * @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
20
+ * @param {Object} [options.headers] - 请求头。
21
+ * @fires GraphMap#loaded
22
+ * @extends {ol.Observable}
23
+ * @usage
24
+ */
25
+ export class GraphMap extends Observable {
26
+ constructor(serviceUrl, options) {
27
+ super();
28
+ /**
29
+ * @member GraphMap.prototype.graph
30
+ * @description KnowledgeGraph的实例.
31
+ *
32
+ */
33
+ this.graph = null;
34
+ /**
35
+ * @member GraphMap.prototype.EVENT_TYPES
36
+ * @description 监听一个自定义事件可用如下方式:
37
+ *
38
+ * 支持的事件如下:
39
+ * loaded - 渲染完成时触发。
40
+ */
41
+ this.EVENT_TYPES = ['loaded'];
42
+ this.url = serviceUrl;
43
+ this.options = options;
44
+ const graphMapName = serviceUrl.split('/').pop();
45
+ this.url = serviceUrl.replace(`/graphmaps/${graphMapName}`, '');
46
+ this.createGraphMap(graphMapName, options);
47
+ }
48
+
49
+ /**
50
+ * @private
51
+ * @function GraphMap.prototype.createGraphMap
52
+ * @description 创建图谱。
53
+ * @param {string} graphMapName - 图谱名称。
54
+ * @param {Object} options - 参数。
55
+ * @param {string} [options.proxy] - 服务代理地址。
56
+ * @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
57
+ * @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
58
+ * @param {Object} [options.headers] - 请求头。
59
+ * @param {KnowledgeGraph.Config} [options.config] - knowledgegrah配置项。
60
+ */
61
+ async createGraphMap(graphMapName, options) {
62
+ this.knowledgeGraphService = this.createKnowledgeGraphService(this.url, options);
63
+ const res = await this.knowledgeGraphService.getGraphMapData(graphMapName);
64
+ const result = KnowledgeGraph.dataFromGraphMap(res.data, res.graphMap);
65
+ this.graph = new KnowledgeGraph(options && options.config);
66
+ this.graph.on('afterlayout', () => {
67
+ /**
68
+ * @event GraphMap#loaded
69
+ * @description 渲染完成时触发。
70
+ */
71
+ this.dispatchEvent(this.EVENT_TYPES[0]);
72
+ });
73
+ this.graph.setData(result);
74
+ this.graph.handleNodeStatus(transformExpandCollapseHiddenData(res.graphMap));
75
+ }
76
+
77
+ /**
78
+ * @private
79
+ * @function GraphMap.prototype.createKnowledgeGraphService
80
+ * @description 创建KnowledgeGraphService实例。
81
+ * @param {string} serviceUrl - GraphMap服务地址, 例如:http://{iserver}/services/knowledgeGraph-test/restjsr/graph
82
+ * @param {Object} options - 参数。
83
+ * @param {string} [options.proxy] - 服务代理地址。
84
+ * @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
85
+ * @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
86
+ * @param {Object} [options.headers] - 请求头。
87
+ */
88
+ createKnowledgeGraphService(serviceUrl, options) {
89
+ return new KnowledgeGraphService(serviceUrl, options);
90
+ }
91
+ }