@@ -9,90 +9,56 @@ import {
9
9
var url = GlobeParameter . imageURL ;
10
10
describe ( 'openlayers_TileSuperMapRest' , ( ) => {
11
11
var originalTimeout ;
12
- var testDiv , map , tileOptions , tileSource ;
13
- beforeAll ( ( ) => {
14
- testDiv = document . createElement ( "div" ) ;
15
- testDiv . setAttribute ( "id" , "map" ) ;
16
- testDiv . style . styleFloat = "left" ;
17
- testDiv . style . marginLeft = "8px" ;
18
- testDiv . style . marginTop = "50px" ;
19
- testDiv . style . width = "500px" ;
20
- testDiv . style . height = "500px" ;
21
- document . body . appendChild ( testDiv ) ;
22
- //只测了serverType为iserver得情况
23
- new MapService ( url ) . getMapInfo ( ( serviceResult ) => {
24
- map = new ol . Map ( {
25
- target : 'map' ,
26
- view : new ol . View ( {
27
- center : [ 12957388 , 4853991 ] ,
28
- zoom : 11
29
- } )
30
- } ) ;
31
- tileOptions = TileSuperMapRest . optionsFromMapJSON ( url , serviceResult . result ) ;
32
- tileSource = new TileSuperMapRest ( tileOptions ) ;
33
- var imageLayer = new ol . layer . Tile ( {
34
- source : tileSource
35
- } ) ;
36
- map . addLayer ( imageLayer ) ;
37
- } ) ;
38
- } ) ;
39
12
beforeEach ( ( ) => {
40
13
originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
41
14
jasmine . DEFAULT_TIMEOUT_INTERVAL = 50000 ;
42
15
} ) ;
43
16
afterEach ( ( ) => {
44
17
jasmine . DEFAULT_TIMEOUT_INTERVAL = originalTimeout ;
45
18
} ) ;
46
- afterAll ( ( ) => {
47
- document . body . removeChild ( testDiv ) ;
48
- } ) ;
49
19
50
- it ( 'initialize' , ( done ) => {
51
- setTimeout ( ( ) => {
52
- try {
53
- expect ( tileOptions ) . not . toBeNull ( ) ;
54
- expect ( tileOptions . serverType ) . toBe ( "ISERVER" ) ;
55
- expect ( tileOptions . crossOrigin ) . toBe ( "anonymous" ) ;
56
- expect ( tileSource ) . not . toBeNull ( ) ;
57
- expect ( tileSource . urls . length ) . toBe ( 1 ) ;
58
- done ( ) ;
59
- } catch ( exception ) {
60
- console . log ( "'initialize'案例失败:" + exception . name + ":" + exception . message ) ;
61
- expect ( false ) . toBeTruthy ( ) ;
62
- done ( ) ;
20
+ it ( 'initialize' , ( ) => {
21
+ var tileOptions = {
22
+ url : url ,
23
+ prjCoordSys : {
24
+ "epsgCode" : 4326
63
25
}
64
- } , 6000 ) ;
65
-
26
+ } ;
27
+ var tileSource = new TileSuperMapRest ( tileOptions ) ;
28
+ expect ( tileSource . options ) . not . toBeNull ( ) ;
29
+ expect ( tileSource . options . serverType ) . toBe ( "ISERVER" ) ;
30
+ expect ( tileSource . urls . length ) . toBe ( 1 ) ;
66
31
} ) ;
67
32
68
33
it ( 'tileUrlFunction' , ( ) => {
69
34
var tempOptions = {
35
+ url : url ,
70
36
extent : [ 0 , 0 , 90 , 90 ] ,
71
37
prjCoordSys : {
72
38
"epsgCode" : 4326
73
39
}
74
40
} ;
41
+ var tileSourcetile = new TileSuperMapRest ( tempOptions ) ;
75
42
var pixelRatio = "245" ;
76
43
var coords = new ol . geom . Point ( 120.14 , 30.24 ) ;
77
- var tileUrl = tileSource . tileUrlFunction ( coords , pixelRatio , ol . proj . get ( "EPSG:4326" ) ) ;
44
+ var tileUrl = tileSourcetile . tileUrlFunction ( coords , pixelRatio , ol . proj . get ( "EPSG:4326" ) ) ;
78
45
expect ( tileUrl ) . not . toBeNull ( ) ;
79
- expect ( tileSource . getTileGrid ( ) . getTileSize ( ) ) . toEqual ( 256 ) ;
80
- expect ( tileSource . getTileGrid ( ) . getResolution ( 0 ) ) . toEqual ( 90.0 / 256 ) ;
46
+ expect ( tileSourcetile . getTileGrid ( ) . getTileSize ( ) ) . toEqual ( 256 ) ;
47
+ expect ( tileSourcetile . getTileGrid ( ) . getResolution ( 0 ) ) . toEqual ( 90.0 / 256 ) ;
81
48
} ) ;
82
49
83
50
it ( 'tileUrlFunction_tilePoxy' , ( ) => {
84
- tileOptions . tileProxy = "tileProxy" ;
85
- var tileSourcetilePoxy = new TileSuperMapRest ( tileOptions ) ;
86
- var tempOptions = {
87
- redirect : true ,
51
+ var tileOptions = {
52
+ url : url ,
88
53
prjCoordSys : {
89
54
"epsgCode" : 4326
90
- }
55
+ } ,
56
+ tileProxy : "tileProxy"
91
57
} ;
58
+ var tileSourcetilePoxy = new TileSuperMapRest ( tileOptions ) ;
92
59
var pixelRatio = "245" ;
93
60
var coords = new ol . geom . Point ( 120.14 , 30.24 ) ;
94
61
var tileUrl = tileSourcetilePoxy . tileUrlFunction ( coords , pixelRatio , ol . proj . get ( "EPSG:4326" ) ) ;
95
- // expect(tileUrl).toBe("tileProxyhttp%3A%2F%2Flocalhost%3A8090%2Fiserver%2Fservices%2Fmap-world%2Frest%2Fmaps%2F%25E4%25B8%2596%25E7%2595%258C%25E5%259C%25B0%25E5%259B%25BE_Day%2Fimage.png%3F%26transparent%3Dtrue%26cacheEnabled%3Dfalse%26width%3D256%26height%3D256%26viewBounds%3D%257B%2522leftBottom%2522%2520%3A%2520%257B%2522x%2522%3ANaN%2C%2522y%2522%3ANaN%257D%2C%2522rightTop%2522%2520%3A%2520%257B%2522x%2522%3ANaN%2C%2522y%2522%3ANaN%257D%257D");
96
62
expect ( tileUrl ) . not . toBeNull ( ) ;
97
63
} ) ;
98
64
0 commit comments