Skip to content

Commit eb56b10

Browse files
committed
Core 新增交通网络分析服务 review by caoxinke
1 parent 53185bc commit eb56b10

File tree

3 files changed

+276
-0
lines changed

3 files changed

+276
-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.StopQueryService
8+
* 站点查询服务类。
9+
* 返回结果通过该类支持的事件的监听函数参数获取
10+
*
11+
* Inherits from:
12+
* - <SuperMap.CoreServiceBase>
13+
*/
14+
require('./CoreServiceBase');
15+
SuperMap.REST.StopQueryService = SuperMap.Class(SuperMap.CoreServiceBase, {
16+
17+
/**
18+
* Constructor: SuperMap.REST.StopQueryService
19+
* 站点查询服务类构造函数。
20+
*
21+
* 例如:
22+
* (start code)
23+
* var myService = new SuperMap.REST.StopQueryService(url, {eventListeners: {
24+
* "processCompleted": StopQueryCompleted,
25+
* "processFailed": StopQueryError
26+
* }
27+
* };
28+
* (end)
29+
*
30+
* Parameters:
31+
* url - {String} 与客户端交互的站点查询服务地址。
32+
* 例如:"http://localhost:8090/iserver/services/traffictransferanalyst-sample/restjsr/traffictransferanalyst/Traffic-Changchun"。
33+
* options - {Object} 参数。
34+
*
35+
* Allowed options properties:
36+
* eventListeners - {Object} 需要被注册的监听器对象。
37+
*/
38+
initialize: function (url, options) {
39+
SuperMap.CoreServiceBase.prototype.initialize.apply(this, arguments);
40+
options = options || {};
41+
SuperMap.Util.extend(this, options);
42+
},
43+
44+
/**
45+
* APIMethod: destroy
46+
* 释放资源,将引用资源的属性置空。
47+
*/
48+
destroy: function () {
49+
SuperMap.CoreServiceBase.prototype.destroy.apply(this, arguments);
50+
SuperMap.Util.reset(this);
51+
},
52+
53+
/**
54+
* APIMethod: processAsync
55+
* 负责将客户端的更新参数传递到服务端。
56+
*
57+
* Parameters:
58+
* params - {<SuperMap.REST.StopQueryParameters>} 交通换乘参数。
59+
*/
60+
processAsync: function (params) {
61+
if (!params) {
62+
return;
63+
}
64+
var me = this, end;
65+
66+
end = me.url.substr(me.url.length - 1, 1);
67+
me.url += (end === "/") ? '' : '/';
68+
me.url += "stops/keyword/" + params.keyWord;
69+
me.url += me.isInTheSameDomain ? ".json?" : ".jsonp";
70+
71+
me.request({
72+
method: "GET",
73+
params: {returnPosition: params.returnPosition},
74+
scope: me,
75+
success: me.serviceProcessCompleted,
76+
failure: me.serviceProcessFailed
77+
});
78+
},
79+
80+
CLASS_NAME: "SuperMap.REST.StopQueryService"
81+
});
82+
83+
module.exports = function (url, options) {
84+
return new SuperMap.REST.StopQueryService(url, options);
85+
};
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/* COPYRIGHT 2017 SUPERMAP
2+
* 本程序只能在有效的授权许可下使用。
3+
* 未经许可,不得以任何手段擅自使用或传播。*/
4+
5+
/**
6+
* Class: SuperMap.REST.TransferPathService
7+
* 交通换乘线路查询服务类,根据交通换乘分析结果(TransferSolutionResult),获取某一条乘车路线的详细信息。
8+
* 返回结果通过该类支持的事件的监听函数参数获取
9+
*
10+
* Inherits from:
11+
* - <SuperMap.CoreServiceBase>
12+
*/
13+
require('./CoreServiceBase');
14+
SuperMap.REST.TransferPathService = SuperMap.Class(SuperMap.CoreServiceBase, {
15+
16+
/**
17+
* Constructor: SuperMap.REST.TransferPathService
18+
* 交通换乘线路服务类构造函数。
19+
*
20+
* 例如:
21+
* (start code)
22+
* var myService = new SuperMap.REST.TransferPathService(url, {eventListeners: {
23+
* "processCompleted": TrafficTransferCompleted,
24+
* "processFailed": TrafficTransferError
25+
* }
26+
* };
27+
* (end)
28+
*
29+
* Parameters:
30+
* url - {String} 与客户端交互的交通换乘线路查询服务地址。
31+
* 例如:"http://localhost:8090/iserver/services/traffictransferanalyst-sample/restjsr/traffictransferanalyst/Traffic-Changchun"。
32+
* options - {Object} 参数。
33+
*
34+
* Allowed options properties:
35+
* eventListeners - {Object} 需要被注册的监听器对象。
36+
*/
37+
initialize: function(url, options) {
38+
SuperMap.CoreServiceBase.prototype.initialize.apply(this, arguments);
39+
options = options || {};
40+
SuperMap.Util.extend(this, options);
41+
},
42+
43+
/**
44+
* APIMethod: destroy
45+
* 释放资源,将引用资源的属性置空。
46+
*/
47+
destroy: function() {
48+
SuperMap.CoreServiceBase.prototype.destroy.apply(this, arguments);
49+
SuperMap.Util.reset(this);
50+
},
51+
52+
/**
53+
* APIMethod: processAsync
54+
* 负责将客户端的更新参数传递到服务端。
55+
*
56+
* Parameters:
57+
* params - {<SuperMap.REST.TransferPathParameters>} 交通换乘参数。
58+
*/
59+
processAsync: function(params) {
60+
if(!params){
61+
return;
62+
}
63+
var me = this,
64+
method = "GET",
65+
jsonParameters,
66+
end;
67+
68+
end = me.url.substr(me.url.length - 1, 1);
69+
me.url += (end === "/") ? '' : '/';
70+
me.url += me.isInTheSameDomain ? "path.json?" : "path.jsonp";
71+
72+
jsonParameters = {
73+
points: SuperMap.Util.toJSON(params.points),
74+
transferLines: params['transferLines']
75+
};
76+
77+
me.request({
78+
method: method,
79+
params: jsonParameters,
80+
scope: me,
81+
success: me.serviceProcessCompleted,
82+
failure: me.serviceProcessFailed
83+
});
84+
},
85+
86+
CLASS_NAME: "SuperMap.REST.TransferPathService"
87+
});
88+
89+
module.exports = function (url, options) {
90+
return new SuperMap.REST.TransferPathService(url, options);
91+
};
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/* COPYRIGHT 2017 SUPERMAP
2+
* 本程序只能在有效的授权许可下使用。
3+
* 未经许可,不得以任何手段擅自使用或传播。*/
4+
5+
/**
6+
* Class: SuperMap.REST.TransferSolutionService
7+
* 交通换乘方案查询服务类。
8+
* 返回结果通过该类支持的事件的监听函数参数获取
9+
*
10+
* Inherits from:
11+
* - <SuperMap.CoreServiceBase>
12+
*/
13+
require('./CoreServiceBase');
14+
15+
SuperMap.REST.TransferSolutionService = SuperMap.Class(SuperMap.CoreServiceBase, {
16+
17+
/**
18+
* Constructor: SuperMap.REST.TransferSolutionService
19+
* 交通换乘方案查询服务类构造函数。
20+
*
21+
* 例如:
22+
* (start code)
23+
* var myService = new SuperMap.REST.TransferSolutionService(url, {eventListeners: {
24+
* "processCompleted": trafficTransferCompleted,
25+
* "processFailed": trafficTransferError
26+
* }
27+
* };
28+
* (end)
29+
*
30+
* Parameters:
31+
* url - {String} 与客户端交互的交通换乘方案查询服务地址。
32+
* 例如:"http://localhost:8090/iserver/services/traffictransferanalyst-sample/restjsr/traffictransferanalyst/Traffic-Changchun"。
33+
* options - {Object} 参数。
34+
*
35+
* Allowed options properties:
36+
* eventListeners - {Object} 需要被注册的监听器对象。
37+
*/
38+
initialize: function (url, options) {
39+
SuperMap.CoreServiceBase.prototype.initialize.apply(this, arguments);
40+
options = options || {};
41+
SuperMap.Util.extend(this, options);
42+
},
43+
44+
/**
45+
* APIMethod: destroy
46+
* 释放资源,将引用资源的属性置空。
47+
*/
48+
destroy: function () {
49+
SuperMap.CoreServiceBase.prototype.destroy.apply(this, arguments);
50+
SuperMap.Util.reset(this);
51+
},
52+
53+
/**
54+
* APIMethod: processAsync
55+
* 负责将客户端的更新参数传递到服务端。
56+
*
57+
* Parameters:
58+
* params - {<SuperMap.REST.TransferSolutionParameters>} 交通换乘参数。
59+
*/
60+
processAsync: function (params) {
61+
if (!params) {
62+
return;
63+
}
64+
var me = this,
65+
method = "GET",
66+
jsonParameters,
67+
end;
68+
69+
end = me.url.substr(me.url.length - 1, 1);
70+
me.url += (end === "/") ? '' : '/';
71+
me.url += me.isInTheSameDomain ? "solutions.json?" : "solutions.jsonp";
72+
73+
jsonParameters = {
74+
points: SuperMap.Util.toJSON(params.points),
75+
walkingRatio: params['walkingRatio'],
76+
transferTactic: params['transferTactic'],
77+
solutionCount: params['solutionCount'],
78+
transferPreference: params["transferPreference"]
79+
};
80+
if (params.evadeLines) jsonParameters["evadeLines"] = SuperMap.Util.toJSON(params.evadeLines);
81+
if (params.evadeStops) jsonParameters["evadeStops"] = SuperMap.Util.toJSON(params.evadeStops);
82+
if (params.priorLines) jsonParameters["priorLines"] = SuperMap.Util.toJSON(params.priorLines);
83+
if (params.priorStops) jsonParameters["priorStops"] = SuperMap.Util.toJSON(params.priorStops);
84+
if (params.travelTime) jsonParameters["travelTime"] = params.travelTime;
85+
86+
me.request({
87+
method: method,
88+
params: jsonParameters,
89+
scope: me,
90+
success: me.serviceProcessCompleted,
91+
failure: me.serviceProcessFailed
92+
});
93+
},
94+
95+
CLASS_NAME: "SuperMap.REST.TransferSolutionService"
96+
});
97+
98+
module.exports = function (url, options) {
99+
return new SuperMap.REST.TransferSolutionService(url, options);
100+
};

0 commit comments

Comments
 (0)