Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Replace the hardcoded treshold in line splitting code and added more …
…comment

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10935 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jun 16, 2009
1 parent 097694b commit e79c0e4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/core/qgsgeometry.cpp
Expand Up @@ -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 );
}

Expand Down

0 comments on commit e79c0e4

Please sign in to comment.