2025-02-17 09:13:18 +00:00
|
|
|
|
#include "QDEMResampleDialog.h"
|
|
|
|
|
#include "ui_QDEMResampleDialog.h"
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include "ImageOperatorBase.h"
|
|
|
|
|
|
|
|
|
|
QDEMResampleDialog::QDEMResampleDialog(QWidget *parent)
|
|
|
|
|
: QDialog(parent),ui(new Ui::QDEMResampleDialogClass)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
connect(ui->dialogBtn, SIGNAL(accepted()), this, SLOT(onAccepted()));
|
|
|
|
|
connect(ui->dialogBtn, SIGNAL(rejected()), this, SLOT(onRejected()));
|
|
|
|
|
|
|
|
|
|
connect(ui->DEMWSG84SelectBtn, SIGNAL(clicked(bool)), this, SLOT(onDEMWSG84SelectBtnClicked(bool)));
|
|
|
|
|
connect(ui->outDEMSelectBtn, SIGNAL(clicked(bool)), this, SLOT(onoutDEMSelectBtnClicked(bool)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDEMResampleDialog::~QDEMResampleDialog()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
void QDEMResampleDialog::onDEMWSG84SelectBtnClicked(bool flag)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>һ<EFBFBD><D2BB> .tif <20>ļ<EFBFBD>
|
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(this,
|
|
|
|
|
u8"DEM Raster Select", // <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
"", // <20><>ʼĿ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ·<CEAA><C2B7>
|
|
|
|
|
u8"tiff Files (*.tiff);;tif Files (*.tif);;dat Files (*.dat);;All Files (*.*)"); // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><CDB9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
if (!fileName.isEmpty()) {
|
|
|
|
|
this->ui->lineEditDEMLLA->setText(fileName);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
QMessageBox::information(this, u8"û<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>", u8"û<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><EFBFBD>ļ<EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QDEMResampleDialog::onoutDEMSelectBtnClicked(bool flag)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>һ<EFBFBD><D2BB> .tif <20>ļ<EFBFBD>
|
|
|
|
|
QString fileName = QFileDialog::getSaveFileName(this,
|
|
|
|
|
u8"DEM Raster Select", // <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
"", // <20><>ʼĿ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ·<CEAA><C2B7>
|
|
|
|
|
u8"tiff Files (*.tiff);;tif Files (*.tif);;dat Files (*.dat);;All Files (*.*)"); // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><CDB9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
if (!fileName.isEmpty()) {
|
|
|
|
|
this->ui->lineEditoutDEM->setText(fileName);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
QMessageBox::information(this, u8"û<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>", u8"û<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><EFBFBD>ļ<EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QDEMResampleDialog::onAccepted()
|
|
|
|
|
{
|
2025-03-12 02:23:09 +00:00
|
|
|
|
this->hide();
|
2025-02-17 09:13:18 +00:00
|
|
|
|
double gridx = ui->doubleSpinBoxGridX->value();
|
|
|
|
|
double gridy = ui->doubleSpinBoxGridY->value();
|
|
|
|
|
|
|
|
|
|
QString inDEMPath = ui->lineEditDEMLLA->text();
|
|
|
|
|
QString outDEMPath = ui->lineEditoutDEM->text();
|
|
|
|
|
|
|
|
|
|
gdalImage demimg(inDEMPath);
|
|
|
|
|
|
|
|
|
|
Eigen::MatrixXd srcgt = demimg.gt;
|
|
|
|
|
//
|
2025-02-19 07:06:59 +00:00
|
|
|
|
|
|
|
|
|
qDebug() << "----- src gt ------------------------------------";
|
|
|
|
|
qDebug() << QString("%1\t%2\t%3").arg(srcgt(0, 0)).arg(srcgt(0, 1)).arg(srcgt(0, 2));
|
|
|
|
|
qDebug() << QString("%1\t%2\t%3").arg(srcgt(1, 0)).arg(srcgt(1, 1)).arg(srcgt(1, 2));
|
|
|
|
|
qDebug() << "-----------------------------------------";
|
|
|
|
|
|
|
|
|
|
double Xscale = srcgt(0, 1)/gridx;
|
|
|
|
|
double Yscale = srcgt(1, 2)/gridy;
|
2025-02-17 09:13:18 +00:00
|
|
|
|
|
|
|
|
|
int new_width = ceil(Xscale * demimg.width) + 1;
|
|
|
|
|
int new_height = ceil(Yscale * demimg.height) + 1;
|
|
|
|
|
|
|
|
|
|
srcgt(0, 1) = gridx;
|
|
|
|
|
srcgt(1, 2) = gridy;
|
|
|
|
|
|
|
|
|
|
|
2025-02-19 07:06:59 +00:00
|
|
|
|
qDebug() << "target gt";
|
|
|
|
|
qDebug() << "----- target gt ------------------------------------";
|
|
|
|
|
qDebug() << QString("%1\t%2\t%3").arg(srcgt(0, 0)).arg(srcgt(0, 1)).arg(srcgt(0, 2));
|
|
|
|
|
qDebug() << QString("%1\t%2\t%3").arg(srcgt(1, 0)).arg(srcgt(1, 1)).arg(srcgt(1, 2));
|
|
|
|
|
qDebug() << "-----------------------------------------";
|
|
|
|
|
|
2025-02-17 09:13:18 +00:00
|
|
|
|
std::shared_ptr<double> gt(new double[6]);
|
|
|
|
|
gt.get()[0] = srcgt(0, 0);
|
|
|
|
|
gt.get()[1] = srcgt(0, 1);
|
|
|
|
|
gt.get()[2] = srcgt(0, 2);
|
|
|
|
|
gt.get()[3] = srcgt(1, 0);
|
|
|
|
|
gt.get()[4] = srcgt(1, 1);
|
|
|
|
|
gt.get()[5] = srcgt(1, 2);
|
|
|
|
|
|
|
|
|
|
qDebug() << "DEM ReSample start ...";
|
2025-02-19 07:06:59 +00:00
|
|
|
|
qDebug() << "height:\t" << new_height;
|
|
|
|
|
qDebug() << "width:\t" << new_width;
|
|
|
|
|
|
|
|
|
|
qDebug() << ResampleGDAL(inDEMPath.toLocal8Bit().constData(),
|
2025-02-17 09:13:18 +00:00
|
|
|
|
outDEMPath.toLocal8Bit().constData(), gt.get(), new_width, new_height, GDALResampleAlg::GRA_Bilinear);
|
|
|
|
|
|
|
|
|
|
qDebug() << "DEM ReSample finished!!!";
|
2025-03-12 02:23:09 +00:00
|
|
|
|
this->show();
|
|
|
|
|
QMessageBox::information(this, tr(u8"<EFBFBD><EFBFBD>ʾ"), tr(u8"completed!!!"));
|
2025-02-17 09:13:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QDEMResampleDialog::onRejected()
|
|
|
|
|
{
|
|
|
|
|
this->close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|