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 c748aac commit 2e05cf1d4e6f812dbc6df6270d80372272e9baeb
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 2e05cf1

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