Skip to content

Commit

Permalink
Do not pan to the feature if the currrent extend can't contain the ge…
Browse files Browse the repository at this point in the history
…ometry
  • Loading branch information
ValentinBuira committed Oct 25, 2024
1 parent d014195 commit 22e9672
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/inpututils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,25 @@ QPointF InputUtils::geometryCenterToScreenCoordinates( const QgsGeometry &geom,
return screenPoint;
}

bool InputUtils::canExtentContainGeometry( const QgsGeometry &geom, InputMapSettings *mapSettings )
{
QPointF screenPoint;

if ( !mapSettings || geom.isNull() || !geom.constGet() )
// return screenPoint;
return false;

QgsRectangle geomBbox = geom.boundingBox();
QgsRectangle currentExtent = mapSettings->mapSettings().extent();

if (currentExtent.width() > geomBbox.width()
&& currentExtent.height() > geomBbox.height()) {
return true;
}
return false;
}


double InputUtils::convertCoordinateString( const QString &rationalValue )
{
QStringList values = rationalValue.split( "," );
Expand Down
7 changes: 7 additions & 0 deletions app/inpututils.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ class InputUtils: public QObject
*/
Q_INVOKABLE QPointF geometryCenterToScreenCoordinates( const QgsGeometry &geom, InputMapSettings *mapSettings );


/**
* Returns the true if the geometry could fully be contained in the current screen otherwise false
* Geometry must be in canvas CRS
*/
Q_INVOKABLE bool canExtentContainGeometry( const QgsGeometry &geom, InputMapSettings *mapSettings );

// utility functions to extract information from map settings
// (in theory this data should be directly available from .MapTransform
// but they are not currently, so this is a workaround we need for display of markers)
Expand Down
4 changes: 4 additions & 0 deletions app/qml/map/MMMapController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,10 @@ Item {
if ( identifyHighlight.geometry === null )
return

if (! __inputUtils.canExtentContainGeometry( identifyHighlight.geometry, mapCanvas.mapSettings )){
return
}

let screenPt = __inputUtils.geometryCenterToScreenCoordinates( identifyHighlight.geometry, mapCanvas.mapSettings )
screenPt.y += mapOffset / 2
mapCanvas.jumpTo( screenPt )
Expand Down

1 comment on commit 22e9672

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 24.10.689811 just submitted!

Please sign in to comment.