Skip to content

Commit 246ed77

Browse files
author
mhugent
committedApr 14, 2007

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed
 

‎src/plugins/georeferencer/qgsleastsquares.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
void QgsLeastSquares::linear(std::vector<QgsPoint> mapCoords,
1313
std::vector<QgsPoint> pixelCoords,
14-
QgsPoint& origin, double& pixelSize) {
14+
QgsPoint& origin, double& pixelXSize, double& pixelYSize) {
1515
int n = mapCoords.size();
1616
if (n < 2) {
1717
throw std::domain_error(QObject::tr("Fit to a linear transform requires at "
@@ -43,7 +43,8 @@ void QgsLeastSquares::linear(std::vector<QgsPoint> mapCoords,
4343

4444
origin.setX(aX);
4545
origin.setY(aY);
46-
pixelSize = (std::abs(bX) + std::abs(bY)) / 2;
46+
pixelXSize = std::abs(bX);
47+
pixelYSize = std::abs(bY);
4748
}
4849

4950

@@ -150,4 +151,3 @@ void QgsLeastSquares::affine(std::vector<QgsPoint> mapCoords,
150151
gsl_permutation_free(p);
151152

152153
}
153-

‎src/plugins/georeferencer/qgsleastsquares.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class QgsLeastSquares {
1212
public:
1313
static void linear(std::vector<QgsPoint> mapCoords,
1414
std::vector<QgsPoint> pixelCoords,
15-
QgsPoint& origin, double& pixelSize);
15+
QgsPoint& origin, double& pixelXSize, double& pixelYSize);
1616

1717
static void helmert(std::vector<QgsPoint> mapCoords,
1818
std::vector<QgsPoint> pixelCoords,

‎src/plugins/georeferencer/qgspointdialog.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ void QgsPointDialog::on_cmbTransformType_currentIndexChanged(const QString& valu
292292
bool QgsPointDialog::generateWorldFile()
293293
{
294294
QgsPoint origin(0, 0);
295-
double pixelSize = 1;
295+
double pixelXSize = 1;
296+
double pixelYSize = 1;
296297
double rotation = 0;
297298
double xOffset = 0.0;
298299
double yOffset = 0.0;
@@ -312,7 +313,7 @@ bool QgsPointDialog::generateWorldFile()
312313
{
313314
if (cmbTransformType->currentText() == tr("Linear"))
314315
{
315-
QgsLeastSquares::linear(mapCoords, pixelCoords, origin, pixelSize);
316+
QgsLeastSquares::linear(mapCoords, pixelCoords, origin, pixelXSize, pixelYSize);
316317
}
317318
else if (cmbTransformType->currentText() == tr("Helmert"))
318319
{
@@ -327,7 +328,8 @@ bool QgsPointDialog::generateWorldFile()
327328
if (res == QMessageBox::Cancel)
328329
return false;
329330

330-
QgsLeastSquares::helmert(mapCoords, pixelCoords, origin, pixelSize, rotation);
331+
QgsLeastSquares::helmert(mapCoords, pixelCoords, origin, pixelXSize, rotation);
332+
pixelYSize = pixelXSize;
331333
}
332334
else if (cmbTransformType->currentText() == tr("Affine"))
333335
{
@@ -375,12 +377,12 @@ bool QgsPointDialog::generateWorldFile()
375377
return false;
376378
}
377379
QTextStream stream(&file);
378-
stream<<pixelSize<<endl
380+
stream<<pixelXSize<<endl
379381
<<0<<endl
380382
<<0<<endl
381-
<<-pixelSize<<endl
382-
<<QString::number(origin.x() - xOffset * pixelSize, 'f')<<endl
383-
<<QString::number(origin.y() + yOffset * pixelSize, 'f')<<endl;
383+
<<-pixelYSize<<endl
384+
<<QString::number(origin.x() - xOffset * pixelXSize, 'f')<<endl
385+
<<QString::number(origin.y() + yOffset * pixelYSize, 'f')<<endl;
384386
// write the data points in case we need them later
385387
QFile pointFile(mLayer->source() + ".points");
386388
if (pointFile.open(QIODevice::WriteOnly))

0 commit comments

Comments
 (0)
Please sign in to comment.