Skip to content
Permalink
Browse files

Replace the hardcoded treshold in line splitting code and added more …

…comment

git-svn-id: http://svn.osgeo.org/qgis/trunk@10935 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Jun 16, 2009
1 parent 1d9b648 commit 264d6e0a8ebc982b8dcc7adc0a66b911a900f5f9
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/core/qgsgeometry.cpp
@@ -4794,18 +4794,27 @@ int QgsGeometry::splitLinearGeometry( GEOSGeometry *splitLine, QList<QgsGeometry
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++ )
{
const GEOSGeometry *testing = GEOSGetGeometryN( mergedLines, i );
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 );
}

0 comments on commit 264d6e0

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