mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
move catch block to QgsQuickUtils::transformPoint since it can be invoced from qml
This commit is contained in:
parent
1ed818e264
commit
8d240ecd4d
@ -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 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user