Skip to content
Permalink
Browse files
Fix for bug #1424, split feature segfault
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9712 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Nov 27, 2008
1 parent 630ddb7 commit f5c8c4ec449f13c2065290b2012136da2c376de9
Showing with 22 additions and 2 deletions.
  1. +19 −2 src/core/qgsgeometry.cpp
  2. +3 −0 src/core/qgsgeometry.h
@@ -4864,7 +4864,7 @@ int QgsGeometry::splitPolygonGeometry( GEOSGeometry* splitLine, QList<QgsGeometr
//ratio intersect geometry / geometry. This should be close to 1
//if the polygon belongs to the input geometry

for ( int i = 0; i < GEOSGetNumGeometries( polygons ); i++ )
for ( int i = 0; i < getNumberOfGeometries( polygons ); i++ )
{
const GEOSGeometry *polygon = GEOSGetGeometryN( polygons, i );
intersectGeometry = GEOSIntersection( mGeos, polygon );
@@ -4883,7 +4883,7 @@ int QgsGeometry::splitPolygonGeometry( GEOSGeometry* splitLine, QList<QgsGeometr
}

bool splitDone = true;
int nGeometriesThis = GEOSGetNumGeometries( mGeos ); //original number of geometries
int nGeometriesThis = getNumberOfGeometries( mGeos ); //original number of geometries
if ( testedGeometries.size() == nGeometriesThis )
{
splitDone = false;
@@ -5003,6 +5003,23 @@ GEOSGeometry *QgsGeometry::nodeGeometries( const GEOSGeometry *splitLine, GEOSGe
return unionGeometry;
}

int QgsGeometry::getNumberOfGeometries(GEOSGeometry* g) const
{
if(!g)
{
return 0;
}
int geometryType = GEOSGeomTypeId(g);
if(geometryType == GEOS_POINT || geometryType == GEOS_LINESTRING || geometryType == GEOS_LINEARRING
|| geometryType == GEOS_POLYGON)
{
return 1;
}

//calling GEOSGetNumGeometries is save for multi types and collections also in geos2
return GEOSGetNumGeometries(g);
}

int QgsGeometry::mergeGeometriesMultiTypeSplit( QVector<GEOSGeometry*>& splitResult )
{
if ( !mGeos || mDirtyGeos )
@@ -417,6 +417,9 @@ class CORE_EXPORT QgsGeometry
@return the noded multiline geometry or 0 in case of error. The calling function takes ownership of the node geometry*/
GEOSGeometry* nodeGeometries( const GEOSGeometry *splitLine, GEOSGeometry *poly ) const;

/**Returns number of single geometry in a geos geometry. Is save for geos 2 and 3*/
int getNumberOfGeometries(GEOSGeometry* g) const;

int mergeGeometriesMultiTypeSplit( QVector<GEOSGeometry*>& splitResult );

/** return point from wkb */

0 comments on commit f5c8c4e

Please sign in to comment.