Skip to content

Commit cad508e

Browse files
committed
Core 新增网络分析服务 review by caoxinke
1 parent eb56b10 commit cad508e

11 files changed

+1228
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/* COPYRIGHT 2017 SUPERMAP
2+
* 本程序只能在有效的授权许可下使用。
3+
* 未经许可,不得以任何手段擅自使用或传播。*/
4+
5+
6+
/**
7+
* Class: SuperMap.REST.BurstPipelineAnalystService
8+
* 爆管分析服务类;即将给定弧段或节点作为爆管点来进行分析,返回关键结点 ID 数组,普通结点 ID 数组及其上下游弧段 ID 数组。
9+
*
10+
* Inherits from:
11+
* - <SuperMap.CoreServiceBase>
12+
*/
13+
require('./CoreServiceBase');
14+
15+
SuperMap.REST.BurstPipelineAnalystService = SuperMap.Class(SuperMap.CoreServiceBase, {
16+
17+
/**
18+
* Constructor: SuperMap.REST.BurstPipelineAnalystService
19+
* 爆管分析服务类构造函数。
20+
*
21+
* Parameters:
22+
* url - {String} 网络分析服务地址。请求网络分析服务,URL应为:
23+
* http://{服务器地址}:{服务端口号}/iserver/services/{网络分析服务名}/rest/networkanalyst/{网络数据集@数据源};
24+
* 例如: "http://localhost:8090/iserver/services/test/rest/networkanalyst/WaterNet@FacilityNet";
25+
* options - {Object} 参数。
26+
*
27+
* Allowed options properties:
28+
* eventListeners - {Object} 需要被注册的监听器对象。
29+
*/
30+
31+
initialize: function(url, options) {
32+
SuperMap.CoreServiceBase.prototype.initialize.apply(this, arguments);
33+
},
34+
35+
/**
36+
* APIMethod: destroy
37+
* 释放资源,将引用的资源属性置空。
38+
*/
39+
destroy: function() {
40+
SuperMap.CoreServiceBase.prototype.destroy.apply(this, arguments);
41+
},
42+
43+
/**
44+
* APIMethod: processAsync
45+
* 负责将客户端的查询参数传递到服务端。
46+
*
47+
* Parameters:
48+
* params - {<SuperMap.REST.BurstPipelineAnalystParameters>}
49+
*/
50+
processAsync: function(params) {
51+
if (!params) {
52+
return;
53+
}
54+
var me = this, jsonObject;
55+
var end = me.url.substr(me.url.length - 1, 1);
56+
me.url = me.url + ((end === "/") ? "burstAnalyse" : "/burstAnalyse") + (this.isInTheSameDomain ? ".json?" : ".jsonp?");
57+
58+
jsonObject = {
59+
sourceNodeIDs: params.sourceNodeIDs,
60+
isUncertainDirectionValid: params.isUncertainDirectionValid
61+
};
62+
63+
//必传参数不正确,就终止
64+
if(params.edgeID !== null && params.nodeID !== null ) return;
65+
if(params.edgeID === null && params.nodeID === null ) return;
66+
if(params.edgeID !== null)
67+
jsonObject.edgeID = params.edgeID;
68+
else
69+
jsonObject.nodeID = params.nodeID;
70+
71+
me.request({
72+
method: "GET",
73+
params: jsonObject,
74+
scope: me,
75+
success: me.serviceProcessCompleted,
76+
failure: me.serviceProcessFailed
77+
});
78+
},
79+
80+
CLASS_NAME: "SuperMap.REST.BurstPipelineAnalystService"
81+
});
82+
83+
module.exports = function (url, options) {
84+
return new SuperMap.REST.BurstPipelineAnalystService(url, options);
85+
};
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/* COPYRIGHT 2017 SUPERMAP
2+
* 本程序只能在有效的授权许可下使用。
3+
* 未经许可,不得以任何手段擅自使用或传播。*/
4+
5+
/**
6+
* Class: SuperMap.REST.ComputeWeightMatrixService
7+
* 耗费矩阵分析服务类。
8+
* 耗费矩阵是根据交通网络分析参数中的耗费字段来计算一个二维数组,
9+
* 用来存储指定的任意两点间的资源消耗。
10+
* 耗费矩阵分析结果通过该类支持的事件的监听函数参数获取
11+
* Inherits from:
12+
* - <SuperMap.CoreServiceBase>
13+
*/
14+
require('./CoreServiceBase');
15+
16+
SuperMap.REST.ComputeWeightMatrixService = SuperMap.Class(SuperMap.CoreServiceBase, {
17+
18+
/**
19+
* Constructor: SuperMap.REST.ComputeWeightMatrixService
20+
* 耗费矩阵分析服务类构造函数。
21+
*
22+
* 例如:
23+
* (start code)
24+
* var mycomputeWeightMatrixService = new SuperMap.REST.ComputeWeightMatrixService(url,{
25+
* eventListeners: {
26+
* "processCompleted": computeWeightMatrixCompleted,
27+
* "processFailed": computeWeightMatrixnError
28+
* }
29+
* });
30+
* (end)
31+
*
32+
* Parameters:
33+
* url - {String} 耗费矩阵分析服务地址。请求服务的URL应为:
34+
* http://{服务器地址}:{服务端口号}/iserver/services/{网络分析服务名}/rest/networkanalyst/{网络数据集@数据源};
35+
* 例如:"http://localhost:8090/iserver/services/components-rest/rest/networkanalyst/RoadNet@Changchun"。
36+
* options - {Object} 参数。
37+
*
38+
* Allowed options properties:
39+
* eventListeners - {Object} 需要被注册的监听器对象。
40+
*/
41+
42+
initialize: function(url, options) {
43+
SuperMap.CoreServiceBase.prototype.initialize.apply(this, arguments);
44+
},
45+
46+
/**
47+
* APIMethod: destroy
48+
* 释放资源,将引用的资源属性置空。
49+
*/
50+
destroy: function() {
51+
SuperMap.CoreServiceBase.prototype.destroy.apply(this, arguments);
52+
},
53+
54+
/**
55+
* APIMethod: processAsync
56+
* 负责将客户端的查询参数传递到服务端。
57+
*
58+
* Parameters:
59+
* params - {<SuperMap.REST.ComputeWeightMatrixParameters>}
60+
*/
61+
processAsync: function(params) {
62+
if (!params) {
63+
return;
64+
}
65+
var me = this, jsonObject,
66+
end = me.url.substr(me.url.length - 1, 1);
67+
me.url = me.url + ((end === "/") ? "weightmatrix" : "/weightmatrix") + (this.isInTheSameDomain ? ".json?" : ".jsonp?");
68+
jsonObject = {
69+
parameter: SuperMap.Util.toJSON(params.parameter),
70+
nodes: me.getJson(params.isAnalyzeById, params.nodes)
71+
};
72+
me.request({
73+
method: "GET",
74+
params: jsonObject,
75+
scope: me,
76+
success: me.serviceProcessCompleted,
77+
failure: me.serviceProcessFailed
78+
});
79+
},
80+
81+
/**
82+
* Method: getJson
83+
* 将对象转化为JSON字符串。
84+
*
85+
* Parameters:
86+
* isAnalyzeById - {Boolean}
87+
* params - {Array}
88+
*
89+
* Returns:
90+
* {Object} 转化后的JSON字符串。
91+
*/
92+
getJson: function (isAnalyzeById, params) {
93+
var jsonString = "[",
94+
len = params ? params.length : 0;
95+
96+
if (isAnalyzeById === false) {
97+
for (var i = 0; i < len; i++) {
98+
if (i > 0) jsonString += ",";
99+
jsonString += '{"x":' + params[i].x + ',"y":' + params[i].y + '}';
100+
}
101+
} else if (isAnalyzeById == true) {
102+
for (var i = 0; i < len; i++) {
103+
if (i > 0) jsonString += ",";
104+
jsonString += params[i];
105+
}
106+
}
107+
jsonString += ']';
108+
return jsonString;
109+
},
110+
111+
CLASS_NAME: "SuperMap.REST.ComputeWeightMatrixService"
112+
});
113+
114+
module.exports = function (url, options) {
115+
return new SuperMap.REST.ComputeWeightMatrixService(url, options);
116+
};
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/* COPYRIGHT 2017 SUPERMAP
2+
* 本程序只能在有效的授权许可下使用。
3+
* 未经许可,不得以任何手段擅自使用或传播。*/
4+
5+
6+
/**
7+
* Class: SuperMap.REST.FacilityAnalystStreamService
8+
* 上游/下游 关键设施查找资源服务类;即查找给定弧段或节点的上游/下游中的关键设施结点,返回关键结点 ID 数组及其下游弧段 ID 数组。
9+
*
10+
* Inherits from:
11+
* - <SuperMap.CoreServiceBase>
12+
*/
13+
require('./CoreServiceBase');
14+
15+
SuperMap.REST.FacilityAnalystStreamService = SuperMap.Class(SuperMap.CoreServiceBase, {
16+
17+
/**
18+
* Constructor: SuperMap.REST.FacilityAnalystStreamService
19+
* 上游/下游关键设施查找资源服务类构造函数。
20+
*
21+
* Parameters:
22+
* url - {String} 网络分析服务地址。请求网络分析服务,URL应为:
23+
* http://{服务器地址}:{服务端口号}/iserver/services/{网络分析服务名}/rest/networkanalyst/{网络数据集@数据源};
24+
* 例如: "http://localhost:8090/iserver/services/test/rest/networkanalyst/WaterNet@FacilityNet";
25+
* options - {Object} 参数。
26+
*
27+
* Allowed options properties:
28+
* eventListeners - {Object} 需要被注册的监听器对象。
29+
*/
30+
31+
initialize: function (url, options) {
32+
SuperMap.CoreServiceBase.prototype.initialize.apply(this, arguments);
33+
},
34+
35+
/**
36+
* APIMethod: destroy
37+
* 释放资源,将引用的资源属性置空。
38+
*/
39+
destroy: function () {
40+
SuperMap.CoreServiceBase.prototype.destroy.apply(this, arguments);
41+
},
42+
43+
/**
44+
* APIMethod: processAsync
45+
* 负责将客户端的查询参数传递到服务端。
46+
*
47+
* Parameters:
48+
* params - {<SuperMap.REST.FacilityAnalystStreamParameters>}
49+
*/
50+
processAsync: function (params) {
51+
if (!params) {
52+
return;
53+
}
54+
var me = this, jsonObject;
55+
var end = me.url.substr(me.url.length - 1, 1);
56+
57+
//URL 通过参数类型来判断是 上游 还是下游 查询
58+
if (params.queryType === 0) {
59+
me.url = me.url + ((end === "/") ? "upstreamcirticalfaclilities" : "/upstreamcirticalfaclilities") + (this.isInTheSameDomain ? ".json?" : ".jsonp?");
60+
}
61+
else if (params.queryType === 1) {
62+
me.url = me.url + ((end === "/") ? "downstreamcirticalfaclilities" : "/downstreamcirticalfaclilities") + (this.isInTheSameDomain ? ".json?" : ".jsonp?");
63+
}
64+
else return;
65+
66+
jsonObject = {
67+
sourceNodeIDs: params.sourceNodeIDs,
68+
isUncertainDirectionValid: params.isUncertainDirectionValid
69+
};
70+
71+
if (params.edgeID !== null && params.nodeID !== null) return;
72+
if (params.edgeID === null && params.nodeID === null) return;
73+
if (params.edgeID !== null)
74+
jsonObject.edgeID = params.edgeID;
75+
else
76+
jsonObject.nodeID = params.nodeID;
77+
78+
me.request({
79+
method: "GET",
80+
params: jsonObject,
81+
scope: me,
82+
success: me.serviceProcessCompleted,
83+
failure: me.serviceProcessFailed
84+
});
85+
},
86+
87+
CLASS_NAME: "SuperMap.REST.FacilityAnalystStreamService"
88+
});
89+
90+
module.exports = function (url, options) {
91+
return new SuperMap.REST.FacilityAnalystStreamService(url, options);
92+
};

0 commit comments

Comments
 (0)