@supermapgis/iclient-ol 11.2.0

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 +97 -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 +500 -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 +124963 -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 +142946 -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 +150 -0
  23. package/mapping/SuperMapCloud.js +56 -0
  24. package/mapping/Tianditu.js +152 -0
  25. package/mapping/TileSuperMapRest.js +374 -0
  26. package/mapping/WebMap.js +5485 -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 +100 -0
  35. package/overlay/Graph.js +439 -0
  36. package/overlay/GraphMap.js +140 -0
  37. package/overlay/Graphic.js +588 -0
  38. package/overlay/HeatMap.js +450 -0
  39. package/overlay/Label.js +966 -0
  40. package/overlay/Mapv.js +149 -0
  41. package/overlay/Range.js +129 -0
  42. package/overlay/RankSymbol.js +94 -0
  43. package/overlay/Turf.js +299 -0
  44. package/overlay/Unique.js +124 -0
  45. package/overlay/VectorTileSuperMapRest.js +501 -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 +64 -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 +413 -0
  55. package/overlay/mapv/index.js +5 -0
  56. package/overlay/theme/GeoFeature.js +275 -0
  57. package/overlay/theme/Theme.js +587 -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 +377 -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 +30 -0
  67. package/services/AddressMatchService.js +60 -0
  68. package/services/ChartService.js +97 -0
  69. package/services/DataFlowService.js +119 -0
  70. package/services/DatasetService.js +104 -0
  71. package/services/DatasourceService.js +76 -0
  72. package/services/FeatureService.js +260 -0
  73. package/services/FieldService.js +53 -0
  74. package/services/GeoprocessingService.js +157 -0
  75. package/services/GridCellInfosService.js +53 -0
  76. package/services/ImageCollectionService.js +93 -0
  77. package/services/ImageService.js +70 -0
  78. package/services/KnowledgeGraphService.js +96 -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 +93 -0
  83. package/services/NetworkAnalystService.js +268 -0
  84. package/services/ProcessingService.js +507 -0
  85. package/services/QueryService.js +116 -0
  86. package/services/ServiceBase.js +26 -0
  87. package/services/SpatialAnalystService.js +466 -0
  88. package/services/ThemeService.js +50 -0
  89. package/services/TrafficTransferAnalystService.js +93 -0
  90. package/services/WebPrintingJobService.js +112 -0
  91. package/services/index.js +27 -0
