Skip to content
Permalink
Browse files

[FEATURE] Add dX, dY and residual on GCP Points (#8513)

* add dX, dY and residual on GCP Points
* add option to automatically save GCP Points in the raster-modified path
  • Loading branch information
Fanevanjanahary authored and nyalldawson committed Nov 26, 2018
1 parent 4c3e43b commit 7a9ba25e80acc82f23e7098fda4798b891e67021
@@ -341,7 +341,7 @@ bool QgsGeorefPluginGui::getTransformSettings()
}

d.getTransformSettings( mTransformParam, mResamplingMethod, mCompressionMethod,
mModifiedRasterFileName, mProjection, mPdfOutputMapFile, mPdfOutputFile, mUseZeroForTrans, mLoadInQgis, mUserResX, mUserResY );
mModifiedRasterFileName, mProjection, mPdfOutputMapFile, mPdfOutputFile, mSaveGcp, mUseZeroForTrans, mLoadInQgis, mUserResX, mUserResY );
mTransformParamLabel->setText( tr( "Transform: " ) + convertTransformEnumToString( mTransformParam ) );
mGeorefTransform.selectTransformParametrisation( mTransformParam );
mGCPListWidget->setGeorefTransform( &mGeorefTransform );
@@ -1250,7 +1250,7 @@ bool QgsGeorefPluginGui::loadGCPs( /*bool verbose*/ )

QgsPointXY mapCoords( ls.at( 0 ).toDouble(), ls.at( 1 ).toDouble() ); // map x,y
QgsPointXY pixelCoords( ls.at( 2 ).toDouble(), ls.at( 3 ).toDouble() ); // pixel x,y
if ( ls.count() == 5 )
if ( ls.count() == 5 || ls.count() == 8 )
{
bool enable = ls.at( 4 ).toInt();
addPoint( pixelCoords, mapCoords, enable, false );
@@ -1280,15 +1280,19 @@ void QgsGeorefPluginGui::saveGCPs()
if ( pointFile.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
{
QTextStream points( &pointFile );
points << "mapX,mapY,pixelX,pixelY,enable" << endl;
points << "mapX,mapY,pixelX,pixelY,enable,dX,dY,residual" << endl;
Q_FOREACH ( QgsGeorefDataPoint *pt, mPoints )
{
points << QStringLiteral( "%1,%2,%3,%4,%5" )
points << QStringLiteral( "%1,%2,%3,%4,%5,%6,%7,%8" )
.arg( qgsDoubleToString( pt->mapCoords().x() ),
qgsDoubleToString( pt->mapCoords().y() ),
qgsDoubleToString( pt->pixelCoords().x() ),
qgsDoubleToString( pt->pixelCoords().y() ) )
.arg( pt->isEnabled() ) << endl;
.arg( pt->isEnabled() )
.arg( qgsDoubleToString( pt->residual().x() ),
qgsDoubleToString( pt->residual().y() ),
qgsDoubleToString( std::sqrt( pt->residual().x() * pt->residual().x() + pt->residual().y() * pt->residual().y() ) ) )
<< endl;
}

mInitialPoints = mPoints;
@@ -1410,6 +1414,11 @@ bool QgsGeorefPluginGui::georeference()
{
writePDFMapFile( mPdfOutputMapFile, mGeorefTransform );
}
if ( !mSaveGcp.isEmpty() )
{
mGCPpointsFileName = mModifiedRasterFileName + QLatin1String( ".points" );
saveGCPs();
}
return true;
}
}
@@ -228,6 +228,7 @@ class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBas
QgsCoordinateReferenceSystem mProjection;
QString mPdfOutputFile;
QString mPdfOutputMapFile;
QString mSaveGcp;
double mUserResX, mUserResY; // User specified target scale

QgsGeorefTransform::TransformParametrisation mTransformParam;
@@ -260,6 +261,7 @@ class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBas
bool mGCPsDirty;
bool mLoadInQgis;


QgsDockWidget *mDock = nullptr;
int messageTimeout();
};
@@ -121,6 +121,8 @@ QgsTransformSettingsDialog::QgsTransformSettingsDialog( const QString &raster, c

cbxZeroAsTrans->setChecked( settings.value( QStringLiteral( "/Plugin-GeoReferencer/zeroastrans" ), false ).toBool() );
cbxLoadInQgisWhenDone->setChecked( settings.value( QStringLiteral( "/Plugin-GeoReferencer/loadinqgis" ), false ).toBool() );
saveGcpCheckBox->setChecked( settings.value( QStringLiteral( "/Plugin-GeoReferencer/save_gcp_points" ), false ).toBool() );

}

