Skip to content

Commit

Permalink
Fix Z interpolation & test
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannQDQ authored and lbartoletti committed Dec 20, 2024
1 parent 33b38b2 commit 61a27e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 13 additions & 3 deletions src/app/qgsmaptooltrimextendfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,20 @@ void QgsMapToolTrimExtendFeature::canvasMoveEvent( QgsMapMouseEvent *e )
if ( !getPoints( match, pExtend1, pExtend2 ) )
break;

QgsPoint pLimit1Projected, pLimit2Projected;
QgsCoordinateTransform transform( mLimitLayer->crs(), mVlayer->crs(), mCanvas->mapSettings().transformContext() );
pLimit1Projected = QgsPoint( transform.transform( pLimit1 ) );
pLimit2Projected = QgsPoint( transform.transform( pLimit2 ) );

QgsPoint pLimit1Projected( pLimit1 );
QgsPoint pLimit2Projected( pLimit2 );
if ( !transform.isShortCircuited() )
{
const QgsPointXY transformedP1 = transform.transform( pLimit1 );
const QgsPointXY transformedP2 = transform.transform( pLimit2 );
pLimit1Projected.setX( transformedP1.x() );
pLimit1Projected.setY( transformedP1.y() );
pLimit2Projected.setX( transformedP2.x() );
pLimit2Projected.setY( transformedP2.y() );
}

// No need to trim/extend if segments are continuous
if ( ( ( pLimit1Projected == pExtend1 ) || ( pLimit1Projected == pExtend2 ) ) || ( ( pLimit2Projected == pExtend1 ) || ( pLimit2Projected == pExtend2 ) ) )
break;
Expand Down
4 changes: 2 additions & 2 deletions tests/src/app/testqgsmaptooltrimextendfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class TestQgsMapToolTrimExtendFeature : public QObject
// | \| |
// | + (2,1) |
// (0,0) +-------------------+ (3,0)
vlPolygon.reset( new QgsVectorLayer( QStringLiteral( "MultiPolygon?field=fld:int" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ) );
vlPolygon.reset( new QgsVectorLayer( QStringLiteral( "MultiPolygon?crs=EPSG:3946&field=fld:int" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ) );
const int idx = vlPolygon->fields().indexFromName( QStringLiteral( "fld" ) );
QVERIFY( idx != -1 );
f1.initAttributes( 1 );
Expand Down Expand Up @@ -606,7 +606,7 @@ class TestQgsMapToolTrimExtendFeature : public QObject
pt.toQPointF().toPoint(),
Qt::LeftButton,
Qt::NoButton,
Qt::ControlModifier
Qt::ShiftModifier
) );
tool->canvasReleaseEvent( event.get() );

Expand Down

0 comments on commit 61a27e0

Please sign in to comment.