Skip to content
Permalink
Browse files

move catch block to QgsQuickUtils::transformPoint since it can be inv…

…oced from qml
  • Loading branch information
PeterPetrik authored and nyalldawson committed Jan 13, 2021
1 parent 1ed818e commit 8d240ecd4dbd29db3662594bfc47e47fef7946fa
@@ -19,8 +19,6 @@
#include "qgsquickattributeformmodelbase.h"
#include "qgsquickattributeformmodel.h"
#include <qgsvectorlayerutils.h>
#include "qgsattributeeditorcontainer.h"
#include "qgsattributeeditorfield.h"

/// @cond PRIVATE

@@ -32,7 +32,6 @@

#include "qgseditformconfig.h"
#include "qgsexpressioncontext.h"
#include "qgsattributeeditorcontainer.h"

#include "qgis_quick.h"
#include "qgsquickattributemodel.h"
@@ -139,19 +139,12 @@ void QgsQuickPositionKit::updateProjectedPosition()
return;

QgsPointXY srcPoint = QgsPointXY( mPosition.x(), mPosition.y() );
QgsPointXY projectedPositionXY = srcPoint;
try
{
projectedPositionXY = QgsQuickUtils::transformPoint(
positionCRS(),
mMapSettings->destinationCrs(),
mMapSettings->transformContext(),
srcPoint );
}
catch ( const QgsCsException & )
{
QgsDebugMsg( QStringLiteral( "Failed to transform GPS position: " ) + srcPoint.toString() );
}
QgsPointXY projectedPositionXY = QgsQuickUtils::transformPoint(
positionCRS(),
mMapSettings->destinationCrs(),
mMapSettings->transformContext(),
srcPoint
);

QgsPoint projectedPosition( projectedPositionXY );
projectedPosition.addZValue( mPosition.z() );
@@ -68,9 +68,20 @@ QgsPointXY QgsQuickUtils::transformPoint( const QgsCoordinateReferenceSystem &sr
const QgsCoordinateTransformContext &context,
const QgsPointXY &srcPoint )
{
QgsCoordinateTransform mTransform( srcCrs, destCrs, context );
QgsPointXY pt = mTransform.transform( srcPoint );
return pt;
try
{
QgsCoordinateTransform ct( srcCrs, destCrs, context );
if ( ct.isValid() )
{
const QgsPointXY pt = ct.transform( srcPoint );
return pt;
}
}
catch ( QgsCsException &cse )
{
Q_UNUSED( cse )
}
return srcPoint;
}

double QgsQuickUtils::screenUnitsToMeters( QgsQuickMapSettings *mapSettings, int baseLengthPixels )

0 comments on commit 8d240ec

Please sign in to comment.
You can’t perform that action at this time.