Skip to content
Permalink
Browse files

also handle ringless polygons with GEOS <3.3 (follows 6370153)

  • Loading branch information
jef-n committed Jun 15, 2013
1 parent 07ea0aa commit 9f3a87911617cbf2a8ac4c85c12348d70240e2ab
Showing with 18 additions and 5 deletions.
  1. +18 −5 src/core/qgsgeometry.cpp
@@ -353,24 +353,37 @@ static GEOSGeometry *createGeosLinearRing( const QgsPolyline& polyline )

static GEOSGeometry *createGeosPolygon( const QVector<GEOSGeometry*> &rings )
{
if ( rings.size() < 1 )
GEOSGeometry *shell;

if ( rings.size() == 0 )
{
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
return GEOSGeom_createEmptyPolygon();
#else
shell = GEOSGeom_createLinearRing( GEOSCoordSeq_create( 0, 2 ) );
#endif
}
GEOSGeometry *shell = rings[0];
else
{
shell = rings[0];
}

GEOSGeometry **holes = NULL;
int nHoles = 0;

if ( rings.size() > 1 )
{
holes = new GEOSGeometry*[ rings.size()-1 ];
nHoles = rings.size() - 1;
holes = new GEOSGeometry*[ nHoles ];
if ( !holes )
return 0;

for ( int i = 0; i < rings.size() - 1; i++ )
for ( int i = 0; i < nHoles; i++ )
holes[i] = rings[i+1];
}

GEOSGeometry *geom = GEOSGeom_createPolygon( shell, holes, rings.size() - 1 );
GEOSGeometry *geom = GEOSGeom_createPolygon( shell, holes, nHoles );

if ( holes )
delete [] holes;

0 comments on commit 9f3a879

Please sign in to comment.
You can’t perform that action at this time.