1616
1717#include " qgsgcplist.h"
1818#include " qgsgcplistmodel.h"
19-
19+ # include " qgis.h "
2020#include " qgsgeorefdatapoint.h"
2121#include " qgsgeoreftransform.h"
2222
@@ -85,23 +85,43 @@ void QgsGCPListModel::updateModel()
8585 if ( !mGCPList )
8686 return ;
8787
88- // // Setup table header
89- QStringList itemLabels;
90- // // Set column headers
91- itemLabels << " on/off" << " id" << " srcX" << " srcY" << " dstX" << " dstY" << " dX" << " dY" << " residual" ;
92- // setColumnCount(itemLabels.size());
93- setHorizontalHeaderLabels ( itemLabels );
94- setRowCount ( mGCPList ->size () );
95-
9688 bool bTransformUpdated = false ;
89+ bool wldTransform = false ;
90+ double wldScaleX, wldScaleY, rotation;
91+ QgsPoint origin;
92+
9793 if ( mGeorefTransform )
9894 {
9995 vector<QgsPoint> mapCoords, pixelCoords;
10096 mGCPList ->createGCPVectors ( mapCoords, pixelCoords );
10197
10298 // TODO: the parameters should probable be updated externally (by user interaction)
10399 bTransformUpdated = mGeorefTransform ->updateParametersFromGCPs ( mapCoords, pixelCoords );
100+ // transformation that involves only scaling and rotation (linear or helmert) ?
101+ wldTransform = mGeorefTransform ->getOriginScaleRotation ( origin, wldScaleX, wldScaleY, rotation );
102+ if ( wldTransform && !doubleNear ( rotation, 0.0 ) )
103+ {
104+ wldScaleX *= cos ( rotation );
105+ wldScaleY *= cos ( rotation );
106+ }
107+ if ( wldTransform )
108+ {
109+
110+ }
111+ }
112+
113+ // // Setup table header
114+ QStringList itemLabels;
115+ if ( wldTransform )
116+ {
117+ itemLabels << " on/off" << " id" << " srcX" << " srcY" << " dstX" << " dstY" << QString ( " dX[" ) + tr ( " map units" ) + " ]" << QString ( " dY[" ) + tr ( " map units" ) + " ]" << " residual" ;
104118 }
119+ else
120+ {
121+ itemLabels << " on/off" << " id" << " srcX" << " srcY" << " dstX" << " dstY" << QString ( " dX[" ) + tr ( " pixels" ) + " ]" << QString ( " dY[" ) + tr ( " pixels" ) + " ]" << " residual" ;
122+ }
123+ setHorizontalHeaderLabels ( itemLabels );
124+ setRowCount ( mGCPList ->size () );
105125
106126 for ( int i = 0 ; i < mGCPList ->sizeAll (); ++i )
107127 {
@@ -135,8 +155,13 @@ void QgsGCPListModel::updateModel()
135155 // As transforms of order >=2 are not invertible, we are only
136156 // interested in the residual in this direction
137157 mGeorefTransform ->transformWorldToRaster ( p->mapCoords (), dst );
138- dX = ( dst.x () - p->pixelCoords ().x () );
158+ dX = ( dst.x () - p->pixelCoords ().x () );
139159 dY = -( dst.y () - p->pixelCoords ().y () );
160+ if ( wldTransform )
161+ {
162+ dX *= wldScaleX;
163+ dY *= wldScaleY;
164+ }
140165 residual = sqrt ( dX * dX + dY * dY );
141166 }
142167 else
@@ -152,7 +177,7 @@ void QgsGCPListModel::updateModel()
152177 if ( residual >= 0 .f )
153178 {
154179 setItem ( i, j++, QGSSTANDARDITEM ( dX ) /* create_item<double>(dX)*/ );
155- setItem ( i, j++, QGSSTANDARDITEM ( dY ) /* create_item<double>(-dY)*/ );
180+ setItem ( i, j++, QGSSTANDARDITEM ( dY ) /* create_item<double>(-dY)*/ );
156181 setItem ( i, j++, QGSSTANDARDITEM ( residual ) /* create_item<double>(residual)*/ );
157182 }
158183 else
0 commit comments