[QGIS Commit] r9712 - trunk/qgis/src/core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Thu Nov 27 09:05:12 EST 2008
Author: mhugent
Date: 2008-11-27 09:05:12 -0500 (Thu, 27 Nov 2008)
New Revision: 9712
Modified:
trunk/qgis/src/core/qgsgeometry.cpp
trunk/qgis/src/core/qgsgeometry.h
Log:
Fix for bug #1424, split feature segfault
Modified: trunk/qgis/src/core/qgsgeometry.cpp
===================================================================
--- trunk/qgis/src/core/qgsgeometry.cpp 2008-11-26 11:01:03 UTC (rev 9711)
+++ trunk/qgis/src/core/qgsgeometry.cpp 2008-11-27 14:05:12 UTC (rev 9712)
@@ -4864,7 +4864,7 @@
//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 @@
}
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 @@
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 )
Modified: trunk/qgis/src/core/qgsgeometry.h
===================================================================
--- trunk/qgis/src/core/qgsgeometry.h 2008-11-26 11:01:03 UTC (rev 9711)
+++ trunk/qgis/src/core/qgsgeometry.h 2008-11-27 14:05:12 UTC (rev 9712)
@@ -417,6 +417,9 @@
@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 */
More information about the QGIS-commit
mailing list