Skip to content
Permalink
Browse files
Applied patch #2731 by mhugent: show georeferencer residuals in map u…
…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 4d46f1909a910c3fe39b970223ef4cd2c5e0e53b
@@ -16,7 +16,7 @@

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

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

@@ -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 )
{
@@ -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
@@ -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

0 comments on commit 4d46f19

Please sign in to comment.