QgsTransformSettingsDialog::~QgsTransformSettingsDialog()
@@ -132,7 +134,7 @@ QgsTransformSettingsDialog::~QgsTransformSettingsDialog()
void QgsTransformSettingsDialog::getTransformSettings( QgsGeorefTransform::TransformParametrisation &tp,
QgsImageWarper::ResamplingMethod &rm,
QString &comprMethod, QString &raster,
QgsCoordinateReferenceSystem &proj, QString &pdfMapFile, QString &pdfReportFile, bool &zt, bool &loadInQgis,
QgsCoordinateReferenceSystem &proj, QString &pdfMapFile, QString &pdfReportFile, QString &gcpPoints, bool &zt, bool &loadInQgis,
double &resX, double &resY )
{
if ( cmbTransformType->currentIndex() == -1 )
@@ -162,6 +164,10 @@ void QgsTransformSettingsDialog::getTransformSettings( QgsGeorefTransform::Trans
resX = dsbHorizRes->value();
resY = dsbVerticalRes->value();
}
if ( saveGcpCheckBox->isChecked() )
{
gcpPoints = mOutputRaster->filePath();
}
}

void QgsTransformSettingsDialog::resetSettings()
@@ -173,6 +179,7 @@ void QgsTransformSettingsDialog::resetSettings()
s.setValue( QStringLiteral( "/Plugin-GeoReferencer/targetsrs" ), QString() );
s.setValue( QStringLiteral( "/Plugin-GeoReferencer/zeroastrans" ), false );
s.setValue( QStringLiteral( "/Plugin-GeoReferencer/loadinqgis" ), false );
s.setValue( QStringLiteral( "/Plugin-GeoReferencer/save_gcp_points" ), false );
s.setValue( QStringLiteral( "/Plugin-GeoReferencer/user_specified_resolution" ), false );
s.setValue( QStringLiteral( "/Plugin-GeoReferencer/user_specified_resx" ), 1.0 );
s.setValue( QStringLiteral( "/Plugin-GeoReferencer/user_specified_resy" ), -1.0 );
@@ -227,6 +234,8 @@ void QgsTransformSettingsDialog::accept()
settings.setValue( QStringLiteral( "/Plugin-GeoReferencer/user_specified_resx" ), dsbHorizRes->value() );
settings.setValue( QStringLiteral( "/Plugin-GeoReferencer/user_specified_resy" ), dsbVerticalRes->value() );
settings.setValue( QStringLiteral( "/Plugin-GeoReferencer/word_file_checkbox" ), mWorldFileCheckBox->isChecked() );
settings.setValue( QStringLiteral( "/Plugin-GeoReferencer/save_gcp_points" ), saveGcpCheckBox->isChecked() );


QDialog::accept();
}
@@ -33,7 +33,7 @@ class QgsTransformSettingsDialog : public QDialog, private Ui::QgsTransformSetti
~QgsTransformSettingsDialog() override;
void getTransformSettings( QgsGeorefTransform::TransformParametrisation &tp,
QgsImageWarper::ResamplingMethod &rm, QString &comprMethod,
QString &raster, QgsCoordinateReferenceSystem &proj, QString &pdfMapFile, QString &pdfReportFile, bool &zt, bool &loadInQgis,
QString &raster, QgsCoordinateReferenceSystem &proj, QString &pdfMapFile, QString &pdfReportFile, QString &gcpPoints, bool &zt, bool &loadInQgis,
double &resX, double &resY );
static void resetSettings();

0 comments on commit 7a9ba25

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