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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

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

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

Expand Down Expand Up @@ -85,23 +85,43 @@ void QgsGCPListModel::updateModel()
if ( !mGCPList )
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 wldTransform = false;
double wldScaleX, wldScaleY, rotation;
QgsPoint origin;

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

// TODO: the parameters should probable be updated externally (by user interaction)
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 )
{
Expand Down Expand Up @@ -135,8 +155,13 @@ void QgsGCPListModel::updateModel()
// As transforms of order >=2 are not invertible, we are only
// interested in the residual in this direction
mGeorefTransform->transformWorldToRaster( p->mapCoords(), dst );
dX = ( dst.x() - p->pixelCoords().x() );
dX = ( dst.x() - p->pixelCoords().x() );
dY = -( dst.y() - p->pixelCoords().y() );
if ( wldTransform )
{
dX *= wldScaleX;
dY *= wldScaleY;
}
residual = sqrt( dX * dX + dY * dY );
}
else
Expand All @@ -152,7 +177,7 @@ void QgsGCPListModel::updateModel()
if ( residual >= 0.f )
{
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)*/ );
}
else
Expand Down
Loading

0 comments on commit 4d46f19

Please sign in to comment.