Skip to content
Permalink
Browse files

Add topological points on layers with configured precision

The tolerance was hardcoded to 1mm before.
  • Loading branch information
m-kuhn committed Feb 28, 2019
1 parent 8907d9c commit 0ed7a62695b66a9d24356fe021ffd4edc49a9b6b
Showing with 14 additions and 7 deletions.
  1. +14 −7 src/core/qgsvectorlayereditutils.cpp
@@ -25,6 +25,7 @@
#include "qgswkbtypes.h"
#include "qgsvectorlayerutils.h"
#include "qgsvectorlayer.h"
#include "qgsgeometryoptions.h"

#include <limits>

@@ -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,

0 comments on commit 0ed7a62

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