Skip to content

Commit

Permalink
Add topological points on layers with configured precision
Browse files Browse the repository at this point in the history
The tolerance was hardcoded to 1mm before.
  • Loading branch information
m-kuhn committed Mar 18, 2019
1 parent 8907d9c commit 0ed7a62
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 0ed7a62

Please sign in to comment.