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' ;
36
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 ] ) ;
710 var bounds1 = bounds . clone ( ) ;
811 expect ( bounds ) . not . toBeNull ( ) ;
912 expect ( bounds . CLASS_NAME ) . toEqual ( "SuperMap.Bounds" ) ;
@@ -32,8 +35,8 @@ describe('Bounds', function () {
3235 } ) ;
3336
3437 //取小数点后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 ) ;
3740 var str1 = bounds . toBBOX ( ) ;
3841 expect ( str1 ) . toEqual ( "-1.123457,-1.765432,1.444444,1.555556" ) ;
3942 var str2 = bounds . toBBOX ( 1 ) ;
@@ -43,8 +46,8 @@ describe('Bounds', function () {
4346 bounds . destroy ( ) ;
4447 } ) ;
4548
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 ) ;
4851 var size = bounds . getSize ( ) ;
4952 var pixel = bounds . getCenterPixel ( ) ;
5053 expect ( size . w ) . toEqual ( 280 ) ;
@@ -54,15 +57,15 @@ describe('Bounds', function () {
5457 bounds . destroy ( ) ;
5558 } ) ;
5659
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 ) ;
5962 var bounds1 = bounds . scale ( 2 ) ;
6063 expect ( bounds1 ) . not . toBeNull ( ) ;
6164 expect ( bounds1 . bottom ) . toEqual ( - 95 ) ;
6265 expect ( bounds1 . left ) . toEqual ( - 95 ) ;
6366 expect ( bounds1 . right ) . toEqual ( 85 ) ;
6467 expect ( bounds1 . top ) . toEqual ( 85 ) ;
65- var origin = new SuperMap . Pixel ( 40 , 50 ) ;
68+ var origin = new Pixel ( 40 , 50 ) ;
6669 var bounds2 = bounds . scale ( 2 , origin ) ;
6770 expect ( bounds2 ) . not . toBeNull ( ) ;
6871 expect ( bounds2 . bottom ) . toEqual ( - 150 ) ;
@@ -72,8 +75,8 @@ describe('Bounds', function () {
7275 bounds . destroy ( ) ;
7376 } ) ;
7477
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 ) ;
7780 var newBounds = bounds . add ( 20 , 10 ) ;
7881 expect ( newBounds ) . not . toBeNull ( ) ;
7982 expect ( newBounds . bottom ) . toEqual ( - 40 ) ;
@@ -84,14 +87,14 @@ describe('Bounds', function () {
8487 } ) ;
8588
8689 //在当前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 ) ;
8992 spyOn ( bounds , 'extend' ) . and . callThrough ( ) ;
90- bounds . extend ( new SuperMap . LonLat ( 50 , 60 ) ) ;
93+ bounds . extend ( new LonLat ( 50 , 60 ) ) ;
9194 expect ( bounds ) . not . toBeNull ( ) ;
92- bounds . extend ( new SuperMap . Geometry . Point ( 50 , 60 ) ) ;
95+ bounds . extend ( new Point ( 50 , 60 ) ) ;
9396 expect ( bounds ) . not . toBeNull ( ) ;
94- bounds . extend ( new SuperMap . Bounds ( 50 , 60 ) ) ;
97+ bounds . extend ( new Bounds ( 50 , 60 ) ) ;
9598 expect ( bounds ) . not . toBeNull ( ) ;
9699 expect ( bounds . bottom ) . toEqual ( - 50 ) ;
97100 expect ( bounds . left ) . toEqual ( - 50 ) ;
@@ -101,30 +104,30 @@ describe('Bounds', function () {
101104 } ) ;
102105
103106 //判断传入的坐标是否在范围内
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 ) ;
107110 expect ( isContains1 ) . toBeTruthy ( ) ;
108111 var isContains2 = bounds . containsLonLat (
109- new SuperMap . LonLat ( 400 , 40 ) ,
112+ new LonLat ( 400 , 40 ) ,
110113 {
111114 inclusive : true ,
112- worldBounds : new SuperMap . Bounds ( - 180 , - 90 , 180 , 90 )
115+ worldBounds : new Bounds ( - 180 , - 90 , 180 , 90 )
113116 }
114117 ) ;
115118 expect ( isContains2 ) . toBeTruthy ( ) ;
116119 bounds . destroy ( ) ;
117120 } ) ;
118121
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 ) ;
122125 expect ( isContains ) . toBeTruthy ( ) ;
123126 bounds . destroy ( ) ;
124127 } ) ;
125128
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 ) ;
128131 var isContains1 = bounds . contains ( 40 , 40 ) ;
129132 var isContains2 = bounds . contains ( ) ;
130133 var isContains3 = bounds . contains ( 40 , 40 , false ) ;
@@ -135,38 +138,38 @@ describe('Bounds', function () {
135138 } ) ;
136139
137140 //判断目标边界范围是否与当前边界范围相交
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 ) ;
140143 var options1 = {
141144 inclusive : false ,
142- worldBounds : new SuperMap . Bounds ( - 170 , - 90 , 120 , 80 )
145+ worldBounds : new Bounds ( - 170 , - 90 , 120 , 80 )
143146 } ;
144147 var options2 = {
145148 inclusive : false ,
146- worldBounds : new SuperMap . Bounds ( - 180 , - 90 , 100 , 80 )
149+ worldBounds : new Bounds ( - 180 , - 90 , 100 , 80 )
147150 } ;
148151 var isIntersects1 = bounds . intersectsBounds (
149- new SuperMap . Bounds ( 100 , - 90 , 120 , 80 ) ,
152+ new Bounds ( 100 , - 90 , 120 , 80 ) ,
150153 options1
151154 ) ;
152155 var isIntersects2 = bounds . intersectsBounds (
153- new SuperMap . Bounds ( 100 , - 90 , 100 , 80 ) ,
156+ new Bounds ( 100 , - 90 , 100 , 80 ) ,
154157 options2
155158 ) ;
156159 expect ( isIntersects1 ) . toBeTruthy ( ) ;
157160 expect ( isIntersects2 ) . toBeFalsy ( ) ;
158161 bounds . destroy ( ) ;
159162 } ) ;
160163
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 ) ) ;
164167 expect ( str ) . toEqual ( "tr" ) ;
165168 bounds . destroy ( ) ;
166169 } ) ;
167170
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 ) ;
170173 var obj = bounds . toServerJSONObject ( ) ;
171174 expect ( obj ) . not . toBeNull ( ) ;
172175 expect ( obj . bottom ) . toEqual ( - 90 ) ;
@@ -178,26 +181,26 @@ describe('Bounds', function () {
178181 bounds . destroy ( ) ;
179182 } ) ;
180183
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 ) ;
183186 expect ( bounds ) . not . toBeNull ( ) ;
184187 expect ( bounds . bottom ) . toEqual ( - 90 ) ;
185188 expect ( bounds . left ) . toEqual ( - 180 ) ;
186189 expect ( bounds . right ) . toEqual ( 100 ) ;
187190 expect ( bounds . top ) . toEqual ( 80 ) ;
188191 } ) ;
189192
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 ) ) ;
192195 expect ( bounds ) . not . toBeNull ( ) ;
193196 expect ( bounds . bottom ) . toEqual ( 10 ) ;
194197 expect ( bounds . left ) . toEqual ( 0 ) ;
195198 expect ( bounds . right ) . toEqual ( 20 ) ;
196199 expect ( bounds . top ) . toEqual ( 0 ) ;
197200 } ) ;
198201
199- it ( 'oppositeQuadrant' , function ( ) {
200- var oppositeQuadrant = SuperMap . Bounds . oppositeQuadrant ( "tl" ) ;
202+ it ( 'oppositeQuadrant' , ( ) => {
203+ var oppositeQuadrant = Bounds . oppositeQuadrant ( "tl" ) ;
201204 expect ( oppositeQuadrant ) . toEqual ( "br" ) ;
202205 } ) ;
203206} ) ;
0 commit comments