Skip to content

Commit

Permalink
Georeferencer plugin: enable creation of nonrectangular pixels in lin…
Browse files Browse the repository at this point in the history
…ear transformation

git-svn-id: http://svn.osgeo.org/qgis/trunk@6884 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 14, 2007
1 parent 47d2a31 commit 2f337ed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/plugins/georeferencer/qgsleastsquares.cpp
Expand Up @@ -11,7 +11,7 @@

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

origin.setX(aX);
origin.setY(aY);
pixelSize = (std::abs(bX) + std::abs(bY)) / 2;
pixelXSize = std::abs(bX);
pixelYSize = std::abs(bY);
}


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

}

2 changes: 1 addition & 1 deletion src/plugins/georeferencer/qgsleastsquares.h
Expand Up @@ -12,7 +12,7 @@ class QgsLeastSquares {
public:
static void linear(std::vector<QgsPoint> mapCoords,
std::vector<QgsPoint> pixelCoords,
QgsPoint& origin, double& pixelSize);
QgsPoint& origin, double& pixelXSize, double& pixelYSize);

static void helmert(std::vector<QgsPoint> mapCoords,
std::vector<QgsPoint> pixelCoords,
Expand Down
16 changes: 9 additions & 7 deletions src/plugins/georeferencer/qgspointdialog.cpp
Expand Up @@ -292,7 +292,8 @@ void QgsPointDialog::on_cmbTransformType_currentIndexChanged(const QString& valu
bool QgsPointDialog::generateWorldFile()
{
QgsPoint origin(0, 0);
double pixelSize = 1;
double pixelXSize = 1;
double pixelYSize = 1;
double rotation = 0;
double xOffset = 0.0;
double yOffset = 0.0;
Expand All @@ -312,7 +313,7 @@ bool QgsPointDialog::generateWorldFile()
{
if (cmbTransformType->currentText() == tr("Linear"))
{
QgsLeastSquares::linear(mapCoords, pixelCoords, origin, pixelSize);
QgsLeastSquares::linear(mapCoords, pixelCoords, origin, pixelXSize, pixelYSize);
}
else if (cmbTransformType->currentText() == tr("Helmert"))
{
Expand All @@ -327,7 +328,8 @@ bool QgsPointDialog::generateWorldFile()
if (res == QMessageBox::Cancel)
return false;

QgsLeastSquares::helmert(mapCoords, pixelCoords, origin, pixelSize, rotation);
QgsLeastSquares::helmert(mapCoords, pixelCoords, origin, pixelXSize, rotation);
pixelYSize = pixelXSize;
}
else if (cmbTransformType->currentText() == tr("Affine"))
{
Expand Down Expand Up @@ -375,12 +377,12 @@ bool QgsPointDialog::generateWorldFile()
return false;
}
QTextStream stream(&file);
stream<<pixelSize<<endl
stream<<pixelXSize<<endl
<<0<<endl
<<0<<endl
<<-pixelSize<<endl
<<QString::number(origin.x() - xOffset * pixelSize, 'f')<<endl
<<QString::number(origin.y() + yOffset * pixelSize, 'f')<<endl;
<<-pixelYSize<<endl
<<QString::number(origin.x() - xOffset * pixelXSize, 'f')<<endl
<<QString::number(origin.y() + yOffset * pixelYSize, 'f')<<endl;
// write the data points in case we need them later
QFile pointFile(mLayer->source() + ".points");
if (pointFile.open(QIODevice::WriteOnly))
Expand Down

0 comments on commit 2f337ed

Please sign in to comment.