|
| 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