1+ require ( '../../../src/leaflet/services/spatialAnalystService' ) ;
2+
3+ var spatialAnalystURL = GlobeParameter . spatialAnalystURL_Changchun ;
4+ var options = {
5+ serverType : 'iServer'
6+ } ;
7+ describe ( 'leaflet_SpatialAnalystService_bufferAnalysis' , function ( ) {
8+ var serviceResult ;
9+ var originalTimeout ;
10+ beforeEach ( function ( ) {
11+ originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
12+ jasmine . DEFAULT_TIMEOUT_INTERVAL = 50000 ;
13+ serviceResult = null ;
14+ } ) ;
15+ afterEach ( function ( ) {
16+ jasmine . DEFAULT_TIMEOUT_INTERVAL = originalTimeout ;
17+ } ) ;
18+ it ( 'bufferAnalysis_test' , function ( done ) {
19+ var pointsList = [
20+ [ - 4690.000 , 2823.940 ] ,
21+ [ - 4690.301 , 3448.940 ] ,
22+ [ - 3810.125 , 3816.561 ] ,
23+ [ - 3609.158 , 3917.383 ] ,
24+ [ - 3490.291 , 3976.983 ] ,
25+ [ - 4377.027 , 4020.004 ] ,
26+ [ - 4382.939 , 4076.265 ] ,
27+ [ - 4382.333 , 4215.049 ] ,
28+ [ - 4382.285 , 4428.156 ] ,
29+ [ - 4383.017 , 4647.579 ] ,
30+ [ - 4382.898 , 4679.707 ] ,
31+ [ - 4382.635 , 4917.462 ] ,
32+ [ - 4381.833 , 5074.019 ] ,
33+ [ - 4381.031 , 5257.042 ] ,
34+ [ - 4380.717 , 5363.785 ] ,
35+ [ - 4378.794 , 5671.717 ] ,
36+ [ - 4377.970 , 5847.521 ] ,
37+ [ - 4303.528 , 5990.637 ] ,
38+ [ - 4270.072 , 6055.343 ] ,
39+ [ - 4382.389 , 6168.913 ] ,
40+ [ - 4209.927 , 6214.183 ] ,
41+ [ - 4209.142 , 6377.789 ] ,
42+ [ - 4210.142 , 6393.692 ] ,
43+ [ - 4207.450 , 6693.989 ] ,
44+ [ - 4208.450 , 6788.392 ] ,
45+ [ - 4207.210 , 6984.304 ] ,
46+ [ - 4208.296 , 7189.183 ] ,
47+ [ - 4208.296 , 7300.505 ] ,
48+ [ - 4208.803 , 7573.056 ] ,
49+ [ - 4208.804 , 7680.977 ] ,
50+ [ - 4208.393 , 7850.593 ] ,
51+ [ - 4210.533 , 8182.656 ] ,
52+ [ - 4261.485 , 8554.893 ]
53+ ] ;
54+ var roadLine = L . polyline ( pointsList , { color : 'red' } ) ;
55+ var geoBufferAnalystParams = new SuperMap . GeometryBufferAnalystParameters ( {
56+ sourceGeometry : roadLine ,
57+ bufferSetting : new SuperMap . BufferSetting ( {
58+ endType : SuperMap . BufferEndType . ROUND ,
59+ leftDistance : new SuperMap . BufferDistance ( { value : 250 } ) ,
60+ rightDistance : new SuperMap . BufferDistance ( { value : 250 } ) ,
61+ semicircleLineSegment : 10
62+ } )
63+ } ) ;
64+ var bufferAnalystService = L . supermap . spatialAnalystService ( spatialAnalystURL , options ) ;
65+ bufferAnalystService . bufferAnalysis ( geoBufferAnalystParams , function ( result ) {
66+ serviceResult = result ;
67+ } ) ;
68+ setTimeout ( function ( ) {
69+ try {
70+ expect ( bufferAnalystService ) . not . toBeNull ( ) ;
71+ expect ( serviceResult ) . not . toBeNull ( ) ;
72+ expect ( serviceResult . type ) . toBe ( "processCompleted" ) ;
73+ expect ( serviceResult . result ) . not . toBeNull ( ) ;
74+ expect ( serviceResult . result . succeed ) . toBe ( true ) ;
75+ var resultGeometry = serviceResult . result . resultGeometry ;
76+ expect ( resultGeometry . type ) . toBe ( "Feature" ) ;
77+ expect ( resultGeometry . geometry ) . not . toBeNull ( ) ;
78+ expect ( resultGeometry . geometry . type ) . toEqual ( "MultiPolygon" ) ;
79+ var coordinates = resultGeometry . geometry . coordinates ;
80+ expect ( coordinates ) . not . toBeNull ( ) ;
81+ expect ( coordinates . length ) . toBeGreaterThan ( 0 ) ;
82+ for ( var i = 0 ; i < coordinates [ 0 ] [ 0 ] . length ; i ++ ) {
83+ expect ( coordinates [ 0 ] [ 0 ] [ i ] . length ) . toEqual ( 2 ) ;
84+ }
85+ bufferAnalystService . destroy ( ) ;
86+ done ( ) ;
87+ } catch ( exception ) {
88+ console . log ( "'bufferAnalysis_test'案例失败" + exception . name + ":" + exception . message ) ;
89+ bufferAnalystService . destroy ( ) ;
90+ expect ( false ) . toBeTruthy ( ) ;
91+ done ( ) ;
92+ }
93+ } , 5000 ) ;
94+ } ) ;
95+ } ) ;
0 commit comments