@@ -312,9 +312,9 @@ describe('mapboxgl_WebMapV2', () => {
312
312
originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
313
313
jasmine . DEFAULT_TIMEOUT_INTERVAL = 50000 ;
314
314
window . jsonsql = { query : ( ) => [ { } ] } ;
315
- spyOn ( Canvg , 'from' ) . and . callFake ( ( ctx , url , callback ) =>
316
- Promise . resolve ( { stop : jasmine . createSpy ( 'stop' ) , start : jasmine . createSpy ( 'start' ) } )
317
- ) ;
315
+ spyOn ( Canvg , 'from' ) . and . callFake ( ( ctx , url , callback ) =>
316
+ Promise . resolve ( { stop : jasmine . createSpy ( 'stop' ) , start : jasmine . createSpy ( 'start' ) } )
317
+ ) ;
318
318
window . geostats = class {
319
319
setSerie ( ) { }
320
320
} ;
@@ -2840,10 +2840,7 @@ describe('mapboxgl_WebMapV2', () => {
2840
2840
expect ( xyzLayer . id ) . toBe ( '2326底图' ) ;
2841
2841
expect ( xyzLayer . type ) . toBe ( 'raster' ) ;
2842
2842
expect ( sources [ '2326底图' ] . bounds ) . toEqual ( [
2843
- 113.77925526971052 ,
2844
- 22.086139328930617 ,
2845
- 114.53407583886273 ,
2846
- 22.61831019233164
2843
+ 113.77925526971052 , 22.086139328930617 , 114.53407583886273 , 22.61831019233164
2847
2844
] ) ;
2848
2845
done ( ) ;
2849
2846
} ) ;
@@ -3659,4 +3656,139 @@ describe('mapboxgl_WebMapV2', () => {
3659
3656
done ( ) ;
3660
3657
} ) ;
3661
3658
} ) ;
3659
+
3660
+ it ( 'overlay is TILE, baselayer is TILE bounds' , ( done ) => {
3661
+ const wkt4496 = `PROJCS["GK Zone 18 (CGCS2000)",GEOGCS["GCS_China_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101,AUTHORITY["EPSG","7044"]]],PRIMEM["Greenwich",0.0,AUTHORITY["EPSG","8901"]],UNIT["DEGREE",0.017453292519943295],AUTHORITY["EPSG","4490"]],PROJECTION["Transverse_Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["False_Easting",1.85E7],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",105.0],PARAMETER["Latitude_Of_Origin",0.0],PARAMETER["Scale_Factor",1.0],UNIT["METER",1.0],AUTHORITY["EPSG","4496"]]` ;
3662
+ spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
3663
+ if ( url . indexOf ( 'portal.json' ) > - 1 ) {
3664
+ return Promise . resolve ( new Response ( JSON . stringify ( iportal_serviceProxy ) ) ) ;
3665
+ }
3666
+ if ( url . indexOf ( '123/map.json' ) > - 1 ) {
3667
+ return Promise . resolve ( new Response ( JSON . stringify ( dynamicProjectionMapInfo ) ) ) ;
3668
+ }
3669
+ if ( url . indexOf ( `test.json?prjCoordSys=${ JSON . stringify ( { epsgCode : 4326 } ) } ` ) > - 1 ) {
3670
+ return Promise . resolve (
3671
+ new Response (
3672
+ JSON . stringify ( {
3673
+ prjCoordSys : { epsgCode : 4326 } ,
3674
+ bounds : {
3675
+ top : 2.3755571276430945 ,
3676
+ left : 113.5091647206238 ,
3677
+ bottom : 2.087888705520514 ,
3678
+ leftBottom : {
3679
+ x : 113.5091647206238 ,
3680
+ y : 2.087888705520514
3681
+ } ,
3682
+ right : 113.84235808224173 ,
3683
+ rightTop : {
3684
+ x : 113.84235808224173 ,
3685
+ y : 2.3755571276430945
3686
+ }
3687
+ }
3688
+ } )
3689
+ )
3690
+ ) ;
3691
+ }
3692
+ if ( url . indexOf ( `test.json` ) > - 1 ) {
3693
+ return Promise . resolve (
3694
+ new Response (
3695
+ JSON . stringify ( {
3696
+ prjCoordSys : { epsgCode : 4496 } ,
3697
+ bounds : {
3698
+ top : 262679.13362826034 ,
3699
+ left : 25493.744181281887 ,
3700
+ bottom : 230878.98887457885 ,
3701
+ leftBottom : {
3702
+ x : 25493.744181281887 ,
3703
+ y : 230878.98887457885
3704
+ } ,
3705
+ right : 62548.98751319852 ,
3706
+ rightTop : {
3707
+ x : 62548.98751319852 ,
3708
+ y : 262679.13362826034
3709
+ }
3710
+ }
3711
+ } )
3712
+ )
3713
+ ) ;
3714
+ }
3715
+ if ( url . indexOf ( `China_Dark.json` ) > - 1 ) {
3716
+ return Promise . resolve (
3717
+ new Response (
3718
+ JSON . stringify ( {
3719
+ prjCoordSys : { epsgCode : - 1 } ,
3720
+ bounds : {
3721
+ top : 20037508.342789087 ,
3722
+ left : - 20037508.342789248 ,
3723
+ bottom : - 25819498.513543323 ,
3724
+ leftBottom : {
3725
+ x : - 20037508.342789248 ,
3726
+ y : - 25819498.513543323
3727
+ } ,
3728
+ right : 20037508.342789244 ,
3729
+ rightTop : {
3730
+ x : 20037508.342789244 ,
3731
+ y : 20037508.342789087
3732
+ }
3733
+ }
3734
+ } )
3735
+ )
3736
+ ) ;
3737
+ }
3738
+ if ( url . indexOf ( `china.json` ) > - 1 ) {
3739
+ return Promise . resolve (
3740
+ new Response (
3741
+ JSON . stringify ( {
3742
+ prjCoordSys : { epsgCode : 3857 } ,
3743
+ bounds : {
3744
+ top : 5127400.782113583 ,
3745
+ left : 10607760.850223977 ,
3746
+ bottom : 2755785.4693220854 ,
3747
+ leftBottom : {
3748
+ x : 10607760.850223977 ,
3749
+ y : 2755785.4693220854
3750
+ } ,
3751
+ right : 12979376.163015474 ,
3752
+ rightTop : {
3753
+ x : 12979376.163015474 ,
3754
+ y : 5127400.782113583
3755
+ }
3756
+ }
3757
+ } )
3758
+ )
3759
+ ) ;
3760
+ }
3761
+ if ( url . indexOf ( 'prjCoordSys.wkt' ) ) {
3762
+ return Promise . resolve ( new Response ( wkt4496 ) ) ;
3763
+ }
3764
+ } ) ;
3765
+ datavizWebmap = new WebMap ( '123' , {
3766
+ target : 'map' ,
3767
+ serverUrl : 'http://fake/fakeiportal' ,
3768
+ withCredentials : false
3769
+ } ) ;
3770
+ datavizWebmap . on ( 'mapcreatesucceeded' , ( { map } ) => {
3771
+ const style = map . getStyle ( ) ;
3772
+ expect ( map . getStyle ( ) . layers . length ) . toBe ( 3 ) ;
3773
+ const expectedBaselayerBounds = [ - 180.00000000000006 , - 88 , 180.00000000000003 , 85.05112877980648 ] ;
3774
+ const actualBaselayerBounds = style . sources [ '中国暗色地图' ] . bounds ;
3775
+ expect ( actualBaselayerBounds . length ) . toBe ( expectedBaselayerBounds . length ) ;
3776
+ actualBaselayerBounds . forEach ( ( val , i ) => {
3777
+ expect ( val ) . toBeCloseTo ( expectedBaselayerBounds [ i ] , 6 ) ;
3778
+ } ) ;
3779
+ const expectedOverlayer1Bounds = [ 95.29113702040888 , 24.019508369205386 , 116.5957198557339 , 41.77544139596302 ] ;
3780
+ const actualOverlayer1Bounds = style . sources . china . bounds ;
3781
+ expect ( actualOverlayer1Bounds . length ) . toBe ( expectedOverlayer1Bounds . length ) ;
3782
+ actualOverlayer1Bounds . forEach ( ( val , i ) => {
3783
+ expect ( val ) . toBeCloseTo ( expectedOverlayer1Bounds [ i ] , 6 ) ;
3784
+ } ) ;
3785
+ const expectedOverlayer2Bounds = [ 113.5091647206238 , 2.087888705520514 , 113.84235808224173 , 2.3755571276430945 ] ;
3786
+ const actualOverlayer2Bounds = style . sources . test . bounds ;
3787
+ expect ( actualOverlayer2Bounds . length ) . toBe ( expectedOverlayer2Bounds . length ) ;
3788
+ actualOverlayer2Bounds . forEach ( ( val , i ) => {
3789
+ expect ( val ) . toBeCloseTo ( expectedOverlayer2Bounds [ i ] , 6 ) ;
3790
+ } ) ;
3791
+ done ( ) ;
3792
+ } ) ;
3793
+ } ) ;
3662
3794
} ) ;
0 commit comments