@@ -58,7 +58,9 @@ describe('#GeometryCollection', function () {
58
58
59
59
expect ( collection . getGeometries ( ) ) . to . be . empty ( ) ;
60
60
61
- var geometries = GEN_GEOMETRIES_OF_ALL_TYPES ( ) ;
61
+ var geometries = GEN_GEOMETRIES_OF_ALL_TYPES ( ) . filter ( geo => {
62
+ return ! ( geo instanceof maptalks . GeometryCollection ) ;
63
+ } )
62
64
collection . setGeometries ( geometries ) ;
63
65
64
66
expect ( collection . getGeometries ( ) ) . to . eql ( geometries ) ;
@@ -102,7 +104,7 @@ describe('#GeometryCollection', function () {
102
104
it ( 'normal constructor' , function ( ) {
103
105
var geometries = GEN_GEOMETRIES_OF_ALL_TYPES ( ) ;
104
106
var collection = new maptalks . GeometryCollection ( geometries ) ;
105
- expect ( collection . getGeometries ( ) ) . to . have . length ( geometries . length ) ;
107
+ expect ( collection . getGeometries ( ) . length ) . to . be . eql ( geometries . length - 2 ) ;
106
108
} ) ;
107
109
108
110
it ( 'can be empty.' , function ( ) {
@@ -350,6 +352,40 @@ describe('#GeometryCollection', function () {
350
352
} ) ;
351
353
} ) ;
352
354
355
+
356
+ it ( '#2141 Provide a prompt when GeometryCollection is nested within itself' , function ( ) {
357
+ const pointSymbol = {
358
+ markerType : 'ellipse' ,
359
+ markerWidth : 20 ,
360
+ markerHeight : 20
361
+ } ;
362
+ const lineSymbol = {
363
+ lineColor : 'black' ,
364
+ lineWidth : 4
365
+ } ;
366
+
367
+ const fillSymbol = {
368
+ polygonFill : "black" ,
369
+ polygonOpacity : 1
370
+ } ;
371
+ const lefttop = [ - 0.01 , 0.01 , 1 ] , righttop = [ 0.01 , 0.01 , 1 ] , rightbottom = [ 0.01 , - 0.01 , 1 ] , leftbottom = [ - 0.01 , - 0.01 , 1 ] ;
372
+ const point = new maptalks . Marker ( lefttop , { symbol : pointSymbol } ) ;
373
+ const multipoint = new maptalks . MultiPoint ( [ lefttop , lefttop ] , { symbol : pointSymbol } ) ;
374
+ const line = new maptalks . LineString ( [ lefttop , righttop ] , { symbol : lineSymbol } ) ;
375
+ const multiline = new maptalks . MultiLineString ( [ [ lefttop , righttop ] , [ lefttop , righttop ] ] , { symbol : lineSymbol } ) ;
376
+ const polygon = new maptalks . Polygon ( [ [ lefttop , righttop , rightbottom , leftbottom ] ] , { symbol : fillSymbol } ) ;
377
+ const multipolygon = new maptalks . MultiPolygon ( [ [ [ lefttop , righttop , rightbottom , leftbottom ] ] , [ [ lefttop , righttop , rightbottom , leftbottom ] ] ] , { symbol : fillSymbol } ) ;
378
+ const rectange = new maptalks . Rectangle ( lefttop , 2000 , 1000 , { symbol : fillSymbol } ) ;
379
+ const ellispe = new maptalks . Ellipse ( lefttop , 2000 , 1000 , { symbol : fillSymbol } ) ;
380
+ const sector = new maptalks . Sector ( lefttop , 1000 , 0 , 90 , { symbol : fillSymbol } ) ;
381
+ const circle = new maptalks . Circle ( lefttop , 1000 , { symbol : fillSymbol } ) ;
382
+ const collectionTest = new maptalks . GeometryCollection ( [ ] ) ;
383
+ const geos = [ point , multipoint , line , multiline , polygon , multipolygon , circle , rectange , ellispe , sector , collectionTest ] ;
384
+
385
+ const collection = new maptalks . GeometryCollection ( geos ) ;
386
+ expect ( collection . getGeometries ( ) . length ) . to . be . eql ( 7 ) ;
387
+ } ) ;
388
+
353
389
it ( '#2146 _toJSON(null) from feature-filter' , function ( ) {
354
390
const geojson = {
355
391
"type" : "FeatureCollection" ,
@@ -447,7 +483,6 @@ describe('#GeometryCollection', function () {
447
483
} )
448
484
layer . addGeometry ( polygons )
449
485
} ) ;
450
-
451
486
} ) ;
452
487
453
488
function genPoints ( ) {
0 commit comments