Skip to content

Commit c9f9c01

Browse files
committed
【feature】新增地理处理服务 review by songym commit by luozejin
1 parent 632331a commit c9f9c01

File tree

19 files changed

+2503
-0
lines changed

19 files changed

+2503
-0
lines changed

build/jsdocs/template/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@
274274
"WebPrintingJob": {
275275
"name": "地图打印",
276276
"name_en": "WebPrintingJob"
277+
},
278+
"GeoprocessingService": {
279+
"name": "地理处理服务接口",
280+
"name_en": "GeoprocessingService"
277281
}
278282
}
279283
},
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
import { SuperMap } from '../SuperMap';
2+
import { CommonServiceBase } from './CommonServiceBase';
3+
4+
/**
5+
* @class SuperMap.GeoprocessingService
6+
* @category iServer GeoprocessingService
7+
* @classdesc 地理处理服务接口的基类。
8+
* @version 10.1.0
9+
* @extends {SuperMap.CommonServiceBase}
10+
* @param {string} url - 服务地址。
11+
* @param {Object} options - 参数。
12+
* @param {SuperMap.Events} options.events - 处理所有事件的对象。
13+
* @param {SuperMap.ServerType} [options.serverType=SuperMap.ServerType.ISERVER] - 服务器类型,iServer|iPortal|Online。
14+
* @param {Object} [options.eventListeners] - 事件监听器对象。有 processCompleted 属性可传入处理完成后的回调函数。processFailed 属性传入处理失败后的回调函数。
15+
*/
16+
export class GeoprocessingService extends CommonServiceBase {
17+
constructor(url, options) {
18+
options = options || {};
19+
options.EVENT_TYPES = ['processCompleted', 'processFailed', 'processRunning'];
20+
super(url, options);
21+
this.CLASS_NAME = 'SuperMap.GeoprocessingService';
22+
this.headers = {};
23+
this.crossOrigin = true;
24+
}
25+
/**
26+
* @function SuperMap.GeoprocessingService.prototype.getTools
27+
* @description 获取地理处理工具列表。
28+
*/
29+
getTools() {
30+
const url = `${this.url}/list`;
31+
this._get(url);
32+
}
33+
/**
34+
* @function SuperMap.GeoprocessingService.prototype.getTool
35+
* @description 获取地理处理工具的ID、名称、描述、输入参数、环境参数和输出结果等相关参数。
36+
* @param {string} identifier - 地理处理工具ID。
37+
*/
38+
getTool(identifier) {
39+
const url = `${this.url}/${identifier}`;
40+
this._get(url);
41+
}
42+
/**
43+
* @function SuperMap.GeoprocessingService.prototype.execute
44+
* @description 同步执行地理处理工具。
45+
* @param {string} identifier - 地理处理工具ID。
46+
* @param {Object} parameter - 地理处理工具的输入参数。
47+
* @param {Object} environment - 地理处理工具的环境参数。
48+
*/
49+
execute(identifier, parameter, environment) {
50+
parameter = parameter ? parameter : null;
51+
environment = environment ? environment : null;
52+
const paramter = { parameter, environment };
53+
const url = `${this.url}/${identifier}/execute`;
54+
this._get(url, paramter);
55+
}
56+
/**
57+
* @function SuperMap.GeoprocessingService.prototype.submitJob
58+
* @description 异步执行地理处理工具。
59+
* @param {string} identifier - 地理处理工具ID。
60+
* @param {Object} parameter - 地理处理工具的输入参数。
61+
* @param {Object} environments - 地理处理工具的环境参数。
62+
*/
63+
submitJob(identifier, parameter, environments) {
64+
parameter = parameter ? parameter : null;
65+
environments = environments ? environments : null;
66+
const asyncParameter = { parameter: parameter, environments: environments };
67+
const url = `${this.url}/${identifier}/jobs`;
68+
this.request({
69+
url: url,
70+
headers: { 'Content-type': 'application/json' },
71+
method: 'POST',
72+
data: JSON.stringify(asyncParameter),
73+
scope: this,
74+
success: this.serviceProcessCompleted,
75+
failure: this.serviceProcessFailed
76+
});
77+
}
78+
79+
/**
80+
* @function SuperMap.GeoprocessingService.prototype.waitForJobCompletion
81+
* @description 获取地理处理异步执行状态信息。
82+
* @param {string} jobId - 地理处理任务ID。
83+
* @param {string} identifier - 地理处理工具ID。
84+
* @param {Object} options - 状态信息参数。
85+
* @param {number} options.interval - 定时器时间间隔。
86+
* @param {Callback} options.statusCallback - 任务状态的回调函数。
87+
*/
88+
waitForJobCompletion(jobId, identifier, options) {
89+
const me = this;
90+
const url = `${me.url}/${identifier}/jobs/${jobId}`;
91+
const timer = setInterval(function () {
92+
const serviceProcessCompleted = function (serverResult) {
93+
const state = serverResult.state.runState;
94+
options.statusCallback ? options.statusCallback(state) : null;
95+
switch (state) {
96+
case 'FINISHED':
97+
clearInterval(timer);
98+
me.events.triggerEvent('processCompleted', {
99+
result: serverResult
100+
});
101+
break;
102+
case 'FAILED':
103+
clearInterval(timer);
104+
me.events.triggerEvent('processFailed', {
105+
result: serverResult
106+
});
107+
break;
108+
case 'CANCEL':
109+
clearInterval(timer);
110+
me.events.triggerEvent('processFailed', {
111+
result: serverResult
112+
});
113+
break;
114+
}
115+
};
116+
me._get(url, null, serviceProcessCompleted);
117+
}, options.interval);
118+
}
119+
120+
/**
121+
* @function SuperMap.GeoprocessingService.prototype.getJobInfo
122+
* @description 获取地理处理任务的执行信息。
123+
* @param {string} identifier - 地理处理工具ID。
124+
* @param {string} jobId - 地理处理任务ID。
125+
*/
126+
getJobInfo(identifier, jobId) {
127+
const url = `${this.url}/${identifier}/jobs/${jobId}`;
128+
this._get(url);
129+
}
130+
131+
/**
132+
* @function SuperMap.GeoprocessingService.prototype.cancelJob
133+
* @description 取消地理处理任务的异步执行。
134+
* @param {string} identifier - 地理处理工具ID。
135+
* @param {string} jobId - 地理处理任务ID。
136+
*/
137+
cancelJob(identifier, jobId) {
138+
const url = `${this.url}/${identifier}/jobs/${jobId}/cancel`;
139+
this._get(url);
140+
}
141+
/**
142+
* @function SuperMap.GeoprocessingService.prototype.getJobs
143+
* @description 获取地理处理服务任务列表。
144+
* @param {string} identifier - 地理处理工具ID。(传参代表identifier算子的任务列表,不传参代表所有任务的列表)
145+
*/
146+
getJobs(identifier) {
147+
let url = `${this.url}/jobs`;
148+
if (identifier) {
149+
url = `${this.url}/${identifier}/jobs`;
150+
}
151+
this._get(url);
152+
}
153+
/**
154+
* @function SuperMap.GeoprocessingService.prototype.getResults
155+
* @description 地理处理工具执行的结果等,支持结果过滤。
156+
* @param {string} identifier - 地理处理工具ID。
157+
* @param {string} jobId - 地理处理任务ID。
158+
* @param {string} filter - 输出异步结果的id。(可选,传入filter参数时对该地理处理工具执行的结果进行过滤获取,不填参时显示所有的执行结果)
159+
*/
160+
getResults(identifier, jobId, filter) {
161+
let url = `${this.url}/${identifier}/jobs/${jobId}/results`;
162+
if (filter) {
163+
url = `${url}/${filter}`;
164+
}
165+
this._get(url);
166+
}
167+
_get(url, paramter, serviceProcessCompleted, serviceProcessFailed) {
168+
this.request({
169+
url: url,
170+
method: 'GET',
171+
params: paramter,
172+
headers: { 'Content-type': 'application/json' },
173+
scope: this,
174+
success: serviceProcessCompleted ? serviceProcessCompleted : this.serviceProcessCompleted,
175+
failure: serviceProcessFailed ? serviceProcessFailed : this.serviceProcessFailed
176+
});
177+
}
178+
}
179+
SuperMap.GeoprocessingService = GeoprocessingService;

src/common/iServer/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import { GeometryBufferAnalystParameters } from './GeometryBufferAnalystParamete
7575
import { GeometryOverlayAnalystParameters } from './GeometryOverlayAnalystParameters';
7676
import { GeometrySurfaceAnalystParameters } from './GeometrySurfaceAnalystParameters';
7777
import { GeometryThiessenAnalystParameters } from './GeometryThiessenAnalystParameters';
78+
import { GeoprocessingService } from './GeoprocessingService';
7879
import { GeoRelationAnalystParameters } from './GeoRelationAnalystParameters';
7980
import { GeoRelationAnalystService } from './GeoRelationAnalystService';
8081
import { GetFeaturesByBoundsParameters } from './GetFeaturesByBoundsParameters';
@@ -306,6 +307,7 @@ export { GenerateSpatialDataParameters };
306307
export { GenerateSpatialDataService };
307308
export { GeoBoundingBoxQueryBuilderParameter };
308309
export { GeoCodingParameter };
310+
export { GeoprocessingService };
309311
export { GeoDecodingParameter };
310312
export { GeoHashGridAggParameter };
311313
export { GeometryBufferAnalystParameters };

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy