Skip to content

Commit

Permalink
Merge pull request #9307 from m-kuhn/avoid-intersection-use-geometry-…
Browse files Browse the repository at this point in the history
…precision

Add topological points on layers with configured precision
  • Loading branch information
m-kuhn committed Mar 2, 2019
2 parents 252791e + 2e05cf1 commit c267992
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/core/qgsvectorlayereditutils.cpp
Expand Up @@ -25,6 +25,7 @@
#include "qgswkbtypes.h"
#include "qgsvectorlayerutils.h"
#include "qgsvectorlayer.h"
#include "qgsgeometryoptions.h"

#include <limits>

Expand Down Expand Up @@ -614,14 +615,20 @@ int QgsVectorLayerEditUtils::addTopologicalPoints( const QgsPointXY &p )
double segmentSearchEpsilon = mLayer->crs().isGeographic() ? 1e-12 : 1e-8;

//work with a tolerance because coordinate projection may introduce some rounding
double threshold = 0.0000001;
if ( mLayer->crs().mapUnits() == QgsUnitTypes::DistanceMeters )
{
threshold = 0.001;
}
else if ( mLayer->crs().mapUnits() == QgsUnitTypes::DistanceFeet )
double threshold = mLayer->geometryOptions()->geometryPrecision();

if ( qgsDoubleNear( threshold, 0.0 ) )
{
threshold = 0.0001;
threshold = 0.0000001;

if ( mLayer->crs().mapUnits() == QgsUnitTypes::DistanceMeters )
{
threshold = 0.001;
}
else if ( mLayer->crs().mapUnits() == QgsUnitTypes::DistanceFeet )
{
threshold = 0.0001;
}
}

QgsRectangle searchRect( p.x() - threshold, p.y() - threshold,
Expand Down

0 comments on commit c267992

Please sign in to comment.