File tree 1 file changed +18
-5
lines changed
1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -353,24 +353,37 @@ static GEOSGeometry *createGeosLinearRing( const QgsPolyline& polyline )
353
353
354
354
static GEOSGeometry *createGeosPolygon ( const QVector<GEOSGeometry*> &rings )
355
355
{
356
- if ( rings.size () < 1 )
356
+ GEOSGeometry *shell;
357
+
358
+ if ( rings.size () == 0 )
357
359
{
360
+ #if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
361
+ ((GEOS_VERSION_MAJOR>3 ) || ((GEOS_VERSION_MAJOR==3 ) && (GEOS_VERSION_MINOR>=3 )))
358
362
return GEOSGeom_createEmptyPolygon ();
363
+ #else
364
+ shell = GEOSGeom_createLinearRing ( GEOSCoordSeq_create ( 0 , 2 ) );
365
+ #endif
359
366
}
360
- GEOSGeometry *shell = rings[0 ];
367
+ else
368
+ {
369
+ shell = rings[0 ];
370
+ }
371
+
361
372
GEOSGeometry **holes = NULL ;
373
+ int nHoles = 0 ;
362
374
363
375
if ( rings.size () > 1 )
364
376
{
365
- holes = new GEOSGeometry*[ rings.size ()-1 ];
377
+ nHoles = rings.size () - 1 ;
378
+ holes = new GEOSGeometry*[ nHoles ];
366
379
if ( !holes )
367
380
return 0 ;
368
381
369
- for ( int i = 0 ; i < rings. size () - 1 ; i++ )
382
+ for ( int i = 0 ; i < nHoles ; i++ )
370
383
holes[i] = rings[i+1 ];
371
384
}
372
385
373
- GEOSGeometry *geom = GEOSGeom_createPolygon ( shell, holes, rings. size () - 1 );
386
+ GEOSGeometry *geom = GEOSGeom_createPolygon ( shell, holes, nHoles );
374
387
375
388
if ( holes )
376
389
delete [] holes;
You can’t perform that action at this time.
0 commit comments