100518_georef.diff
src/plugins/georeferencer/qgsgcplistmodel.cpp (Arbeitskopie) | ||
---|---|---|
16 | 16 | |
17 | 17 |
#include "qgsgcplist.h" |
18 | 18 |
#include "qgsgcplistmodel.h" |
19 | ||
19 |
#include "qgis.h" |
|
20 | 20 |
#include "qgsgeorefdatapoint.h" |
21 | 21 |
#include "qgsgeoreftransform.h" |
22 | 22 | |
... | ... | |
85 | 85 |
if ( !mGCPList ) |
86 | 86 |
return; |
87 | 87 | |
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() ); |
|
88 |
bool bTransformUpdated = false; |
|
89 |
bool wldTransform = false; |
|
90 |
double wldScaleX, wldScaleY, rotation; |
|
91 |
QgsPoint origin; |
|
95 | 92 | |
96 |
bool bTransformUpdated = false; |
|
97 | 93 |
if ( mGeorefTransform ) |
98 | 94 |
{ |
99 | 95 |
vector<QgsPoint> mapCoords, pixelCoords; |
... | ... | |
101 | 97 | |
102 | 98 |
// TODO: the parameters should probable be updated externally (by user interaction) |
103 | 99 |
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 |
} |
|
104 | 111 |
} |
105 | 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"; |
|
118 |
} |
|
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() ); |
|
125 | ||
106 | 126 |
for ( int i = 0; i < mGCPList->sizeAll(); ++i ) |
107 | 127 |
{ |
108 | 128 |
int j = 0; |
... | ... | |
135 | 155 |
// As transforms of order >=2 are not invertible, we are only |
136 | 156 |
// interested in the residual in this direction |
137 | 157 |
mGeorefTransform->transformWorldToRaster( p->mapCoords(), dst ); |
138 |
dX = ( dst.x() - p->pixelCoords().x() );
|
|
158 |
dX = ( dst.x() - p->pixelCoords().x() ); |
|
139 | 159 |
dY = -( dst.y() - p->pixelCoords().y() ); |
160 |
if ( wldTransform ) |
|
161 |
{ |
|
162 |
dX *= wldScaleX; |
|
163 |
dY *= wldScaleY; |
|
164 |
} |
|
140 | 165 |
residual = sqrt( dX * dX + dY * dY ); |
141 | 166 |
} |
142 | 167 |
else |
... | ... | |
152 | 177 |
if ( residual >= 0.f ) |
153 | 178 |
{ |
154 | 179 |
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)*/ );
|
|
156 | 181 |
setItem( i, j++, QGSSTANDARDITEM( residual ) /*create_item<double>(residual)*/ ); |
157 | 182 |
} |
158 | 183 |
else |
src/plugins/georeferencer/qgsgeorefplugingui.cpp (Arbeitskopie) | ||
---|---|---|
108 | 108 | |
109 | 109 |
QgsGeorefPluginGui::~QgsGeorefPluginGui() |
110 | 110 |
{ |
111 |
QgsTransformSettingsDialog::resetSettings(); |
|
112 | 111 |
clearGCPData(); |
113 | 112 | |
114 | 113 |
// delete layer (and don't signal it as it's our private layer) |
... | ... | |
1226 | 1225 |
//transformation that involves only scaling and rotation (linear or helmert) ? |
1227 | 1226 |
bool wldTransform = transform.getOriginScaleRotation( origin, scaleX, scaleY, rotation ); |
1228 | 1227 | |
1229 |
//consider rotation in scale parameter |
|
1230 |
double wldScaleX = scaleX; |
|
1231 |
double wldScaleY = scaleY; |
|
1232 |
if ( wldTransform && !doubleNear( rotation, 0.0 ) ) |
|
1233 |
{ |
|
1234 |
wldScaleX *= cos( rotation ); |
|
1235 |
wldScaleY *= cos( rotation ); |
|
1236 |
} |
|
1237 | ||
1238 | 1228 |
if ( wldTransform ) |
1239 | 1229 |
{ |
1240 | 1230 |
QString parameterTitle = tr( "Transformation parameters" ); |
... | ... | |
1277 | 1267 |
{ |
1278 | 1268 |
if (( *gcpIt )->isEnabled() ) |
1279 | 1269 |
{ |
1280 |
resXMap = ( *gcpIt )->residual().x() * wldScaleX; |
|
1281 |
resYMap = ( *gcpIt )->residual().y() * wldScaleY; |
|
1282 |
sumVxSquare += ( resXMap * resXMap ); |
|
1283 |
sumVySquare += ( resYMap * resYMap ); |
|
1270 |
sumVxSquare += (( *gcpIt )->residual().x() * ( *gcpIt )->residual().x() ); |
|
1271 |
sumVySquare += (( *gcpIt )->residual().y() * ( *gcpIt )->residual().y() ); |
|
1284 | 1272 |
} |
1285 | 1273 |
} |
1286 | 1274 | |
... | ... | |
1326 | 1314 |
//convert residual scale bar plot to map units if scaling is equal in x- and y-direction (e.g. helmert) |
1327 | 1315 |
if ( wldTransform ) |
1328 | 1316 |
{ |
1329 |
if ( doubleNear( wldScaleX, wldScaleY ) )
|
|
1317 |
if ( doubleNear( scaleX, scaleX ) )
|
|
1330 | 1318 |
{ |
1331 | 1319 |
resPlotItem->setPixelToMapUnits( scaleX ); |
1332 | 1320 |
resPlotItem->setConvertScaleToMapUnits( true ); |
... | ... | |
1354 | 1342 |
{ |
1355 | 1343 |
QStringList currentGCPStrings; |
1356 | 1344 |
QPointF residual = ( *gcpIt )->residual(); |
1357 |
double residualX = residual.x(); |
|
1358 |
if ( wldTransform ) |
|
1359 |
{ |
|
1360 |
residualX *= wldScaleX; |
|
1361 |
} |
|
1362 |
double residualY = residual.y(); |
|
1363 |
if ( wldTransform ) |
|
1364 |
{ |
|
1365 |
residualY *= wldScaleY; |
|
1366 |
} |
|
1367 |
double residualTot = sqrt( residualX * residualX + residualY * residualY ); |
|
1345 |
double residualTot = sqrt( residual.x() * residual.x() + residual.y() * residual.y() ); |
|
1368 | 1346 | |
1369 | 1347 |
currentGCPStrings << QString::number(( *gcpIt )->id() ); |
1370 | 1348 |
if (( *gcpIt )->isEnabled() ) |
... | ... | |
1376 | 1354 |
currentGCPStrings << tr( "no" ); |
1377 | 1355 |
} |
1378 | 1356 |
currentGCPStrings << QString::number(( *gcpIt )->pixelCoords().x(), 'f', 2 ) << QString::number(( *gcpIt )->pixelCoords().y(), 'f', 2 ) << QString::number(( *gcpIt )->mapCoords().x(), 'f', 2 )\ |
1379 |
<< QString::number(( *gcpIt )->mapCoords().y(), 'f', 2 ) << QString::number( residualX ) << QString::number( residualY ) << QString::number( residualTot );
|
|
1357 |
<< QString::number(( *gcpIt )->mapCoords().y(), 'f', 2 ) << QString::number( residual.x() ) << QString::number( residual.y() ) << QString::number( residualTot );
|
|
1380 | 1358 |
gcpTable->addRow( currentGCPStrings ); |
1381 | 1359 |
} |
1382 | 1360 |