[QGIS Commit] r10935 - trunk/qgis/src/core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Tue Jun 16 00:41:18 EDT 2009
Author: mhugent
Date: 2009-06-16 00:41:18 -0400 (Tue, 16 Jun 2009)
New Revision: 10935
Modified:
trunk/qgis/src/core/qgsgeometry.cpp
Log:
Replace the hardcoded treshold in line splitting code and added more comment
Modified: trunk/qgis/src/core/qgsgeometry.cpp
===================================================================
--- trunk/qgis/src/core/qgsgeometry.cpp 2009-06-15 17:13:46 UTC (rev 10934)
+++ trunk/qgis/src/core/qgsgeometry.cpp 2009-06-16 04:41:18 UTC (rev 10935)
@@ -4794,9 +4794,12 @@
QVector<GEOSGeometry*> testedGeometries;
GEOSGeometry* intersectGeom = 0;
- //hardcoded thresholds
+ //Create a small buffer around the original geometry
+ //and intersect candidate line segments with the buffer.
+ //Then we use the ratio intersection length / segment length to
+ //decide if the line segment belongs to the original geometry or
+ //if it is part of the splitting line
double bufferDistance = 0.0000001;
- double intersectThreshold = 0.00001;
for ( int i = 0; i < GEOSGetNumGeometries( mergedLines ); i++ )
{
@@ -4804,8 +4807,14 @@
intersectGeom = GEOSIntersection( mGeos, GEOSBuffer( testing, bufferDistance, DEFAULT_QUADRANT_SEGMENTS ) );
double len;
GEOSLength( intersectGeom, &len );
- if ( len > intersectThreshold )
+ double testingLen;
+ GEOSLength( testing, &testingLen);
+ double ratio = len / testingLen;
+ //the ratios for geometries that belong to the original line are usually close to 1
+ if ( ratio >= 0.5 && ratio <= 1.5)
+ {
testedGeometries << GEOSGeom_clone( testing );
+ }
GEOSGeom_destroy( intersectGeom );
}
More information about the QGIS-commit
mailing list