Skip to content
Permalink
Browse files
Georeferencer plugin: enable creation of nonrectangular pixels in lin…
…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 2f337ed2db0b931cdf7ecd262f1e51acc36428ad
Showing with 13 additions and 11 deletions.
  1. +3 −3 src/plugins/georeferencer/qgsleastsquares.cpp
  2. +1 −1 src/plugins/georeferencer/qgsleastsquares.h
  3. +9 −7 src/plugins/georeferencer/qgspointdialog.cpp
@@ -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 "
@@ -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);
}


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

}

@@ -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,
@@ -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;
@@ -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"))
{
@@ -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"))
{
@@ -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))

0 comments on commit 2f337ed

Please sign in to comment.