@@ -0,0 +1,119 @@
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 {ServiceBase} from './ServiceBase';
5
+ import { DataFlowService as DataFlow } from '@supermapgis/iclient-common/iServer/DataFlowService';
6
+
7
+ /**
8
+ * @class DataFlowService
9
+ * @category iServer DataFlow
10
+ * @classdesc 数据流服务类。用于实现客户端与服务器之间实现低延迟和实时数据传输。数据流服务采用 WebSocket 协议,支持全双工、双向式通信。
11
+ * 服务器可将流数据服务的分析处理结果作为数据来源向客户端广播,客户端与数据流服务建立连接后,即可自动接收服务器广播的数据。
12
+ * @modulecategory Services
13
+ * @extends {ServiceBase}
14
+ * @example
15
+ * new DataFlowService(url).queryChart(param,function(result){
16
+ * //doSomething
17
+ * })
18
+ * @param {string} url - 服务地址。
19
+ * @param {Object} options - 参数。
20
+ * @param {string} [options.proxy] - 服务代理地址。
21
+ * @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
22
+ * @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
23
+ * @param {Object} [options.headers] - 请求头。
24
+ * @param {GeoJSONObject} [options.geometry] - 指定几何范围,只有在该范围内的要素才能被订阅。
25
+ * @param {Object} [options.excludeField] - 排除字段。
26
+ * @usage
27
+ */
28
+ export class DataFlowService extends ServiceBase {
29
+
30
+ constructor(url, options) {
31
+ options = options || {};
32
+ if (options.projection) {
33
+ options.prjCoordSys = options.projection;
34
+ }
35
+ super(url, options);
36
+ this.dataFlow = new DataFlow(url, options);
37
+ this.dataFlow.events.on({
38
+ "broadcastSocketConnected": this._defaultEvent,
39
+ "broadcastSocketError": this._defaultEvent,
40
+ "broadcastFailed": this._defaultEvent,
41
+ "broadcastSucceeded": this._defaultEvent,
42
+ "subscribeSocketConnected": this._defaultEvent,
43
+ "subscribeSocketError": this._defaultEvent,
44
+ "messageSucceeded": this._defaultEvent,
45
+ "setFilterParamSucceeded": this._defaultEvent,
46
+ scope: this
47
+ });
48
+ }
49
+
50
+ /**
51
+ * @function DataFlowService.prototype.initBroadcast
52
+ * @description 初始化广播。
53
+ * @returns {DataFlowService} - 数据流服务。
54
+ */
55
+ initBroadcast() {
56
+ this.dataFlow.initBroadcast();
57
+ return this;
58
+ }
59
+
60
+ /**
61
+ * @function DataFlowService.prototype.broadcast
62
+ * @description 加载广播数据。
63
+ * @param {JSONObject} obj - JSON 格式的要素数据。
64
+ */
65
+ broadcast(obj) {
66
+ this.dataFlow.broadcast(obj);
67
+ }
68
+
69
+ /**
70
+ * @function DataFlowService.prototype.initSubscribe
71
+ * @description 初始化订阅数据。
72
+ */
73
+ initSubscribe() {
74
+ this.dataFlow.initSubscribe();
75
+ return this;
76
+ }
77
+
78
+ /**
79
+ * @function DataFlowService.prototype.setExcludeField
80
+ * @description 设置排除字段。
81
+ * @param {Object} excludeField - 排除字段。
82
+ */
83
+ setExcludeField(excludeField) {
84
+ this.dataFlow.setExcludeField(excludeField);
85
+ this.options.excludeField = excludeField;
86
+ return this;
87
+ }
88
+
89
+ /**
90
+ * @function DataFlowService.prototype.setGeometry
91
+ * @description 设置添加的几何要素数据。
92
+ * @param {GeoJSONObject} geometry - 指定几何范围,只有在该范围内的要素才能被订阅。
93
+ */
94
+ setGeometry(geometry) {
95
+ this.dataFlow.setGeometry(geometry);
96
+ this.options.geometry = geometry;
97
+ return this;
98
+ }
99
+
100
+ /**
101
+ * @function DataFlowService.prototype.unSubscribe
102
+ * @description 结束订阅数据。
103
+ */
104
+ unSubscribe() {
105
+ this.dataFlow.unSubscribe();
106
+ }
107
+
108
+ /**
109
+ * @function DataFlowService.prototype.unBroadcast
110
+ * @description 结束加载广播。
111
+ */
112
+ unBroadcast() {
113
+ this.dataFlow.unBroadcast();
114
+ }
115
+
116
+ _defaultEvent(e) {
117
+ this.dispatchEvent({type: e.eventType || e.type, value: e});
118
+ }
119
+ }
@@ -0,0 +1,104 @@
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 { ServiceBase } from './ServiceBase';
5
+ import { DatasetService as CommonDatasetService } from '@supermapgis/iclient-common/iServer/DatasetService';
6
+ import { CreateDatasetParameters } from '@supermapgis/iclient-common/iServer/CreateDatasetParameters';
7
+ import { UpdateDatasetParameters } from '@supermapgis/iclient-common/iServer/UpdateDatasetParameters';
8
+
9
+ /**
10
+ * @class DatasetService
11
+ * @category iServer Data Dataset
12
+ * @classdesc 数据集信息服务类。提供方法:查询数据集集合、查询指定数据集信息,在指定数据源下新增、修改、删除数据集等。
13
+ * @modulecategory Services
14
+ * @param {string} url - 服务地址。
15
+ * @param {Object} options - 参数。
16
+ * @param {string} [options.proxy] - 服务代理地址。
17
+ * @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
18
+ * @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
19
+ * @param {Object} [options.headers] - 请求头。
20
+ * @extends {ServiceBase}
21
+ * @usage
22
+ */
23
+ export class DatasetService extends ServiceBase {
24
+
25
+ constructor(url, options) {
26
+ super(url, options);
27
+ this._datasetService = new CommonDatasetService(this.url, {
28
+ proxy: this.options.proxy,
29
+ withCredentials: this.options.withCredentials,
30
+ crossOrigin: this.options.crossOrigin,
31
+ headers: this.options.headers
32
+ });
33
+ }
34
+
35
+ /**
36
+ * @function DatasetService.prototype.getDatasets
37
+ * @description 数据集查询服务。
38
+ * @param {string} datasourceName - 数据源名称。
39
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
40
+ * @returns {Promise} Promise 对象。
41
+ */
42
+ getDatasets(datasourceName, callback) {
43
+ if (!datasourceName) {
44
+ return;
45
+ }
46
+ return this._datasetService.getDatasetsService(datasourceName, callback);
47
+ }
48
+
49
+ /**
50
+ * @function DatasetService.prototype.getDataset
51
+ * @description 数据集查询服务。
52
+ * @param {string} datasourceName - 数据源名称。
53
+ * @param {string} datasetName - 数据集名称。
54
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
55
+ * @returns {Promise} Promise 对象。
56
+ */
57
+ getDataset(datasourceName, datasetName, callback) {
58
+ if (!datasourceName || !datasetName) {
59
+ return;
60
+ }
61
+ return this._datasetService.getDatasetService(datasourceName, datasetName, callback);
62
+ }
63
+
64
+ /**
65
+ * @function DatasetService.prototype.setDataset
66
+ * @description 数据集信息设置服务。可实现修改已存在数据集,新增不存在数据集。
67
+ * @param {CreateDatasetParameters | UpdateDatasetParameters } params - 数据集创建参数类或数据集信息更改参数类。
68
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
69
+ * @returns {Promise} Promise 对象。
70
+ */
71
+ setDataset(params, callback) {
72
+ if(!(params instanceof CreateDatasetParameters) && !(params instanceof UpdateDatasetParameters)){
73
+ return;
74
+ }else if (params instanceof CreateDatasetParameters) {
75
+ var datasetParams = {
76
+ "datasetType": params.datasetType,
77
+ "datasetName": params.datasetName,
78
+ "datasourceName": params.datasourceName
79
+ }
80
+ }else if(params instanceof UpdateDatasetParameters){
81
+ datasetParams = {
82
+ "datasetName": params.datasetName,
83
+ "datasourceName": params.datasourceName,
84
+ "isFileCache": params.isFileCache,
85
+ "description": params.description,
86
+ "prjCoordSys": params.prjCoordSys,
87
+ "charset": params.charset
88
+ }
89
+ }
90
+ return this._datasetService.setDatasetService(datasetParams, callback);
91
+ }
92
+
93
+ /**
94
+ * @function DatasetService.prototype.deleteDataset
95
+ * @description 指定数据源下的数据集删除服务。
96
+ * @param {string} datasourceName - 数据源名称。
97
+ * @param {string} datasetName - 数据集名称。
98
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
99
+ * @returns {Promise} Promise 对象。
100
+ */
101
+ deleteDataset(datasourceName, datasetName, callback) {
102
+ return this._datasetService.deleteDatasetService(datasourceName, datasetName, callback);
103
+ }
104
+ }
@@ -0,0 +1,76 @@
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 {ServiceBase} from './ServiceBase';
5
+ import {DatasourceService as CommonDatasourceService} from '@supermapgis/iclient-common/iServer/DatasourceService';
6
+ import { SetDatasourceParameters } from '@supermapgis/iclient-common/iServer/SetDatasourceParameters';
7
+
8
+ /**
9
+ * @class DatasourceService
10
+ * @category iServer Data Datasource
11
+ * @classdesc 数据源服务类。提供方法:查询数据源集合、查询指定数据源信息、设置指定数据源信息。可以获取的数据源信息包括数据源名称、数据源描述、引擎类型、距离单位、坐标单位、投影信息等。
12
+ * @modulecategory Services
13
+ * @param {string} url - 服务地址。
14
+ * @param {Object} options - 参数。
15
+ * @param {string} [options.proxy] - 服务代理地址。
16
+ * @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
17
+ * @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
18
+ * @param {Object} [options.headers] - 请求头。
19
+ * @extends {ServiceBase}
20
+ * @usage
21
+ */
22
+ export class DatasourceService extends ServiceBase {
23
+
24
+ constructor(url, options) {
25
+ super(url, options);
26
+ this._datasourceService = new CommonDatasourceService(this.url, {
27
+ proxy: this.proxy,
28
+ withCredentials: this.withCredentials,
29
+ crossOrigin: this.crossOrigin,
30
+ headers: this.headers
31
+ });
32
+ }
33
+
34
+ /**
35
+ * @function DatasourceService.prototype.getDatasources
36
+ * @description 数据源集合查询服务。
37
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
38
+ */
39
+ getDatasources(callback) {
40
+ return this._datasourceService.getDatasourcesService(callback);
41
+ }
42
+
43
+ /**
44
+ * @function DatasourceService.prototype.getDatasource
45
+ * @description 数据源信息查询服务。
46
+ * @param {string} datasourceName - 数据源名称。
47
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
48
+ * @returns {Promise} Promise 对象。
49
+ */
50
+ getDatasource(datasourceName, callback) {
51
+ if (!datasourceName) {
52
+ return;
53
+ }
54
+ return this._datasourceService.getDatasourceService(datasourceName, callback);
55
+ }
56
+
57
+ /**
58
+ * @function DatasourceService.prototype.setDatasource
59
+ * @description 数据源信息设置服务。可实现更改当前数据源信息。
60
+ * @param {SetDatasourceParameters} params - 数据源信息设置参数类。
61
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
62
+ * @returns {Promise} Promise 对象。
63
+ */
64
+ setDatasource(params, callback) {
65
+ if (!(params instanceof SetDatasourceParameters)) {
66
+ return;
67
+ }
68
+ const datasourceParams = {
69
+ description: params.description,
70
+ coordUnit: params.coordUnit,
71
+ distanceUnit: params.distanceUnit,
72
+ datasourceName: params.datasourceName
73
+ };
74
+ return this._datasourceService.setDatasourceService(datasourceParams, callback);
75
+ }
76
+ }
@@ -0,0 +1,260 @@
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 { DataFormat } from '@supermapgis/iclient-common/REST';
6
+ import { EditFeaturesService } from '@supermapgis/iclient-common/iServer/EditFeaturesService';
7
+ import { FeatureService as CommonFeatureService } from '@supermapgis/iclient-common/iServer/FeatureService';
8
+ import { Util } from '../core/Util';
9
+ import { ServiceBase } from './ServiceBase';
10
+ import GeoJSON from 'ol/format/GeoJSON';
11
+ import Geometry from 'ol/geom/Geometry';
12
+ import Polygon from 'ol/geom/Polygon';
13
+
14
+ /**
15
+ * @class FeatureService
16
+ * @constructs FeatureService
17
+ * @category iServer Data Feature
18
+ * @classdesc 要素数据集类。提供:ID 查询,范围查询,SQL查询,几何查询,缓冲区查询,地物编辑,要素附件查询、编辑等方法。
19
+ * @modulecategory Services
20
+ * @example
21
+ * new FeatureService(url).getFeaturesByIDs(param,function(result){
22
+ * //doSomething
23
+ * })
24
+ * @param {string} url - 服务地址。
25
+ * @param {Object} options - 参数。
26
+ * @param {string} [options.proxy] - 服务代理地址。
27
+ * @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
28
+ * @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
29
+ * @param {Object} [options.headers] - 请求头。
30
+ * @extends {ServiceBase}
31
+ * @usage
32
+ */
33
+ export class FeatureService extends ServiceBase {
34
+ constructor(url, options) {
35
+ super(url, options);
36
+ this._featureService = new CommonFeatureService(url, options);
37
+ }
38
+
39
+ /**
40
+ * @function FeatureService.prototype.getFeaturesByIDs
41
+ * @description 数据集 ID 查询服务。
42
+ * @param {GetFeaturesByIDsParameters} params - ID 查询参数类。
43
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
44
+ * @param {DataFormat} [resultFormat=DataFormat.GEOJSON] - 返回的数据格式。
45
+ * @returns {Promise} Promise 对象。
46
+ */
47
+ getFeaturesByIDs(params, callback, resultFormat) {
48
+ params = this._processParams(params);
49
+ return this._featureService.getFeaturesByIDs(params, callback, resultFormat);
50
+ }
51
+
52
+ /**
53
+ * @function FeatureService.prototype.getFeaturesByBounds
54
+ * @description 数据集范围查询服务。
55
+ * @param {GetFeaturesByBoundsParameters} params - 数据集范围查询参数类。
56
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
57
+ * @param {DataFormat} [resultFormat=DataFormat.GEOJSON] - 返回的数据格式。
58
+ * @returns {Promise} Promise 对象。
59
+ */
60
+ getFeaturesByBounds(params, callback, resultFormat) {
61
+ params = this._processParams(params);
62
+ return this._featureService.getFeaturesByBounds(params, callback, resultFormat);
63
+ }
64
+
65
+ /**
66
+ * @function FeatureService.prototype.getFeaturesByBuffer
67
+ * @description 数据集缓冲区查询服务。
68
+ * @param {GetFeaturesByBufferParameters} params - 数据集缓冲区查询参数类。
69
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
70
+ * @param {DataFormat} [resultFormat=DataFormat.GEOJSON] - 返回的数据格式。
71
+ * @returns {Promise} Promise 对象。
72
+ */
73
+ getFeaturesByBuffer(params, callback, resultFormat) {
74
+ params = this._processParams(params);
75
+ return this._featureService.getFeaturesByBuffer(params, callback, resultFormat);
76
+ }
77
+
78
+ /**
79
+ * @function FeatureService.prototype.getFeaturesBySQL
80
+ * @description 数据集 SQL 查询服务。
81
+ * @param {GetFeaturesBySQLParameters} params - 数据集 SQL 查询参数类。
82
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
83
+ * @param {DataFormat} [resultFormat=DataFormat.GEOJSON] - 返回的数据格式。
84
+ * @returns {Promise} Promise 对象。
85
+ */
86
+ getFeaturesBySQL(params, callback, resultFormat) {
87
+ params = this._processParams(params);
88
+ return this._featureService.getFeaturesBySQL(params, callback, resultFormat);
89
+ }
90
+
91
+ /**
92
+ * @function FeatureService.prototype.getFeaturesByGeometry
93
+ * @description 数据集几何查询服务类。
94
+ * @param {GetFeaturesByGeometryParameters} params - 数据集几何查询参数类。
95
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
96
+ * @param {DataFormat} [resultFormat=DataFormat.GEOJSON] - 返回的数据格式。
97
+ * @returns {Promise} Promise 对象。
98
+ */
99
+ getFeaturesByGeometry(params, callback, resultFormat) {
100
+ params = this._processParams(params);
101
+ return this._featureService.getFeaturesByGeometry(params, callback, resultFormat);
102
+ }
103
+
104
+ /**
105
+ * @function FeatureService.prototype.editFeatures
106
+ * @description 地物编辑服务。
107
+ * @param {EditFeaturesParameters} params - 数据服务中数据集添加、修改、删除参数类。
108
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
109
+ * @returns {Promise} Promise 对象。
110
+ */
111
+ editFeatures(params, callback) {
112
+ if (!params || !params.dataSourceName || !params.dataSetName) {
113
+ return;
114
+ }
115
+ var me = this,
116
+ url = me.url,
117
+ dataSourceName = params.dataSourceName,
118
+ dataSetName = params.dataSetName;
119
+ url = CommonUtil.urlPathAppend(url, 'datasources/' + dataSourceName + '/datasets/' + dataSetName);
120
+
121
+ var editFeatureService = new EditFeaturesService(url, {
122
+ proxy: me.options.proxy,
123
+ withCredentials: me.options.withCredentials,
124
+ crossOrigin: me.options.crossOrigin,
125
+ headers: me.options.headers
126
+ });
127
+ return editFeatureService.processAsync(me._processParams(params), callback);
128
+ }
129
+
130
+ /**
131
+ * @function FeatureService.prototype.getMetadata
132
+ * @description 地理要素元信息。
133
+ * @version 11.1.1
134
+ * @param {Object} params - 包括数据源名称、数据集名称、要素 ID。
135
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
136
+ * @returns {Promise} Promise 对象。
137
+ */
138
+ getMetadata(params, callback) {
139
+ return this._featureService.getMetadata(params, callback);
140
+ }
141
+
142
+ /**
143
+ * @function FeatureService.prototype.getFeatureAttachments
144
+ * @description 要素附件查询服务。
145
+ * @version 11.2.0
146
+ * @param {AttachmentsParameters} params - 要素附件服务中附件查询参数类。
147
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
148
+ * @returns {Promise} Promise 对象。
149
+ */
150
+ getFeatureAttachments(params, callback) {
151
+ return this._featureService.getFeatureAttachments(params, callback);
152
+ }
153
+
154
+ /**
155
+ * @function FeatureService.prototype.editFeatureAttachments
156
+ * @description 要素附件编辑服务。
157
+ * @version 11.2.0
158
+ * @param {EditAttachmentsParameters} params - 要素附件服务中附件添加、删除参数类。
159
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
160
+ * @returns {Promise} Promise 对象。
161
+ */
162
+ editFeatureAttachments(params, callback) {
163
+ return this._featureService.editFeatureAttachments(params, callback);
164
+ }
165
+
166
+ /**
167
+ * @function FeatureService.prototype.getFeaturesCount
168
+ * @description 获取要素数量。
169
+ * @version 11.2.0
170
+ * @param {GetFeaturesByIDsParameters|GetFeaturesByBoundsParameters|GetFeaturesByBufferParameters|GetFeaturesByGeometryParameters|GetFeaturesBySQLParameters} params - 查询参数类。
171
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
172
+ * @returns {Promise} Promise 对象。
173
+ */
174
+ getFeaturesCount(params, callback) {
175
+ params = this._processParams(params);
176
+ return this._featureService.getFeaturesCount(params, callback);
177
+ }
178
+
179
+ /**
180
+ * @function FeatureService.prototype.getFeaturesDatasetInfo
181
+ * @description 获取要素数据集信息。
182
+ * @version 11.2.0
183
+ * @param {GetFeaturesByIDsParameters|GetFeaturesByBoundsParameters|GetFeaturesByBufferParameters|GetFeaturesByGeometryParameters|GetFeaturesBySQLParameters} params - 查询参数类。
184
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
185
+ * @returns {Promise} Promise 对象。
186
+ */
187
+ getFeaturesDatasetInfo(params, callback) {
188
+ params = this._processParams(params);
189
+ return this._featureService.getFeaturesDatasetInfo(params, callback);
190
+ }
191
+
192
+ _processParams(params) {
193
+ if (!params) {
194
+ return {};
195
+ }
196
+ var me = this;
197
+ params.returnContent = params.returnContent == null ? true : params.returnContent;
198
+ params.fromIndex = params.fromIndex ? params.fromIndex : 0;
199
+ params.toIndex = params.toIndex ? params.toIndex : -1;
200
+ if (params.bounds) {
201
+ params.bounds = Util.toSuperMapBounds(params.bounds);
202
+ }
203
+ if (params.geometry && params.geometry instanceof Geometry) {
204
+ params.geometry = Util.toSuperMapGeometry(JSON.parse(new GeoJSON().writeGeometry(params.geometry)));
205
+ }
206
+ if (params.editType) {
207
+ params.editType = params.editType.toLowerCase();
208
+ }
209
+ if (params.features) {
210
+ var features = [];
211
+ if (Util.isArray(params.features)) {
212
+ params.features.map(function (feature) {
213
+ features.push(me._createServerFeature(feature));
214
+ return feature;
215
+ });
216
+ } else {
217
+ features.push(me._createServerFeature(params.features));
218
+ }
219
+ params.features = features;
220
+ }
221
+ return params;
222
+ }
223
+
224
+ _createServerFeature(geoFeature) {
225
+ var feature = {},
226
+ fieldNames = [],
227
+ fieldValues = [];
228
+ if(geoFeature.toServerFeature){
229
+ return geoFeature.toServerFeature({geometryFunction:(geometry)=>{
230
+ if(Array.isArray(geometry) && geometry.length === 4){
231
+ const polygon = new Polygon([[[geometry[0], geometry[1]], [geometry[2], geometry[1]], [geometry[2], geometry[3]], [geometry[0], geometry[3]]]]);
232
+ return Util.toSuperMapGeometry(new GeoJSON().writeGeometryObject(polygon));
233
+ }
234
+ if(geometry.getExtent){
235
+ return Util.toSuperMapGeometry(new GeoJSON().writeGeometryObject(geometry));
236
+ }
237
+ return Util.toSuperMapGeometry(geometry);
238
+ }})
239
+ }
240
+ var properties = geoFeature.getProperties();
241
+ for (var key in properties) {
242
+ if (key === geoFeature.getGeometryName()) {
243
+ continue;
244
+ }
245
+ fieldNames.push(key);
246
+ fieldValues.push(properties[key]);
247
+ }
248
+ feature.fieldNames = fieldNames;
249
+ feature.fieldValues = fieldValues;
250
+ if (geoFeature.getId()) {
251
+ feature.id = geoFeature.getId();
252
+ }
253
+ feature.geometry = Util.toSuperMapGeometry(new GeoJSON().writeFeatureObject(geoFeature));
254
+ return feature;
255
+ }
256
+
257
+ _processFormat(resultFormat) {
258
+ return resultFormat ? resultFormat : DataFormat.GEOJSON;
259
+ }
260
+ }
@@ -0,0 +1,53 @@
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 {ServiceBase} from './ServiceBase';
5
+ import { FieldService as CommonFieldService } from '@supermapgis/iclient-common/iServer/FieldService';
6
+
7
+ /**
8
+ * @class FieldService
9
+ * @category iServer Data Field
10
+ * @classdesc 字段服务类。提供方法:查询字段信息、查询字段统计信息等。
11
+ * @example
12
+ * new FieldService(url).getFields(function(result){
13
+ * //doSomething
14
+ * });
15
+ * @modulecategory Services
16
+ * @param {string} url - 服务地址。
17
+ * @param {Object} options - 参数。
18
+ * @param {string} [options.proxy] - 服务代理地址。
19
+ * @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
20
+ * @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
21
+ * @param {Object} [options.headers] - 请求头。
22
+ * @extends {ServiceBase}
23
+ * @usage
24
+ */
25
+ export class FieldService extends ServiceBase {
26
+
27
+ constructor(url, options) {
28
+ super(url, options);
29
+ this._fieldService = new CommonFieldService(url, options);
30
+ }
31
+
32
+ /**
33
+ * @function FieldService.prototype.getFields
34
+ * @description 字段查询服务。
35
+ * @param {FieldParameters} params - 字段信息查询参数类。
36
+ * @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
37
+ * @returns {Promise} Promise 对象。
38
+ */
39
+ getFields(params, callback) {
40
+ return this._fieldService.getFields(params, callback);
41
+ }
42
+
43
+ /**
44
+ * @function FieldService.prototype.getFieldStatisticsInfo
45
+ * @description 字段统计服务。
46
+ * @param {FieldStatisticsParameters} params - 字段统计信息查询参数类。
47
+ * @param {RequestCallback} callback - 回调函数。
48
+ * @returns {Promise} Promise 对象。
49
+ */
50
+ getFieldStatisticsInfo(params, callback) {
51
+ return this._fieldService.getFieldStatisticsInfo(params, callback);
52
+ }
53
+ }