Skip to content

Commit 2e05cf1

Browse files
committedFeb 28, 2019
Add topological points on layers with configured precision
The tolerance was hardcoded to 1mm before.
1 parent c748aac commit 2e05cf1

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed
 

‎src/core/qgsvectorlayereditutils.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "qgswkbtypes.h"
2626
#include "qgsvectorlayerutils.h"
2727
#include "qgsvectorlayer.h"
28+
#include "qgsgeometryoptions.h"
2829

2930
#include <limits>
3031

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

616617
//work with a tolerance because coordinate projection may introduce some rounding
617-
double threshold = 0.0000001;
618-
if ( mLayer->crs().mapUnits() == QgsUnitTypes::DistanceMeters )
619-
{
620-
threshold = 0.001;
621-
}
622-
else if ( mLayer->crs().mapUnits() == QgsUnitTypes::DistanceFeet )
618+
double threshold = mLayer->geometryOptions()->geometryPrecision();
619+
620+
if ( qgsDoubleNear( threshold, 0.0 ) )
623621
{
624-
threshold = 0.0001;
622+
threshold = 0.0000001;
623+
624+
if ( mLayer->crs().mapUnits() == QgsUnitTypes::DistanceMeters )
625+
{
626+
threshold = 0.001;
627+
}
628+
else if ( mLayer->crs().mapUnits() == QgsUnitTypes::DistanceFeet )
629+
{
630+
threshold = 0.0001;
631+
}
625632
}
626633

627634
QgsRectangle searchRect( p.x() - threshold, p.y() - threshold,

0 commit comments

Comments
 (0)
Please sign in to comment.