1
- require ( '../../../src/common/commontypes/Bounds' ) ;
2
- require ( '../../../src/common/commontypes/LonLat' ) ;
1
+ import { Bounds } from '../../../src/common/commontypes/Bounds' ;
2
+ import { Pixel } from '../../../src/common/commontypes/Pixel' ;
3
+ import { LonLat } from '../../../src/common/commontypes/LonLat' ;
4
+ import { Size } from '../../../src/common/commontypes/Size' ;
5
+ import { Point } from '../../../src/common/commontypes/geometry/Point' ;
3
6
4
- describe ( 'Bounds' , function ( ) {
5
- it ( 'constructor, clone, equals, toString, toArray' , function ( ) {
6
- var bounds = new SuperMap . Bounds ( [ - 180 , - 90 , 180 , 90 ] ) ;
7
+ describe ( 'Bounds' , ( ) => {
8
+ it ( 'constructor, clone, equals, toString, toArray' , ( ) => {
9
+ var bounds = new Bounds ( [ - 180 , - 90 , 180 , 90 ] ) ;
7
10
var bounds1 = bounds . clone ( ) ;
8
11
expect ( bounds ) . not . toBeNull ( ) ;
9
12
expect ( bounds . CLASS_NAME ) . toEqual ( "SuperMap.Bounds" ) ;
@@ -32,8 +35,8 @@ describe('Bounds', function () {
32
35
} ) ;
33
36
34
37
//取小数点后decimal位数字进行四舍五入再转换为BBOX字符串
35
- it ( 'toBBOX' , function ( ) {
36
- var bounds = new SuperMap . Bounds ( - 1.1234567 , - 1.7654321 , 1.4444444 , 1.5555555 ) ;
38
+ it ( 'toBBOX' , ( ) => {
39
+ var bounds = new Bounds ( - 1.1234567 , - 1.7654321 , 1.4444444 , 1.5555555 ) ;
37
40
var str1 = bounds . toBBOX ( ) ;
38
41
expect ( str1 ) . toEqual ( "-1.123457,-1.765432,1.444444,1.555556" ) ;
39
42
var str2 = bounds . toBBOX ( 1 ) ;
@@ -43,8 +46,8 @@ describe('Bounds', function () {
43
46
bounds . destroy ( ) ;
44
47
} ) ;
45
48
46
- it ( 'getSize, getCenterPixel' , function ( ) {
47
- var bounds = new SuperMap . Bounds ( - 180 , - 90 , 100 , 80 ) ;
49
+ it ( 'getSize, getCenterPixel' , ( ) => {
50
+ var bounds = new Bounds ( - 180 , - 90 , 100 , 80 ) ;
48
51
var size = bounds . getSize ( ) ;
49
52
var pixel = bounds . getCenterPixel ( ) ;
50
53
expect ( size . w ) . toEqual ( 280 ) ;
@@ -54,15 +57,15 @@ describe('Bounds', function () {
54
57
bounds . destroy ( ) ;
55
58
} ) ;
56
59
57
- it ( 'scale' , function ( ) {
58
- var bounds = new SuperMap . Bounds ( - 50 , - 50 , 40 , 40 ) ;
60
+ it ( 'scale' , ( ) => {
61
+ var bounds = new Bounds ( - 50 , - 50 , 40 , 40 ) ;
59
62
var bounds1 = bounds . scale ( 2 ) ;
60
63
expect ( bounds1 ) . not . toBeNull ( ) ;
61
64
expect ( bounds1 . bottom ) . toEqual ( - 95 ) ;
62
65
expect ( bounds1 . left ) . toEqual ( - 95 ) ;
63
66
expect ( bounds1 . right ) . toEqual ( 85 ) ;
64
67
expect ( bounds1 . top ) . toEqual ( 85 ) ;
65
- var origin = new SuperMap . Pixel ( 40 , 50 ) ;
68
+ var origin = new Pixel ( 40 , 50 ) ;
66
69
var bounds2 = bounds . scale ( 2 , origin ) ;
67
70
expect ( bounds2 ) . not . toBeNull ( ) ;
68
71
expect ( bounds2 . bottom ) . toEqual ( - 150 ) ;
@@ -72,8 +75,8 @@ describe('Bounds', function () {
72
75
bounds . destroy ( ) ;
73
76
} ) ;
74
77
75
- it ( 'add' , function ( ) {
76
- var bounds = new SuperMap . Bounds ( - 50 , - 50 , 40 , 40 ) ;
78
+ it ( 'add' , ( ) => {
79
+ var bounds = new Bounds ( - 50 , - 50 , 40 , 40 ) ;
77
80
var newBounds = bounds . add ( 20 , 10 ) ;
78
81
expect ( newBounds ) . not . toBeNull ( ) ;
79
82
expect ( newBounds . bottom ) . toEqual ( - 40 ) ;
@@ -84,14 +87,14 @@ describe('Bounds', function () {
84
87
} ) ;
85
88
86
89
//在当前bounds上扩展bounds
87
- it ( 'extend' , function ( ) {
88
- var bounds = new SuperMap . Bounds ( - 50 , - 50 , 40 , 40 ) ;
90
+ it ( 'extend' , ( ) => {
91
+ var bounds = new Bounds ( - 50 , - 50 , 40 , 40 ) ;
89
92
spyOn ( bounds , 'extend' ) . and . callThrough ( ) ;
90
- bounds . extend ( new SuperMap . LonLat ( 50 , 60 ) ) ;
93
+ bounds . extend ( new LonLat ( 50 , 60 ) ) ;
91
94
expect ( bounds ) . not . toBeNull ( ) ;
92
- bounds . extend ( new SuperMap . Geometry . Point ( 50 , 60 ) ) ;
95
+ bounds . extend ( new Point ( 50 , 60 ) ) ;
93
96
expect ( bounds ) . not . toBeNull ( ) ;
94
- bounds . extend ( new SuperMap . Bounds ( 50 , 60 ) ) ;
97
+ bounds . extend ( new Bounds ( 50 , 60 ) ) ;
95
98
expect ( bounds ) . not . toBeNull ( ) ;
96
99
expect ( bounds . bottom ) . toEqual ( - 50 ) ;
97
100
expect ( bounds . left ) . toEqual ( - 50 ) ;
@@ -101,30 +104,30 @@ describe('Bounds', function () {
101
104
} ) ;
102
105
103
106
//判断传入的坐标是否在范围内
104
- it ( 'containsLonLat' , function ( ) {
105
- var bounds = new SuperMap . Bounds ( - 50 , - 50 , 40 , 40 ) ;
106
- var isContains1 = bounds . containsLonLat ( new SuperMap . LonLat ( 40 , 40 ) , true ) ;
107
+ it ( 'containsLonLat' , ( ) => {
108
+ var bounds = new Bounds ( - 50 , - 50 , 40 , 40 ) ;
109
+ var isContains1 = bounds . containsLonLat ( new LonLat ( 40 , 40 ) , true ) ;
107
110
expect ( isContains1 ) . toBeTruthy ( ) ;
108
111
var isContains2 = bounds . containsLonLat (
109
- new SuperMap . LonLat ( 400 , 40 ) ,
112
+ new LonLat ( 400 , 40 ) ,
110
113
{
111
114
inclusive : true ,
112
- worldBounds : new SuperMap . Bounds ( - 180 , - 90 , 180 , 90 )
115
+ worldBounds : new Bounds ( - 180 , - 90 , 180 , 90 )
113
116
}
114
117
) ;
115
118
expect ( isContains2 ) . toBeTruthy ( ) ;
116
119
bounds . destroy ( ) ;
117
120
} ) ;
118
121
119
- it ( 'containsPixel' , function ( ) {
120
- var bounds = new SuperMap . Bounds ( - 50 , - 50 , 40 , 40 ) ;
121
- var isContains = bounds . containsPixel ( new SuperMap . Pixel ( 40 , 40 ) , true ) ;
122
+ it ( 'containsPixel' , ( ) => {
123
+ var bounds = new Bounds ( - 50 , - 50 , 40 , 40 ) ;
124
+ var isContains = bounds . containsPixel ( new Pixel ( 40 , 40 ) , true ) ;
122
125
expect ( isContains ) . toBeTruthy ( ) ;
123
126
bounds . destroy ( ) ;
124
127
} ) ;
125
128
126
- it ( 'contains' , function ( ) {
127
- var bounds = new SuperMap . Bounds ( - 50 , - 50 , 40 , 40 ) ;
129
+ it ( 'contains' , ( ) => {
130
+ var bounds = new Bounds ( - 50 , - 50 , 40 , 40 ) ;
128
131
var isContains1 = bounds . contains ( 40 , 40 ) ;
129
132
var isContains2 = bounds . contains ( ) ;
130
133
var isContains3 = bounds . contains ( 40 , 40 , false ) ;
@@ -135,38 +138,38 @@ describe('Bounds', function () {
135
138
} ) ;
136
139
137
140
//判断目标边界范围是否与当前边界范围相交
138
- it ( 'intersectsBounds' , function ( ) {
139
- var bounds = new SuperMap . Bounds ( - 180 , - 90 , 100 , 80 ) ;
141
+ it ( 'intersectsBounds' , ( ) => {
142
+ var bounds = new Bounds ( - 180 , - 90 , 100 , 80 ) ;
140
143
var options1 = {
141
144
inclusive : false ,
142
- worldBounds : new SuperMap . Bounds ( - 170 , - 90 , 120 , 80 )
145
+ worldBounds : new Bounds ( - 170 , - 90 , 120 , 80 )
143
146
} ;
144
147
var options2 = {
145
148
inclusive : false ,
146
- worldBounds : new SuperMap . Bounds ( - 180 , - 90 , 100 , 80 )
149
+ worldBounds : new Bounds ( - 180 , - 90 , 100 , 80 )
147
150
} ;
148
151
var isIntersects1 = bounds . intersectsBounds (
149
- new SuperMap . Bounds ( 100 , - 90 , 120 , 80 ) ,
152
+ new Bounds ( 100 , - 90 , 120 , 80 ) ,
150
153
options1
151
154
) ;
152
155
var isIntersects2 = bounds . intersectsBounds (
153
- new SuperMap . Bounds ( 100 , - 90 , 100 , 80 ) ,
156
+ new Bounds ( 100 , - 90 , 100 , 80 ) ,
154
157
options2
155
158
) ;
156
159
expect ( isIntersects1 ) . toBeTruthy ( ) ;
157
160
expect ( isIntersects2 ) . toBeFalsy ( ) ;
158
161
bounds . destroy ( ) ;
159
162
} ) ;
160
163
161
- it ( 'determineQuadrant' , function ( ) {
162
- var bounds = new SuperMap . Bounds ( - 180 , - 90 , 100 , 80 ) ;
163
- var str = bounds . determineQuadrant ( new SuperMap . LonLat ( 20 , 20 ) ) ;
164
+ it ( 'determineQuadrant' , ( ) => {
165
+ var bounds = new Bounds ( - 180 , - 90 , 100 , 80 ) ;
166
+ var str = bounds . determineQuadrant ( new LonLat ( 20 , 20 ) ) ;
164
167
expect ( str ) . toEqual ( "tr" ) ;
165
168
bounds . destroy ( ) ;
166
169
} ) ;
167
170
168
- it ( 'toServerJSONObject' , function ( ) {
169
- var bounds = new SuperMap . Bounds ( - 180 , - 90 , 100 , 80 ) ;
171
+ it ( 'toServerJSONObject' , ( ) => {
172
+ var bounds = new Bounds ( - 180 , - 90 , 100 , 80 ) ;
170
173
var obj = bounds . toServerJSONObject ( ) ;
171
174
expect ( obj ) . not . toBeNull ( ) ;
172
175
expect ( obj . bottom ) . toEqual ( - 90 ) ;
@@ -178,26 +181,26 @@ describe('Bounds', function () {
178
181
bounds . destroy ( ) ;
179
182
} ) ;
180
183
181
- it ( 'fromString' , function ( ) {
182
- var bounds = SuperMap . Bounds . fromString ( "-180,-90,100,80" , false ) ;
184
+ it ( 'fromString' , ( ) => {
185
+ var bounds = Bounds . fromString ( "-180,-90,100,80" , false ) ;
183
186
expect ( bounds ) . not . toBeNull ( ) ;
184
187
expect ( bounds . bottom ) . toEqual ( - 90 ) ;
185
188
expect ( bounds . left ) . toEqual ( - 180 ) ;
186
189
expect ( bounds . right ) . toEqual ( 100 ) ;
187
190
expect ( bounds . top ) . toEqual ( 80 ) ;
188
191
} ) ;
189
192
190
- it ( 'fromSize' , function ( ) {
191
- var bounds = SuperMap . Bounds . fromSize ( new SuperMap . Size ( 20 , 10 ) ) ;
193
+ it ( 'fromSize' , ( ) => {
194
+ var bounds = Bounds . fromSize ( new Size ( 20 , 10 ) ) ;
192
195
expect ( bounds ) . not . toBeNull ( ) ;
193
196
expect ( bounds . bottom ) . toEqual ( 10 ) ;
194
197
expect ( bounds . left ) . toEqual ( 0 ) ;
195
198
expect ( bounds . right ) . toEqual ( 20 ) ;
196
199
expect ( bounds . top ) . toEqual ( 0 ) ;
197
200
} ) ;
198
201
199
- it ( 'oppositeQuadrant' , function ( ) {
200
- var oppositeQuadrant = SuperMap . Bounds . oppositeQuadrant ( "tl" ) ;
202
+ it ( 'oppositeQuadrant' , ( ) => {
203
+ var oppositeQuadrant = Bounds . oppositeQuadrant ( "tl" ) ;
201
204
expect ( oppositeQuadrant ) . toEqual ( "br" ) ;
202
205
} ) ;
203
206
} ) ;
0 commit comments