Skip to content

Commit

Permalink
Catch coordinate transform exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Sep 24, 2018
1 parent e148d4b commit 7a85fb0
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/app/3d/qgs3dmaptoolidentify.cpp
Expand Up @@ -108,10 +108,21 @@ void Qgs3DMapToolIdentify::onTerrainPicked( Qt3DRender::QPickEvent *event )

// transform the point and search radius to CRS of the map canvas (if they are different)
QgsCoordinateTransform ct( mCanvas->map()->crs(), canvas2D->mapSettings().destinationCrs(), canvas2D->mapSettings().transformContext() );
QgsPointXY mapPointCanvas2D = ct.transform( mapPoint );
QgsPointXY mapPointSearchRadius( mapPoint.x() + searchRadiusMapUnits, mapPoint.y() );
QgsPointXY mapPointSearchRadiusCanvas2D = ct.transform( mapPointSearchRadius );
double searchRadiusCanvas2D = mapPointCanvas2D.distance( mapPointSearchRadiusCanvas2D );

QgsPointXY mapPointCanvas2D = mapPoint;
double searchRadiusCanvas2D = searchRadiusMapUnits;
try
{
mapPointCanvas2D = ct.transform( mapPoint );
QgsPointXY mapPointSearchRadius( mapPoint.x() + searchRadiusMapUnits, mapPoint.y() );
QgsPointXY mapPointSearchRadiusCanvas2D = ct.transform( mapPointSearchRadius );
searchRadiusCanvas2D = mapPointCanvas2D.distance( mapPointSearchRadiusCanvas2D );
}
catch ( QgsException &e )
{
Q_UNUSED( e );
QgsDebugMsg( QStringLiteral( "Caught exception %1" ).arg( e.what() ) );
}

identifyTool2D->identifyAndShowResults( QgsGeometry::fromPointXY( mapPointCanvas2D ), searchRadiusCanvas2D );
}
Expand Down

0 comments on commit 7a85fb0

Please sign in to comment.