Skip to content

Commit

Permalink
Applied patch #2731 by mhugent: show georeferencer residuals in map u…
Browse files Browse the repository at this point in the history
…nits when possible.

git-svn-id: http://svn.osgeo.org/qgis/trunk@13552 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mmassing committed May 23, 2010
1 parent 57b82b9 commit 4d46f19
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 92 deletions.
47 changes: 36 additions & 11 deletions src/plugins/georeferencer/qgsgcplistmodel.cpp
Expand Up @@ -16,7 +16,7 @@


#include "qgsgcplist.h" #include "qgsgcplist.h"
#include "qgsgcplistmodel.h" #include "qgsgcplistmodel.h"

#include "qgis.h"
#include "qgsgeorefdatapoint.h" #include "qgsgeorefdatapoint.h"
#include "qgsgeoreftransform.h" #include "qgsgeoreftransform.h"


Expand Down Expand Up @@ -85,23 +85,43 @@ void QgsGCPListModel::updateModel()
if ( !mGCPList ) if ( !mGCPList )
return; return;


// // Setup table header
QStringList itemLabels;
// // Set column headers
itemLabels << "on/off" << "id" << "srcX" << "srcY" << "dstX" << "dstY" << "dX" << "dY" << "residual";
// setColumnCount(itemLabels.size());
setHorizontalHeaderLabels( itemLabels );
setRowCount( mGCPList->size() );

bool bTransformUpdated = false; bool bTransformUpdated = false;
bool wldTransform = false;
double wldScaleX, wldScaleY, rotation;
QgsPoint origin;

if ( mGeorefTransform ) if ( mGeorefTransform )
{ {
vector<QgsPoint> mapCoords, pixelCoords; vector<QgsPoint> mapCoords, pixelCoords;
mGCPList->createGCPVectors( mapCoords, pixelCoords ); mGCPList->createGCPVectors( mapCoords, pixelCoords );


// TODO: the parameters should probable be updated externally (by user interaction) // TODO: the parameters should probable be updated externally (by user interaction)
bTransformUpdated = mGeorefTransform->updateParametersFromGCPs( mapCoords, pixelCoords ); bTransformUpdated = mGeorefTransform->updateParametersFromGCPs( mapCoords, pixelCoords );
//transformation that involves only scaling and rotation (linear or helmert) ?
wldTransform = mGeorefTransform->getOriginScaleRotation( origin, wldScaleX, wldScaleY, rotation );
if ( wldTransform && !doubleNear( rotation, 0.0 ) )
{
wldScaleX *= cos( rotation );
wldScaleY *= cos( rotation );
}
if ( wldTransform )
{

}
}

// // Setup table header
QStringList itemLabels;
if ( wldTransform )
{
itemLabels << "on/off" << "id" << "srcX" << "srcY" << "dstX" << "dstY" << QString( "dX[" ) + tr( "map units" ) + "]" << QString( "dY[" ) + tr( "map units" ) + "]" << "residual";
} }
else
{
itemLabels << "on/off" << "id" << "srcX" << "srcY" << "dstX" << "dstY" << QString( "dX[" ) + tr( "pixels" ) + "]" << QString( "dY[" ) + tr( "pixels" ) + "]" << "residual";
}
setHorizontalHeaderLabels( itemLabels );
setRowCount( mGCPList->size() );


for ( int i = 0; i < mGCPList->sizeAll(); ++i ) for ( int i = 0; i < mGCPList->sizeAll(); ++i )
{ {
Expand Down Expand Up @@ -135,8 +155,13 @@ void QgsGCPListModel::updateModel()
// As transforms of order >=2 are not invertible, we are only // As transforms of order >=2 are not invertible, we are only
// interested in the residual in this direction // interested in the residual in this direction
mGeorefTransform->transformWorldToRaster( p->mapCoords(), dst ); mGeorefTransform->transformWorldToRaster( p->mapCoords(), dst );
dX = ( dst.x() - p->pixelCoords().x() ); dX = ( dst.x() - p->pixelCoords().x() );
dY = -( dst.y() - p->pixelCoords().y() ); dY = -( dst.y() - p->pixelCoords().y() );
if ( wldTransform )
{
dX *= wldScaleX;
dY *= wldScaleY;
}
residual = sqrt( dX * dX + dY * dY ); residual = sqrt( dX * dX + dY * dY );
} }
else else
Expand All @@ -152,7 +177,7 @@ void QgsGCPListModel::updateModel()
if ( residual >= 0.f ) if ( residual >= 0.f )
{ {
setItem( i, j++, QGSSTANDARDITEM( dX ) /*create_item<double>(dX)*/ ); setItem( i, j++, QGSSTANDARDITEM( dX ) /*create_item<double>(dX)*/ );
setItem( i, j++, QGSSTANDARDITEM( dY ) /*create_item<double>(-dY)*/); setItem( i, j++, QGSSTANDARDITEM( dY ) /*create_item<double>(-dY)*/ );
setItem( i, j++, QGSSTANDARDITEM( residual ) /*create_item<double>(residual)*/ ); setItem( i, j++, QGSSTANDARDITEM( residual ) /*create_item<double>(residual)*/ );
} }
else else
Expand Down

0 comments on commit 4d46f19

Please sign in to comment.