Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "Fix snapping on segment when layer CRS is different from proj…
…ect CRS. Fixes #29648"

This reverts commit e11b21e.
  • Loading branch information
nyalldawson committed Mar 1, 2021
1 parent 22bad6e commit 1a1b9a9
Showing 1 changed file with 3 additions and 30 deletions.
33 changes: 3 additions & 30 deletions src/gui/qgsmaptoolcapture.cpp
Expand Up @@ -462,8 +462,8 @@ int QgsMapToolCapture::fetchLayerPoint( const QgsPointLocator::Match &match, Qgs
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
QgsVectorLayer *sourceLayer = match.layer();
if ( match.isValid() && ( match.hasVertex() || ( QgsProject::instance()->topologicalEditing() && ( match.hasEdge() || match.hasMiddleSegment() ) ) ) && sourceLayer )

if ( match.isValid() && ( match.hasVertex() || ( QgsProject::instance()->topologicalEditing() && ( match.hasEdge() || match.hasMiddleSegment() ) ) ) && sourceLayer &&
( sourceLayer->crs() == vlayer->crs() ) )
{
QgsFeature f;
QgsFeatureRequest request;
Expand All @@ -483,34 +483,7 @@ int QgsMapToolCapture::fetchLayerPoint( const QgsPointLocator::Match &match, Qgs
return 2;
QgsLineString line( geom.constGet()->vertexAt( vId ), geom.constGet()->vertexAt( vId2 ) );

QgsPoint pt( match.point() );
// Transform point to sourceLayer crs, since vId and vId2 coordinates are in sourceLayer crs
if ( sourceLayer->crs() != QgsProject::instance()->crs() )
{
try
{
pt.transform( QgsCoordinateTransform( QgsProject::instance()->crs(), sourceLayer->crs(), sourceLayer->transformContext() ) );
}
catch ( QgsCsException &cse )
{
Q_UNUSED( cse )
QgsDebugMsg( QStringLiteral( "transformation to layer coordinate failed" ) );
return 2;
}
}
layerPoint = QgsGeometryUtils::closestPoint( line, pt );
// (re)Transform layerPoint to vlayer crs
try
{
layerPoint.transform( QgsCoordinateTransform( sourceLayer->crs(), vlayer->crs(), vlayer->transformContext() ) );
}
catch ( QgsCsException &cse )
{
Q_UNUSED( cse )
QgsDebugMsg( QStringLiteral( "transformation to layer coordinate failed" ) );
return 2;
}

layerPoint = QgsGeometryUtils::closestPoint( line, QgsPoint( match.point() ) );
}
else
{
Expand Down

0 comments on commit 1a1b9a9

Please sign in to comment.