File tree Expand file tree Collapse file tree
src/main/groovy/geoscript/geom Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,9 +118,13 @@ class MultiPolygon extends GeometryCollection {
118118 * Create a JTS MultiPolygon from a List of Polygons
119119 */
120120 private static create (Polygon ... polygons ) {
121- Geometry . factory. createMultiPolygon(polygons. collect{
121+ if (polygons. size() == 0 ) {
122+ Geometry . factory. createMultiPolygon()
123+ } else {
124+ Geometry . factory. createMultiPolygon(polygons. collect {
122125 polygon -> polygon. g
123126 }. toArray() as JtsPolygon [])
127+ }
124128 }
125129
126130 /**
@@ -133,17 +137,21 @@ class MultiPolygon extends GeometryCollection {
133137 if (p. size() > 0 ) {
134138 create(* p)
135139 } else {
136- create( new Polygon () )
140+ Geometry . factory . createMultiPolygon( )
137141 }
138142 }
139143
140144 /**
141145 * Create a JTS MultiPolygon from a List of Polygons or a List of List of Doubles
142146 */
143147 private static create (List polygons ) {
144- List<Polygon > p = polygons. collect{poly ->
145- (poly instanceof Polygon ) ? poly : new Polygon (poly)
148+ if (polygons. isEmpty()) {
149+ Geometry . factory. createMultiPolygon()
150+ } else {
151+ List<Polygon > p = polygons. collect { poly ->
152+ (poly instanceof Polygon ) ? poly : new Polygon (poly)
153+ }
154+ create(* p)
146155 }
147- create(* p)
148156 }
149157}
You can’t perform that action at this time.
0 commit comments