Skip to content

Commit

Permalink
When loading gcp points for a raster which is already
Browse files Browse the repository at this point in the history
georeferenced, assume the source points are in the
raster's IF there's no explicit crs information in the .points file
  • Loading branch information
nyalldawson committed Feb 14, 2022
1 parent a2bb366 commit 8a12a0b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/app/georeferencer/qgsgeorefmainwindow.cpp
Expand Up @@ -1138,6 +1138,19 @@ void QgsGeoreferencerMainWindow::addRaster( const QString &file )
options.skipCrsValidation = true;
mLayer = std::make_unique< QgsRasterLayer >( file, QStringLiteral( "Raster" ), QStringLiteral( "gdal" ), options );

// guess a reasonable target CRS to use by default
if ( mLayer->crs().isValid() )
{
// if source raster already is already georeferenced, assume we'll be keeping the same CRS
mTargetCrs = mLayer->crs();
}
// otherwise use the previous target crs, unless that's never been set
else if ( !mTargetCrs.isValid() )
{
// in which case we'll use the current project CRS
mTargetCrs = QgsProject::instance()->crs();
}

// add layer to map canvas
mCanvas->setLayers( QList<QgsMapLayer *>() << mLayer.get() );

Expand Down Expand Up @@ -1192,7 +1205,7 @@ bool QgsGeoreferencerMainWindow::loadGCPs( QString &error )
{
QgsCoordinateReferenceSystem actualDestinationCrs;
const QList< QgsGcpPoint > points = QgsGCPList::loadGcps( mGCPpointsFileName,
QgsProject::instance()->crs(),
mTargetCrs,
actualDestinationCrs,
error );
if ( !error.isEmpty() )
Expand Down

0 comments on commit 8a12a0b

Please sign in to comment.