Skip to content

Commit

Permalink
Minor cleanup to rename ambiguous method
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson authored and github-actions[bot] committed Feb 9, 2022
1 parent 8c29475 commit 5953cfd
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
16 changes: 9 additions & 7 deletions src/app/georeferencer/qgsgcpcanvasitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,18 @@ void QgsGCPCanvasItem::updatePosition()
if ( mIsGCPSource )
{
setPos( toCanvasCoordinates( mDataPoint->pixelCoords() ) );
return;
}
if ( mDataPoint->canvasCoords().isEmpty() )
else
{
const QgsCoordinateReferenceSystem mapCrs = mMapCanvas->mapSettings().destinationCrs();
const QgsCoordinateTransform transf( mDataPoint->crs(), mapCrs, QgsProject::instance() );
const QgsPointXY mapCoords = transf.transform( mDataPoint->mapCoords() );
mDataPoint->setCanvasCoords( mapCoords );
if ( mDataPoint->canvasCoords().isEmpty() )
{
const QgsCoordinateReferenceSystem mapCrs = mMapCanvas->mapSettings().destinationCrs();
const QgsCoordinateTransform transf( mDataPoint->crs(), mapCrs, QgsProject::instance() );
const QgsPointXY mapCoords = transf.transform( mDataPoint->mapCoords() );
mDataPoint->setCanvasCoords( mapCoords );
}
setPos( toCanvasCoordinates( mDataPoint->canvasCoords() ) );
}
setPos( toCanvasCoordinates( mDataPoint->canvasCoords() ) );
}

void QgsGCPCanvasItem::drawResidualArrow( QPainter *p, const QgsRenderContext &context )
Expand Down
2 changes: 1 addition & 1 deletion src/app/georeferencer/qgsgcplistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void QgsGCPListModel::updateModel()
if ( mGeorefTransform && bTransformUpdated && mGeorefTransform->parametersInitialized() )
{
QgsPointXY dst;
const QgsPointXY pixel = mGeorefTransform->hasCrs() ? mGeorefTransform->toColumnLine( p->pixelCoords() ) : p->pixelCoords();
const QgsPointXY pixel = mGeorefTransform->hasExistingGeoreference() ? mGeorefTransform->toColumnLine( p->pixelCoords() ) : p->pixelCoords();
if ( unitType == tr( "pixels" ) )
{
// Transform from world to raster coordinate:
Expand Down
6 changes: 3 additions & 3 deletions src/app/georeferencer/qgsgeorefmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ void QgsGeoreferencerMainWindow::extentsChangedGeorefCanvas()
}

// Reproject the georeference plugin canvas into world coordinates and fit axis aligned bounding box
QgsRectangle rectMap = mGeorefTransform.hasCrs() ? mGeorefTransform.getBoundingBox( mCanvas->extent(), true ) : mCanvas->extent();
QgsRectangle rectMap = mGeorefTransform.hasExistingGeoreference() ? mGeorefTransform.getBoundingBox( mCanvas->extent(), true ) : mCanvas->extent();
QgsRectangle boundingBox = transformViewportBoundingBox( rectMap, mGeorefTransform, true );

mExtentsChangedRecursionGuard = true;
Expand Down Expand Up @@ -818,7 +818,7 @@ void QgsGeoreferencerMainWindow::extentsChangedQGisCanvas()

// Reproject the canvas into raster coordinates and fit axis aligned bounding box
QgsRectangle boundingBox = transformViewportBoundingBox( QgisApp::instance()->mapCanvas()->extent(), mGeorefTransform, false );
QgsRectangle rectMap = mGeorefTransform.hasCrs() ? mGeorefTransform.getBoundingBox( boundingBox, false ) : boundingBox;
QgsRectangle rectMap = mGeorefTransform.hasExistingGeoreference() ? mGeorefTransform.getBoundingBox( boundingBox, false ) : boundingBox;

mExtentsChangedRecursionGuard = true;
// Just set the whole extent for now
Expand Down Expand Up @@ -1191,7 +1191,7 @@ void QgsGeoreferencerMainWindow::addRaster( const QString &file )
mActionFullHistogramStretch->setEnabled( true );

// Status Bar
if ( mGeorefTransform.hasCrs() )
if ( mGeorefTransform.hasExistingGeoreference() )
{
QString authid = mLayer->crs().authid();
mEPSG->setText( authid );
Expand Down
4 changes: 2 additions & 2 deletions src/app/georeferencer/qgsgeoreftransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class QgsGeorefTransform : public QgsGcpTransformerInterface
*/
void setRasterChangeCoords( const QString &fileRaster );

//! \returns Whether has Coordinate Reference Systems in image
bool hasCrs() const { return mRasterChangeCoords.hasCrs(); }
//! \returns Whether has image already has existing georeference
bool hasExistingGeoreference() const { return mRasterChangeCoords.hasExistingGeoreference(); }

//! \returns Coordinates of image
QgsPointXY toColumnLine( const QgsPointXY &pntMap ) { return mRasterChangeCoords.toColumnLine( pntMap ); }
Expand Down
5 changes: 2 additions & 3 deletions src/app/georeferencer/qgsrasterchangecoords.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@ void QgsRasterChangeCoords::setRaster( const QString &fileRaster )
const gdal::dataset_unique_ptr hDS( GDALOpen( fileRaster.toUtf8().constData(), GA_ReadOnly ) );
double adfGeoTransform[6];
if ( GDALGetProjectionRef( hDS.get() ) && GDALGetGeoTransform( hDS.get(), adfGeoTransform ) == CE_None )
//if ( false )
{
mHasCrs = true;
mHasExistingGeoreference = true;
mUL_X = adfGeoTransform[0];
mUL_Y = adfGeoTransform[3];
mResX = adfGeoTransform[1];
mResY = adfGeoTransform[5];
}
else
{
mHasCrs = false;
mHasExistingGeoreference = false;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/georeferencer/qgsrasterchangecoords.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ class QgsRasterChangeCoords
public:
QgsRasterChangeCoords() = default;
void setRaster( const QString &fileRaster );
bool hasCrs() const { return mHasCrs; }
bool hasExistingGeoreference() const { return mHasExistingGeoreference; }
QVector<QgsPointXY> getPixelCoords( const QVector<QgsPointXY> &mapCoords );
QgsRectangle getBoundingBox( const QgsRectangle &rect, bool toPixel );
QgsPointXY toColumnLine( const QgsPointXY &pntMap );
QgsPointXY toXY( const QgsPointXY &pntPixel );

private:
bool mHasCrs = false;
bool mHasExistingGeoreference = false;
double mUL_X = 0.;
double mUL_Y = 0.;
double mResX = 1.;
Expand Down

0 comments on commit 5953cfd

Please sign in to comment.