Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions app/inpututils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,12 @@ QPointF InputUtils::relevantGeometryCenterToScreenCoordinates( const QgsGeometry

const QgsRectangle currentExtent = mapSettings->mapSettings().visibleExtent();

// Cut the geometry to current extent
const QgsGeometry currentExtentAsGeom = QgsGeometry::fromRect( currentExtent );
const QgsGeometry intersectedGeom = geom.intersection( currentExtentAsGeom );
// Cut the geometry extent to current extent
const QgsRectangle intersectedExtent = currentExtent.intersect( geom.boundingBox() );

if ( !intersectedGeom.isEmpty() )
if ( !intersectedExtent.isEmpty() )
{
target = QgsPoint( intersectedGeom.boundingBox().center() );
target = QgsPoint( intersectedExtent.center() );
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion app/test/testutilsfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ void TestUtilsFunctions::testRelevantGeometryCenterToScreenCoordinates()

// Case when we cut the geometry to current extent
ms.setExtent( QgsRectangle( 599032, 5.40671e+06, 619818, 5.43961e+06 ) );
QCOMPARE( InputUtils::equals( mUtils->relevantGeometryCenterToScreenCoordinates( geom, &ms ), QPointF( 286.257, 274.5 ), epsilon ), true );
QCOMPARE( InputUtils::equals( mUtils->relevantGeometryCenterToScreenCoordinates( geom, &ms ), QPointF( 286.261, 304.496 ), epsilon ), true );
}

void TestUtilsFunctions::testIsValidEmail()
Expand Down
Loading