1- require ( '../../../src/common/iServer/FindClosestFacilitiesService' ) ;
1+ import { FindClosestFacilitiesService } from '../../../src/common/iServer/FindClosestFacilitiesService' ;
2+ import { FindClosestFacilitiesParameters } from '../../../src/common/iServer/FindClosestFacilitiesParameters' ;
3+ import { TransportationAnalystParameter } from '../../../src/common/iServer/TransportationAnalystParameter' ;
4+ import { TransportationAnalystResultSetting } from '../../../src/common/iServer/TransportationAnalystResultSetting' ;
5+ import { Point } from '../../../src/common/commontypes/geometry/Point' ;
26
3- var serviceFailedEventArgsSystem = null ;
4- var serviceSucceedEventArgsSystem = null ;
57var url = GlobeParameter . networkAnalystURL ;
8+ var serviceFailedEventArgsSystem = null , serviceSucceedEventArgsSystem = null ;
9+ var initFindClosestFacilitiesService = ( ) => {
10+ return new FindClosestFacilitiesService ( url , options ) ;
11+ } ;
12+ var findClosestFacilitiesServiceCompleted = ( serviceSucceedEventArgs ) => {
13+ serviceSucceedEventArgsSystem = serviceSucceedEventArgs ;
14+ } ;
15+ var findClosestFacilitiesServiceFailed = ( serviceFailedEventArgs ) => {
16+ serviceFailedEventArgsSystem = serviceFailedEventArgs ;
17+ } ;
618var options = {
719 eventListeners : {
820 'processFailed' : findClosestFacilitiesServiceFailed ,
921 'processCompleted' : findClosestFacilitiesServiceCompleted
1022 }
1123} ;
12- function initFindClosestFacilitiesService ( ) {
13- return new SuperMap . FindClosestFacilitiesService ( url , options ) ;
14- }
15- function findClosestFacilitiesServiceCompleted ( serviceSucceedEventArgs ) {
16- serviceSucceedEventArgsSystem = serviceSucceedEventArgs ;
17- }
18- function findClosestFacilitiesServiceFailed ( serviceFailedEventArgs ) {
19- serviceFailedEventArgsSystem = serviceFailedEventArgs ;
20- }
2124
22- describe ( 'FindClosestFacilitiesService' , function ( ) {
25+ describe ( 'FindClosestFacilitiesService' , ( ) => {
2326 var originalTimeout ;
24- beforeEach ( function ( ) {
27+ beforeEach ( ( ) => {
2528 originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
2629 jasmine . DEFAULT_TIMEOUT_INTERVAL = 50000 ;
2730 } ) ;
28- afterEach ( function ( ) {
31+ afterEach ( ( ) => {
2932 jasmine . DEFAULT_TIMEOUT_INTERVAL = originalTimeout ;
3033 } ) ;
3134
32- it ( 'processAsync:return:true' , function ( done ) {
33- var facilityPoints = [ new SuperMap . Geometry . Point ( 119.6100397551 , - 122.6278394459 ) ,
34- new SuperMap . Geometry . Point ( 171.9035599945 , - 113.2491141857 )
35+ it ( 'processAsync:return:true' , ( done ) => {
36+ var facilityPoints = [ new Point ( 119.6100397551 , - 122.6278394459 ) ,
37+ new Point ( 171.9035599945 , - 113.2491141857 )
3538 ] ;
36- var eventPoint = new SuperMap . Geometry . Point ( 159.6100397551 , - 116.6278394459 ) ;
37- var analystParameter = new SuperMap . TransportationAnalystParameter ( ) ;
38- var resultSetting = new SuperMap . TransportationAnalystResultSetting ( ) ;
39+ var eventPoint = new Point ( 159.6100397551 , - 116.6278394459 ) ;
40+ var analystParameter = new TransportationAnalystParameter ( ) ;
41+ var resultSetting = new TransportationAnalystResultSetting ( ) ;
3942 resultSetting . returnEdgeFeatures = true ;
4043 resultSetting . returnEdgeGeometry = true ;
4144 resultSetting . returnEdgeIDs = true ;
@@ -45,15 +48,15 @@ describe('FindClosestFacilitiesService', function () {
4548 resultSetting . returnPathGuides = true ;
4649 resultSetting . returnRoutes = true ;
4750 analystParameter . resultSetting = resultSetting ;
48- var parameter = new SuperMap . FindClosestFacilitiesParameters ( ) ;
51+ var parameter = new FindClosestFacilitiesParameters ( ) ;
4952 parameter . isAnalyzeById = false ;
5053 parameter . event = eventPoint ;
5154 parameter . facilities = facilityPoints ;
5255 parameter . expectFacilityCount = 2 ;
5356 parameter . parameter = analystParameter ;
5457 var closestFacilitiesService = initFindClosestFacilitiesService ( ) ;
5558 closestFacilitiesService . processAsync ( parameter ) ;
56- setTimeout ( function ( ) {
59+ setTimeout ( ( ) => {
5760 try {
5861 var analystResult = serviceSucceedEventArgsSystem . result . facilityPathList ;
5962 expect ( closestFacilitiesService ) . not . toBeNull ( ) ;
@@ -79,29 +82,27 @@ describe('FindClosestFacilitiesService', function () {
7982 } ) ;
8083
8184 // isAnalyzeById
82- it ( 'processAsync_isAnalyzeById' , function ( done ) {
83- var transReSetting = new SuperMap . TransportationAnalystResultSetting ( ) ;
84- with ( transReSetting ) {
85- returnEdgeFeatures = true ;
86- returnEdgeIDs = true ;
87- returnNodeFeatures = true ;
88- returnNodeIDs = true ;
89- }
90- var transAnaParams = new SuperMap . TransportationAnalystParameter ( ) ;
85+ it ( 'processAsync_isAnalyzeById' , ( done ) => {
86+ var transReSetting = new TransportationAnalystResultSetting ( {
87+ returnEdgeFeatures : true ,
88+ returnEdgeIDs : true ,
89+ returnNodeFeatures : true ,
90+ returnNodeIDs : true
91+ } ) ;
92+ var transAnaParams = new TransportationAnalystParameter ( ) ;
9193 transAnaParams . resultSetting = transReSetting ;
92- var facilitiesParams = new SuperMap . FindClosestFacilitiesParameters ( ) ;
93- with ( facilitiesParams ) {
94- event = 4602 ;
95- facilities = [ 4529 , 4530 ] ;
96- isAnalyzeById = true ;
97- expectFacilityCount = 2 ;
98- fromEvent = true ;
99- maxWeight = 30 ;
100- parameter = transAnaParams
101- }
94+ var facilitiesParams = new FindClosestFacilitiesParameters ( {
95+ event : 4602 ,
96+ facilities : [ 4529 , 4530 ] ,
97+ isAnalyzeById : true ,
98+ expectFacilityCount : 2 ,
99+ fromEvent : true ,
100+ maxWeight : 30 ,
101+ parameter : transAnaParams
102+ } ) ;
102103 var closestFacilitiesService = initFindClosestFacilitiesService ( ) ;
103104 closestFacilitiesService . processAsync ( facilitiesParams ) ;
104- setTimeout ( function ( ) {
105+ setTimeout ( ( ) => {
105106 try {
106107 expect ( serviceSucceedEventArgsSystem ) . not . toBeNull ( ) ;
107108 closestFacilitiesService . destroy ( ) ;
@@ -120,29 +121,27 @@ describe('FindClosestFacilitiesService', function () {
120121 } ) ;
121122
122123 //参数为空
123- it ( 'processAsync_parameterNull' , function ( done ) {
124- var transReSetting = new SuperMap . TransportationAnalystResultSetting ( ) ;
125- with ( transReSetting ) {
126- returnEdgeFeatures = true ;
127- returnEdgeIDs = true ;
128- returnNodeFeatures = true ;
129- returnNodeIDs = true ;
130- }
131- var transAnaParams = new SuperMap . TransportationAnalystParameter ( ) ;
124+ it ( 'processAsync_parameterNull' , ( done ) => {
125+ var transReSetting = new TransportationAnalystResultSetting ( {
126+ returnEdgeFeatures : true ,
127+ returnEdgeIDs : true ,
128+ returnNodeFeatures : true ,
129+ returnNodeIDs : true
130+ } ) ;
131+ var transAnaParams = new TransportationAnalystParameter ( ) ;
132132 transAnaParams . resultSetting = transReSetting ;
133- var facilitiesParams = new SuperMap . FindClosestFacilitiesParameters ( ) ;
134- with ( facilitiesParams ) {
135- event = 4602 ;
136- facilities = [ 4529 , 4530 ] ;
137- isAnalyzeById = true ;
138- expectFacilityCount = 2 ;
139- fromEvent = true ;
140- maxWeight = 30 ;
141- parameter = transAnaParams
142- }
133+ var facilitiesParams = new FindClosestFacilitiesParameters ( {
134+ event : 4602 ,
135+ facilities : [ 4529 , 4530 ] ,
136+ isAnalyzeById : true ,
137+ expectFacilityCount : 2 ,
138+ fromEvent : true ,
139+ maxWeight : 30 ,
140+ parameter : transAnaParams
141+ } ) ;
143142 var closestFacilitiesService = initFindClosestFacilitiesService ( ) ;
144143 closestFacilitiesService . processAsync ( ) ;
145- setTimeout ( function ( ) {
144+ setTimeout ( ( ) => {
146145 try {
147146 expect ( serviceSucceedEventArgsSystem . result . facilityPathList ) . toBeNull ( ) ;
148147 closestFacilitiesService . destroy ( ) ;
@@ -156,31 +155,27 @@ describe('FindClosestFacilitiesService', function () {
156155 } , 2000 ) ;
157156 } ) ;
158157
159- it ( 'fail_processAsync' , function ( done ) {
160- var transReSetting = new SuperMap . TransportationAnalystResultSetting ( ) ;
161- with ( transReSetting ) {
162- returnEdgeFeatures = true ;
163- returnEdgeIDs = true ;
164- returnNodeFeatures = true ;
165- returnNodeIDs = true ;
166- }
167-
168- var transAnaParams = new SuperMap . TransportationAnalystParameter ( ) ;
158+ it ( 'fail_processAsync' , ( done ) => {
159+ var transReSetting = new TransportationAnalystResultSetting ( {
160+ returnEdgeFeatures : true ,
161+ returnEdgeIDs : true ,
162+ returnNodeFeatures : true ,
163+ returnNodeIDs : true
164+ } ) ;
165+ var transAnaParams = new TransportationAnalystParameter ( ) ;
169166 transAnaParams . resultSetting = transReSetting ;
170-
171- var facilitiesParams = new SuperMap . FindClosestFacilitiesParameters ( ) ;
172- with ( facilitiesParams ) {
173- event = 4602 ;
174- facilities = "facil”" ;
175- isAnalyzeById = true ;
176- expectFacilityCount = 2 ;
177- fromEvent = true ;
178- maxWeight = 30 ;
179- parameter = transAnaParams
180- }
167+ var facilitiesParams = new FindClosestFacilitiesParameters ( {
168+ event : 4602 ,
169+ facilities : "facil”" ,
170+ isAnalyzeById : true ,
171+ expectFacilityCount : 2 ,
172+ fromEvent : true ,
173+ maxWeight : 30 ,
174+ parameter : transAnaParams
175+ } ) ;
181176 var closestFacilitiesService = initFindClosestFacilitiesService ( ) ;
182177 closestFacilitiesService . processAsync ( facilitiesParams ) ;
183- setTimeout ( function ( ) {
178+ setTimeout ( ( ) => {
184179 try {
185180 expect ( serviceSucceedEventArgsSystem . result . facilityPathList ) . toBeNull ( ) ;
186181 expect ( serviceFailedEventArgsSystem . error . code ) . toEqual ( 400 ) ;
0 commit comments