forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetFieldsService.js
More file actions
83 lines (72 loc) · 2.84 KB
/
GetFieldsService.js
File metadata and controls
83 lines (72 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import {SuperMap} from '../SuperMap';
import {Util} from '../commontypes/Util';
import {CommonServiceBase} from './CommonServiceBase';
/**
* @class SuperMap.GetFieldsService
* @category iServer Data Field
* @classdesc 字段查询服务,支持查询指定数据集的中所有属性字段(field)的集合。
* @param url - {string} 服务的访问地址。如访问World Map服务,只需将url设为: http://localhost:8090/iserver/services/data-world/rest/data 即可。
* @param options - {Object} 可選参数。如:</br>
* eventListeners - {Object} 事件监听器对象。有processCompleted属性可传入处理完成后的回调函数。processFailed属性传入处理失败后的回调函数。<br>
* serverType - {SuperMap.ServerType} 服务器类型,iServer|iPortal|Online。<br>
* format -{SuperMap.DataFormat} 查询结果返回格式,目前支持iServerJSON 和GeoJSON两种格式。参数格式为"ISERVER","GEOJSON"。
* datasource - {string}</br>
* dataset - {string}</br>
* @extends SuperMap.CommonServiceBase
* @example
* var myService = new SuperMap.GetFieldsService(url, {eventListeners: {
* "processCompleted": getFieldsCompleted,
* "processFailed": getFieldsError
* },
* datasource: "World",
* dataset: "Countries"
* };
*
*/
export class GetFieldsService extends CommonServiceBase {
constructor(url, options) {
super(url, options);
/**
* @member SuperMap.GetFieldsService.prototype.datasource -{string}
* @description 要查询的数据集所在的数据源名称。
*/
this.datasource = null;
/**
* @member SuperMap.GetFieldsService.prototype.dataset -{string}
* @description 要查询的数据集名称。
*/
this.dataset = null;
if (options) {
Util.extend(this, options);
}
this.CLASS_NAME = "SuperMap.GetFieldsService";
}
/**
* @function SuperMap.GetFieldsService.prototype.destroy
* @override
*/
destroy() {
super.destroy();
var me = this;
me.datasource = null;
me.dataset = null;
}
/**
* @function SuperMap.GetFieldsService.prototype.processAsync
* @description 执行服务,查询指定数据集的字段信息。
*/
processAsync() {
var me = this,
end = me.url.substr(me.url.length - 1, 1),
datasetURL = "datasources/" + me.datasource + "/datasets/" + me.dataset;
me.url += (end == "/") ? datasetURL + "/fields.json?" : "/" + datasetURL + "/fields.json?";
me.request({
method: "GET",
data: null,
scope: me,
success: me.serviceProcessCompleted,
failure: me.serviceProcessFailed
});
}
}
SuperMap.GetFieldsService = GetFieldsService;