@@ -2,12 +2,12 @@ require('../../../src/openlayers/core/StyleUtils.js');
22require ( '../../resources/china_cartoCSS.js' ) ;
33require ( '../../resources/china_layers.js' ) ;
44require ( '../../resources/iPortal_maps.js' ) ;
5- var fetch = require ( 'whatwg-fetch-importable' ) ;
5+ var fetch = require ( 'whatwg-fetch-importable' ) ;
66
77var StyleUtils = ol . supermap . StyleUtils ;
88var layersInfo , cartoCSSShaders , iPortalLayersInfo ;
99var mapUrl = GlobeParameter . ChinaURL ;
10- describe ( 'openlayers_testStyleUtils ' , function ( ) {
10+ describe ( 'openlayers_StyleUtils ' , function ( ) {
1111 var originalTimeout ;
1212 beforeEach ( function ( ) {
1313 originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
@@ -36,14 +36,11 @@ describe('openlayers_testStyleUtils', function () {
3636 expect ( style . getStroke ( ) ) . toBeNull ( ) ;
3737 expect ( style . getText ( ) ) . toBeNull ( ) ;
3838 expect ( style . getFill ( ) ) . toBeNull ( ) ;
39-
4039 var imageStyle = style . getImage ( ) ;
4140 expect ( imageStyle ) . not . toBeNull ( ) ;
4241 expect ( imageStyle . getOpacity ( ) ) . toBe ( 1 ) ;
43-
4442 expect ( imageStyle . getSrc ( ) ) . not . toBeNull ( ) ;
4543 expect ( imageStyle . getImage ( imageStyle . getSrc ( ) ) ) . not . toBeNull ( ) ;
46-
4744 done ( ) ;
4845 } catch ( exception ) {
4946 console . error ( "openlayers_StyleUtils': getValidStyleFromLayerInfo_point'案例失败:" + exception . name + ":" + exception . message ) ;
@@ -65,7 +62,6 @@ describe('openlayers_testStyleUtils', function () {
6562 var style = StyleUtils . getValidStyleFromLayerInfo ( layerInfo , feature , mapUrl ) ;
6663 expect ( style ) . not . toBeNull ( ) ;
6764 expect ( style . getFill ( ) ) . toBeNull ( ) ;
68-
6965 var strokeStyle = style . getStroke ( ) ;
7066 expect ( strokeStyle ) . not . toBeNull ( ) ;
7167 expect ( strokeStyle . getColor ( ) ) . toBe ( 'rgba(0,128,0,1)' ) ;
@@ -99,7 +95,6 @@ describe('openlayers_testStyleUtils', function () {
9995 expect ( style . getFill ( ) ) . not . toBeNull ( ) ;
10096 //此处由于StyleUtils内部处理fillSymbolID有一个缺陷,故不判断具体值
10197 expect ( style . getFill ( ) . getColor ( ) ) . not . toBeNull ( ) ;
102-
10398 var strokeStyle = style . getStroke ( ) ;
10499 expect ( strokeStyle ) . not . toBeNull ( ) ;
105100 expect ( strokeStyle . getColor ( ) ) . toBe ( 'rgba(110,84,90,1)' ) ;
@@ -157,7 +152,6 @@ describe('openlayers_testStyleUtils', function () {
157152 var feature = getFeature ( layerName , features ) ;
158153 var style = StyleUtils . getValidStyleFromLayerInfo ( layerInfo , feature , mapUrl ) ;
159154 expect ( style ) . not . toBeNull ( ) ;
160-
161155 var textStyle = style . getText ( ) ;
162156 expect ( textStyle ) . not . toBeNull ( ) ;
163157 expect ( textStyle . getText ( ) ) . toBe ( "太平洋" ) ;
@@ -187,15 +181,12 @@ describe('openlayers_testStyleUtils', function () {
187181 var shader = getShader ( layerName ) ;
188182 var style = StyleUtils . getStyleFromCarto ( 10 , 8.653637486605572e-7 , shader , feature , true , mapUrl ) ;
189183 expect ( style ) . not . toBeNull ( ) ;
190-
191184 expect ( style . getStroke ( ) ) . toBeNull ( ) ;
192185 expect ( style . getText ( ) ) . toBeNull ( ) ;
193186 expect ( style . getFill ( ) ) . toBeNull ( ) ;
194-
195187 var imageStyle = style . getImage ( ) ;
196188 expect ( imageStyle ) . not . toBeNull ( ) ;
197189 expect ( imageStyle . getOpacity ( ) ) . toBe ( 1 ) ;
198-
199190 expect ( imageStyle . getSrc ( ) ) . not . toBeNull ( ) ;
200191 expect ( imageStyle . getImage ( imageStyle . getSrc ( ) ) ) . not . toBeNull ( ) ;
201192 done ( ) ;
@@ -221,11 +212,9 @@ describe('openlayers_testStyleUtils', function () {
221212 expect ( style . getStroke ( ) ) . toBeNull ( ) ;
222213 expect ( style . getText ( ) ) . toBeNull ( ) ;
223214 expect ( style . getFill ( ) ) . toBeNull ( ) ;
224-
225215 var imageStyle = style . getImage ( ) ;
226216 expect ( imageStyle ) . not . toBeNull ( ) ;
227217 expect ( imageStyle . getOpacity ( ) ) . toBe ( 1 ) ;
228-
229218 expect ( imageStyle . getSrc ( ) ) . not . toBeNull ( ) ;
230219 expect ( imageStyle . getImage ( imageStyle . getSrc ( ) ) ) . not . toBeNull ( ) ;
231220 done ( ) ;
@@ -249,7 +238,6 @@ describe('openlayers_testStyleUtils', function () {
249238 var style = StyleUtils . getStyleFromCarto ( 10 , 8.653637486605572e-7 , shader , feature , true , mapUrl ) ;
250239 expect ( style ) . not . toBeNull ( ) ;
251240 expect ( style . getFill ( ) ) . toBeNull ( ) ;
252-
253241 var strokeStyle = style . getStroke ( ) ;
254242 expect ( strokeStyle ) . not . toBeNull ( ) ;
255243 expect ( strokeStyle . getColor ( ) ) . toBe ( 'rgba(0,0,0,0)' ) ;
@@ -280,7 +268,6 @@ describe('openlayers_testStyleUtils', function () {
280268 expect ( style ) . not . toBeNull ( ) ;
281269 expect ( style . getFill ( ) ) . not . toBeNull ( ) ;
282270 expect ( style . getFill ( ) . getColor ( ) ) . toBe ( 'rgba(145, 185, 234, 1)' ) ;
283-
284271 var strokeStyle = style . getStroke ( ) ;
285272 expect ( strokeStyle ) . not . toBeNull ( ) ;
286273 expect ( strokeStyle . getColor ( ) ) . toBe ( 'rgba(0, 0, 0, 0)' ) ;
@@ -312,29 +299,24 @@ describe('openlayers_testStyleUtils', function () {
312299 expect ( style . getStroke ( ) ) . toBeNull ( ) ;
313300 expect ( style . getText ( ) ) . toBeNull ( ) ;
314301 expect ( style . getFill ( ) ) . toBeNull ( ) ;
315-
316302 var imageStyle = style . getImage ( ) ;
317303 expect ( imageStyle ) . not . toBeNull ( ) ;
318304 expect ( imageStyle . getOpacity ( ) ) . toBe ( 1 ) ;
319305 expect ( imageStyle . getRadius ( ) ) . toBe ( 3 ) ;
320306 expect ( imageStyle . getPoints ( ) ) . toBePositiveInfinity ( ) ;
321307 expect ( imageStyle . getImage ( ) ) . not . toBeNull ( ) ;
322-
323308 var size = imageStyle . getSize ( ) ;
324309 expect ( size ) . not . toBeNull ( ) ;
325310 expect ( size [ 0 ] ) . toBe ( 9 ) ;
326311 expect ( size [ 1 ] ) . toBe ( 9 ) ;
327-
328312 var anchor = imageStyle . getAnchor ( ) ;
329313 expect ( anchor ) . not . toBeNull ( ) ;
330314 expect ( anchor [ 0 ] ) . toBe ( 4.5 ) ;
331315 expect ( anchor [ 1 ] ) . toBe ( 4.5 ) ;
332-
333316 var stroke = imageStyle . getStroke ( ) ;
334317 expect ( stroke ) . not . toBeNull ( ) ;
335318 expect ( stroke . getColor ( ) ) . toBe ( "#c33" ) ;
336319 expect ( stroke . getWidth ( ) ) . toBe ( 1 ) ;
337-
338320 var fill = imageStyle . getFill ( ) ;
339321 expect ( fill . getColor ( ) ) . toBe ( "#fc0" ) ;
340322 done ( ) ;
@@ -357,25 +339,22 @@ describe('openlayers_testStyleUtils', function () {
357339 var iPortalStyle = iPortalLayersInfo [ key ] [ 2 ] . style ;
358340 var style = StyleUtils . getStyleFromiPortalStyle ( iPortalStyle , feature . getGeometry ( ) . getType ( ) , feature . getProperties ( ) . style ) ;
359341 expect ( style ) . not . toBeNull ( ) ;
360-
361342 expect ( style . getStroke ( ) ) . toBeNull ( ) ;
362343 expect ( style . getText ( ) ) . toBeNull ( ) ;
363344 expect ( style . getFill ( ) ) . toBeNull ( ) ;
364-
365345 var imageStyle = style . getImage ( ) ;
366346 expect ( imageStyle ) . not . toBeNull ( ) ;
367347 expect ( imageStyle . getOpacity ( ) ) . toBe ( 1 ) ;
368-
369348 expect ( imageStyle . getSrc ( ) ) . not . toBeNull ( ) ;
370349 expect ( imageStyle . getImage ( imageStyle . getSrc ( ) ) ) . not . toBeNull ( ) ;
371-
372350 done ( ) ;
373351 } catch ( exception ) {
374352 console . error ( "openlayers_StyleUtils': getStyleFromiPortalStyle_point'案例失败:" + exception . name + ":" + exception . message ) ;
375353 expect ( false ) . toBeTruthy ( ) ;
376354 done ( ) ;
377355 }
378356 } ) ;
357+
379358 //测试从iPortalLayers中获取style
380359 it ( 'getStyleFromiPortalStyle_polyLine' , function ( done ) {
381360 var key = 'iPortalMaps47' ;
@@ -387,15 +366,12 @@ describe('openlayers_testStyleUtils', function () {
387366 var iPortalStyle = iPortalLayersInfo [ key ] [ 3 ] . style ;
388367 var style = StyleUtils . getStyleFromiPortalStyle ( iPortalStyle , feature . getGeometry ( ) . getType ( ) , feature . getProperties ( ) . style ) ;
389368 expect ( style ) . not . toBeNull ( ) ;
390-
391369 expect ( style . getText ( ) ) . toBeNull ( ) ;
392370 expect ( style . getFill ( ) ) . toBeNull ( ) ;
393-
394371 var strokeStyle = style . getStroke ( ) ;
395372 expect ( strokeStyle ) . not . toBeNull ( ) ;
396373 expect ( strokeStyle . getColor ( ) ) . toBe ( 'rgba(52,219,103,1)' ) ;
397374 expect ( strokeStyle . getWidth ( ) ) . toBe ( 4 ) ;
398-
399375 var lineDash = strokeStyle . getLineDash ( ) ;
400376 expect ( lineDash ) . not . toBeNull ( ) ;
401377 expect ( lineDash [ 0 ] ) . toBe ( 16 ) ;
@@ -407,8 +383,8 @@ describe('openlayers_testStyleUtils', function () {
407383 done ( ) ;
408384 }
409385 } ) ;
410-
411386} ) ;
387+
412388function initLayersInfo ( ) {
413389 var layersInfo = { } ;
414390 var layers = ChinaLayersInfo . subLayers . layers ;
@@ -458,7 +434,6 @@ function getLayerInfo(layerName) {
458434 if ( layersInfo === undefined ) {
459435 return null ;
460436 }
461-
462437 var layerInfo = layersInfo [ layerName ] ;
463438 if ( ! layerInfo ) return null ;
464439 var layerInfo_simple = { layerIndex : layerInfo . layerIndex , ugcLayerType : layerInfo . ugcLayerType } ;
@@ -504,7 +479,6 @@ function getShader(layerName) {
504479//请求tileFeature获取测试用ol feature对象
505480function requestFeature ( url ) {
506481 var tileFormat = new ol . format . GeoJSON ( ) ;
507-
508482 return fetch ( url , { method : 'GET' , timeout : 10000 } )
509483 . then ( function ( response ) {
510484 return response . json ( ) ;
0 commit comments