构建完整批量处理GF3

Release-dev
chenzenghui 2025-05-22 17:28:20 +08:00
parent 8d80a9ff6e
commit fc4bdf7904
9 changed files with 91 additions and 52 deletions

View File

@ -269,8 +269,8 @@ bool BASECONSTVARIABLEAPI unTarfile(QString inTargzPath, QString outGzFolderPath
// tar -zxvf 压缩包路径 文件或目录路径 // tar -zxvf 压缩包路径 文件或目录路径
QProcess process; QProcess process;
// 同步执行(阻塞当前线程) // 同步执行(阻塞当前线程)
QString cmdstr = QString("tar -zxvf %1 %2").arg(inTargzPath).arg(outGzFolderPath); QString cmdstr = QString("tar -zxvf %1 -C %2").arg(inTargzPath).arg(outGzFolderPath);
process.start("cmd.exe", QStringList() << "/c" << cmdstr); // "/c" 表示执行后关闭 CMD process.execute("cmd.exe", QStringList() << "/c" << cmdstr); // "/c" 表示执行后关闭 CMD
process.waitForFinished(); // 等待执行完成 process.waitForFinished(); // 等待执行完成
// 获取输出 // 获取输出
QString output = QString::fromLocal8Bit(process.readAllStandardOutput()); QString output = QString::fromLocal8Bit(process.readAllStandardOutput());

View File

@ -252,13 +252,15 @@ ErrorCode RD_PSTN(double& refrange, double& lamda, double& timeR, double& R, dou
inct = dt*(dplerTheory2-dplerNumber1) / (dplerTheory2 - dplerTheory1); inct = dt*(dplerTheory2-dplerNumber1) / (dplerTheory2 - dplerTheory1);
if (std::abs(dplerNumber1 - dplerTheory2) < 1e-6 || std::abs(inct) < 1.0e-4) { if (std::abs(dplerNumber1 - dplerTheory2) < 1e-6 || std::abs(inct) < 1.0e-4) {
R = R1; // 斜距
return ErrorCode::SUCCESS;
break; break;
} }
inct = std::abs(inct) < 10 ?inct:inct*1e-2; inct = std::abs(inct) < 10 ?inct:inct*1e-2;
timeR = timeR - inct; timeR = timeR - inct;
} }
R = R1; // б¾à return ErrorCode::FAIL;
return ErrorCode::SUCCESS;
} }
ErrorCode GF3RDCreateLookTable(QString inxmlPath, QString indemPath, QString outworkdir, QString outlooktablePath,QString outLocalIncidenceAnglePath,bool localincAngleFlag) ErrorCode GF3RDCreateLookTable(QString inxmlPath, QString indemPath, QString outworkdir, QString outlooktablePath,QString outLocalIncidenceAnglePath,bool localincAngleFlag)
@ -574,8 +576,8 @@ ErrorCode GF3RDProcess(QString inxmlPath, QString indemPath, QString outworkdir,
long sourceespgcode = getProjectEPSGCodeByLon_Lat(centerlon, centerlat); long sourceespgcode = getProjectEPSGCodeByLon_Lat(centerlon, centerlat);
long demespgcode = GetEPSGFromRasterFile(indemPath); long demespgcode = GetEPSGFromRasterFile(indemPath);
double grid_resolution = gridx < gridy ? gridx : gridy; double grid_resolution = gridx < gridy ? gridx : gridy;
double degreePerPixelX = grid_resolution / 110000.0; double degreePerPixelX = getPixelSpacingInDegree(grid_resolution);
double degreePerPixelY = grid_resolution / 110000.0; double degreePerPixelY = getPixelSpacingInDegree(grid_resolution);
bool meter2degreeflag = ConvertResolutionToDegrees( bool meter2degreeflag = ConvertResolutionToDegrees(
sourceespgcode, sourceespgcode,
grid_resolution, grid_resolution,
@ -586,8 +588,8 @@ ErrorCode GF3RDProcess(QString inxmlPath, QString indemPath, QString outworkdir,
); );
if (!meter2degreeflag) { if (!meter2degreeflag) {
qDebug() << u8"转换分辨率为经纬度失败"; qDebug() << u8"转换分辨率为经纬度失败";
degreePerPixelX = grid_resolution / 110000.0; degreePerPixelX = getPixelSpacingInDegree(grid_resolution);
degreePerPixelY = grid_resolution / 110000.0; degreePerPixelY = getPixelSpacingInDegree(grid_resolution);
} }
qDebug() << u8"DEM影像范围:"; qDebug() << u8"DEM影像范围:";
qDebug() << u8"输入分辨率:"<<gridx<<" \t" << gridy; qDebug() << u8"输入分辨率:"<<gridx<<" \t" << gridy;
@ -616,24 +618,33 @@ ErrorCode GF3RDProcess(QString inxmlPath, QString indemPath, QString outworkdir,
ErrorCode GF3MainOrthProcess(QString inDEMPath, QString inTarFilepath, QString outworkspacefolderpath, double pixelresultionDegreee, bool excutehh2vv) ErrorCode GF3MainOrthProcess(QString inDEMPath, QString inTarFilepath, QString outworkspacefolderpath, double pixelresultionDegreee, bool excutehh2vv)
{ {
QProgressDialog progressDialog(u8"正射校正处理", u8"", 0, 6);
progressDialog.setWindowTitle(u8"正射校正处理");
progressDialog.setWindowModality(Qt::WindowModal);
progressDialog.setAutoClose(true);
progressDialog.setValue(0);
progressDialog.setMaximum(6);
progressDialog.setMinimum(0);
progressDialog.show();
qDebug() << u8"开始正射校正处理"; qDebug() << u8"开始正射校正处理";
// 获取任务名称 // 获取任务名称
QString tarfilename = getFileNameWidthoutExtend(inTarFilepath); QString tarfilename = getFileNameWidthoutExtend(inTarFilepath);
// step 1. 创建工作空间 // step 1. 创建工作空间
GF3TargzFilenameClass tarnameclss=getFilename(tarfilename); GF3TargzFilenameClass tarnameclss=getFilename(tarfilename);
QString productionname = tarnameclss.getProductName(); QString productionname = tarnameclss.getProductName();
QString workfolderpath = JoinPath(outworkspacefolderpath, productionname); // 工作空间 QString workfolderpath = JoinPath(outworkspacefolderpath, productionname); // 工作空间
createNewFolerPath(workfolderpath, true); createNewFolerPath(workfolderpath, true);
qDebug() << u8"step 1. 创建工作空间 ok"; qDebug() << u8"step 1. 创建工作空间 ok";
progressDialog.setValue(1);
// step 2.解压文件 // step 2.解压文件
QString unarchiverFolderPath = JoinPath(workfolderpath, u8"unarchiver"); QString unarchiverFolderPath = JoinPath(workfolderpath, u8"unarchiver");
createNewFolerPath(unarchiverFolderPath, true); createNewFolerPath(unarchiverFolderPath, true);
unTarfile(inTarFilepath, unarchiverFolderPath); unTarfile(inTarFilepath, unarchiverFolderPath);
qDebug() << u8"step 2.解压文件 ok"; qDebug() << u8"step 2.解压文件 ok";
progressDialog.setValue(2);
// 在解压文件夹中以及子文件夹查找meta.xml文件 // 在解压文件夹中以及子文件夹查找meta.xml文件
QFileInfoList metalist = findFilePath(unarchiverFolderPath, u8"*.meta.xml"); QFileInfoList metalist = findFilePath(unarchiverFolderPath, u8"*.meta.xml");
if (metalist.count() !=1) { if (metalist.count() !=1) {
@ -649,7 +660,7 @@ ErrorCode GF3MainOrthProcess(QString inDEMPath, QString inTarFilepath, QString o
createNewFolerPath(L1AFolder); createNewFolerPath(L1AFolder);
ImportGF3L1AProcess(metaxmlpath, L1AFolder); ImportGF3L1AProcess(metaxmlpath, L1AFolder);
qDebug() << u8"step 3.文件转换为通用L1A文件 ok"; qDebug() << u8"step 3.文件转换为通用L1A文件 ok";
progressDialog.setValue(3);
// step 4. 幅度转amp // step 4. 幅度转amp
QFileInfoList xmlfilelist = findFilePath(L1AFolder, u8"*.xml"); QFileInfoList xmlfilelist = findFilePath(L1AFolder, u8"*.xml");
if (xmlfilelist.count() == 0) { if (xmlfilelist.count() == 0) {
@ -670,7 +681,7 @@ ErrorCode GF3MainOrthProcess(QString inDEMPath, QString inTarFilepath, QString o
SARSimulationImageL1Dataset l1B(RasterLevel::RasterL1B); SARSimulationImageL1Dataset l1B(RasterLevel::RasterL1B);
l1B.OpenOrNew(workfolderpath, l2bfilename, slcl1.getrowCount(), slcl1.getcolCount()); l1B.OpenOrNew(outampfolder, l2bfilename, slcl1.getrowCount(), slcl1.getcolCount());
QString srcxmlpath = slcl1.getxmlFilePath(); QString srcxmlpath = slcl1.getxmlFilePath();
QString tarxmlpath = l1B.getxmlFilePath(); QString tarxmlpath = l1B.getxmlFilePath();
copyAndReplaceFile(srcxmlpath, tarxmlpath); copyAndReplaceFile(srcxmlpath, tarxmlpath);
@ -678,20 +689,21 @@ ErrorCode GF3MainOrthProcess(QString inDEMPath, QString inTarFilepath, QString o
QString imgfilepath = slcl1.getImageRasterPath(); QString imgfilepath = slcl1.getImageRasterPath();
Complex2AmpRaster(imgfilepath, l1B.getImageRasterPath()); // 转振幅 Complex2AmpRaster(imgfilepath, l1B.getImageRasterPath()); // 转振幅
} }
progressDialog.setValue(4);
// step 5. 创建正射查找表 // step 5. 创建正射查找表
QString L1AXmlPath = xmlfilelist[0].canonicalFilePath(); QString L1AXmlPath = xmlfilelist[0].canonicalFilePath();
QString looktablefolderpath = JoinPath(workfolderpath, u8"looktableRaster"); QString looktablefolderpath = JoinPath(workfolderpath, u8"looktableRaster");
createNewFolerPath(looktablefolderpath);
if (GF3RDProcess(L1AXmlPath, inDEMPath, looktablefolderpath, pixelresultionDegreee, pixelresultionDegreee) == SUCCESS) { if (GF3RDProcess(L1AXmlPath, inDEMPath, looktablefolderpath, pixelresultionDegreee, pixelresultionDegreee) == SUCCESS) {
qDebug()<<(u8"正射表生成成功"); qDebug()<<(u8"正射表生成成功");
} }
else { else {
qDebug() << (u8"正射表生成失败"); qDebug() << (u8"正射表生成失败");
} }
progressDialog.setValue(5);
qDebug() << u8"step 4. 创建正射查找表 ok"; qDebug() << u8"step 4. 创建正射查找表 ok";
// step 6. 影像正射 // step 6. 影像正射
QFileInfoList looktableRasterPathList = findFilePath(looktablefolderpath, u8"_looktable.tif"); QFileInfoList looktableRasterPathList = findFilePath(looktablefolderpath, u8"*_looktable.tif");
if (looktableRasterPathList.count() != 1) { if (looktableRasterPathList.count() != 1) {
qWarning() << u8"目标文件夹发现了多个查找表,不符合规则"; qWarning() << u8"目标文件夹发现了多个查找表,不符合规则";
QMessageBox::warning(nullptr, u8"警告", QString(u8"%1:%2").arg(tarfilename).arg(u8"目标文件夹发现了多个查找表,不符合规则")); QMessageBox::warning(nullptr, u8"警告", QString(u8"%1:%2").arg(tarfilename).arg(u8"目标文件夹发现了多个查找表,不符合规则"));
@ -699,48 +711,52 @@ ErrorCode GF3MainOrthProcess(QString inDEMPath, QString inTarFilepath, QString o
} }
// step 6.1 影像入射角 // step 6.1 影像入射角
QFileInfoList looktableAngleRasterPathList = findFilePath(looktablefolderpath, u8"_localAngle.tif"); QFileInfoList looktableAngleRasterPathList = findFilePath(looktablefolderpath, u8"*_localAngle.tif");
if (looktableAngleRasterPathList.count() != 1) { if (looktableAngleRasterPathList.count() != 1) {
qWarning() << u8"目标文件夹应该只有1个入射角,不符合规则"; qWarning() << u8"目标文件夹应该只有1个入射角,不符合规则";
QMessageBox::warning(nullptr, u8"警告", QString(u8"%1:%2").arg(tarfilename).arg(u8"目标文件夹发现了1个入射角,不符合规则")); QMessageBox::warning(nullptr, u8"警告", QString(u8"%1:%2").arg(tarfilename).arg(u8"目标文件夹发现了1个入射角,不符合规则"));
return ErrorCode::METAXMLFOUNDERROR; return ErrorCode::METAXMLFOUNDERROR;
} }
QString lookincidenceAnglePath = looktableAngleRasterPathList[0].canonicalFilePath(); QString lookincidenceAnglePath = looktableAngleRasterPathList[0].canonicalFilePath();
QString looktableRasterPath = looktableRasterPathList[0].canonicalFilePath(); QString looktableRasterPath = looktableRasterPathList[0].canonicalFilePath();
QString outworkpath = JoinPath(workfolderpath, u8"orth"); QString outworkpath = JoinPath(workfolderpath, u8"orth");
createNewFolerPath(outworkpath, true);
QFileInfoList l2filelist = findFilePath(outampfolder,u8"*.xml"); QFileInfoList l2filelist = findFilePath(outampfolder,u8"*.xml");
for (long i = 0; i < l2filelist.count(); i++) { for (long i = 0; i < l2filelist.count(); i++) {
QString inl2filepath = l2filelist[i].canonicalFilePath(); QString inl2filepath = l2filelist[i].canonicalFilePath();
SARSimulationImageL1Dataset l1B(RasterLevel::RasterL1B); SARSimulationImageL1Dataset l1B(RasterLevel::RasterL1B);
l1B.Open(inl2filepath); l1B.Open(inl2filepath);
QString inRaster = l1B.getImageRasterPath(); QString inRaster = l1B.getImageRasterPath();
QString inRasterfolderpath = l1B.getoutFolderPath(); QString outname = getFileNameWidthoutExtend(inRaster) + "_orth.tif";
QString inRastername = l1B.getImageRasterName();
POLARTYPEENUM poltype = getDatasetGF3FilePolsarType(inRastername);
QString intempHH2VV = inRaster;
if (poltype == POLARHH && excutehh2vv) {
intempHH2VV = JoinPath(inRasterfolderpath, getFileNameWidthoutExtend(inRaster) + "_HH2VV.tif");
GF3_Sigma0_HH2VV(inRaster, looktableRasterPath,intempHH2VV);
}
QString outname = getFileNameWidthoutExtend(intempHH2VV) + "_orth.tif";
QString outstringpath = JoinPath(outworkpath, outname); QString outstringpath = JoinPath(outworkpath, outname);
if (GF3OrthSLC(intempHH2VV, looktableRasterPath, outstringpath) == SUCCESS) { if (GF3OrthSLC(inRaster, looktableRasterPath, outstringpath) == SUCCESS) {
qDebug() << (u8"正射生成成功"); qDebug() << (u8"正射生成成功");
} }
else { else {
qDebug() << (u8"正射生成失败"); qDebug() << (u8"正射生成失败");
} }
} qDebug() << u8"step 5. 正射影像生成 ok";
// step 6.2 生成HH2VV
POLARTYPEENUM poltype = getDatasetGF3FilePolsarType(outname);
if (poltype == POLARHH && excutehh2vv) {
qDebug() << u8"HH2VV生成中:"<< outstringpath;
QString intempHH2VV = JoinPath(outworkpath, getFileNameWidthoutExtend(outstringpath) + "_HH2VV_dB.tif");
GF3_Sigma0_HH2VV(outstringpath, looktableRasterPath,intempHH2VV);
}
else {
// 将amp转换为sigma0
QString intempHH2VV = JoinPath(outworkpath, getFileNameWidthoutExtend(outstringpath) + "_HH2VV_dB.tif");
amp2dBRaster(outstringpath, intempHH2VV);
//qDebug() << u8"HH2VV不需要生成";
}
qDebug() << u8"step 6. HH2VV生成 ok";
}
progressDialog.setValue(6);
return ErrorCode::SUCCESS; return ErrorCode::SUCCESS;
} }

View File

@ -26,7 +26,6 @@
int GF3CALIBRATIONANDORTHLIB_EXPORT GF3_Sigma0_HH2VV(QString in_SigmaHHRasterPath, QString in_IncidencAngleRasterPath, QString out_SigmaVVRasterPath, SIGMATYPE sigmatype= SIGMATYPE::AMPVALUE); int GF3CALIBRATIONANDORTHLIB_EXPORT GF3_Sigma0_HH2VV(QString in_SigmaHHRasterPath, QString in_IncidencAngleRasterPath, QString out_SigmaVVRasterPath, SIGMATYPE sigmatype= SIGMATYPE::AMPVALUE);
#endif #endif

View File

@ -111,7 +111,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation> <GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
</Link> </Link>

View File

@ -19,6 +19,7 @@ QGF3StripBatchProcessDialog::QGF3StripBatchProcessDialog(QWidget *parent)
QObject::connect(ui->checkBoxDEM, SIGNAL(stateChanged(int)), this, SLOT(ontstateChanged(int))); QObject::connect(ui->checkBoxDEM, SIGNAL(stateChanged(int)), this, SLOT(ontstateChanged(int)));
QObject::connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(onreject())); QObject::connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(onreject()));
QObject::connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(onaccept())); QObject::connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(onaccept()));
QObject::connect(ui->pushButton_lineDEM, SIGNAL(clicked(bool)), this, SLOT(onpushButtonDEM(bool)));
@ -40,21 +41,23 @@ void QGF3StripBatchProcessDialog::onaccept()
} }
// »ñÈ¡·Ö±æÂÊ // »ñÈ¡·Ö±æÂÊ
double resolutionMeter = ui->doubleSpinBox->value();// ·Ö±æÂÊת¶È double resolutionMeter = ui->doubleSpinBox->value();// ·Ö±æÂÊת¶È
double resoiutionDegree = getPixelSpacingInDegree(resolutionMeter);// Ã× -> ¶È //double resoiutionDegree = getPixelSpacingInDegree(resolutionMeter);// 米 -> 度
QString workspacedirpath = ui->lineEditWorkDir->text(); QString workspacedirpath = ui->lineEditWorkDir->text();
this->ui->progressBar->setValue(0); this->ui->progressBar->setValue(0);
this->ui->progressBar->setMaximum(ui->listWidgetMetaxml->count()); this->ui->progressBar->setMaximum(ui->listWidgetMetaxml->count());
bool polarHH2VV = ui->checkoutPolarHH2VV->isChecked();
for (long i = 0; i < ui->listWidgetMetaxml->count(); i++) { for (long i = 0; i < ui->listWidgetMetaxml->count(); i++) {
QString inTargzFilePath = ui->listWidgetMetaxml->item(i)->text(); QString inTargzFilePath = ui->listWidgetMetaxml->item(i)->text();
this->ui->label_info->setText(QString(u8"正射处理:%1").arg(inTargzFilePath));
GF3MainOrthProcess(demPath, GF3MainOrthProcess(demPath,
inTargzFilePath, inTargzFilePath,
workspacedirpath, workspacedirpath,
resoiutionDegree, resolutionMeter,
true); polarHH2VV);
this->ui->progressBar->setValue(i); this->ui->progressBar->setValue(i);
} }
QMessageBox::information(this, u8"正射处理完成", u8"正射处理完成");
} }
void QGF3StripBatchProcessDialog::onreject() void QGF3StripBatchProcessDialog::onreject()
@ -117,6 +120,17 @@ void QGF3StripBatchProcessDialog::ontstateChanged(int checked)
} }
} }
void QGF3StripBatchProcessDialog::onpushButtonDEM(bool flag)
{
QString fileName = QFileDialog::getOpenFileName(this, u8"选择DEM文件", "", u8"tif (*.tif);;All Files (*)");
if (!fileName.isEmpty()) {
ui->lineEdit_DEM->setText(fileName);
}
else {
QMessageBox::information(this, u8"没有选择文件", u8"没有选择任何文件");
}
}
void showQGF3StripBatchProcessDialog(QWidget* parent) void showQGF3StripBatchProcessDialog(QWidget* parent)
{ {
QGF3StripBatchProcessDialog* dialog = new QGF3StripBatchProcessDialog(parent); QGF3StripBatchProcessDialog* dialog = new QGF3StripBatchProcessDialog(parent);

View File

@ -24,7 +24,7 @@ public slots:
void onpushButtonWorkSpaceClicked(bool); void onpushButtonWorkSpaceClicked(bool);
void ontstateChanged(int checked); void ontstateChanged(int checked);
void onpushButtonDEM(bool flag);
private: private:
Ui::QGF3StripBatchProcessDialogClass* ui; Ui::QGF3StripBatchProcessDialogClass* ui;

View File

@ -175,6 +175,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2">
<widget class="QCheckBox" name="checkoutPolarHH2VV">
<property name="text">
<string>极化转换:HH-&gt;VV</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -12,6 +12,7 @@
#include <QDateTime> #include <QDateTime>
#include <QFile> #include <QFile>
#include <QTextStream> #include <QTextStream>
#include <iostream>
#pragma execution_character_set("utf-8") #pragma execution_character_set("utf-8")
@ -27,7 +28,6 @@ void customMessageHandler(QtMsgType type, const QMessageLogContext& context, con
outFile.open(QIODevice::WriteOnly | QIODevice::Append); outFile.open(QIODevice::WriteOnly | QIODevice::Append);
QTextStream ts(&outFile); QTextStream ts(&outFile);
switch (type) { switch (type) {
case QtDebugMsg: case QtDebugMsg:
{ {
@ -38,7 +38,8 @@ void customMessageHandler(QtMsgType type, const QMessageLogContext& context, con
.arg(context.line) .arg(context.line)
.arg(function); .arg(function);
ts << logMessage << "\n"; ts << logMessage << "\n";
break; std::cout << logMessage.toLocal8Bit().constData() << std::endl;
break;
} }
case QtInfoMsg: case QtInfoMsg:
{ {
@ -49,7 +50,8 @@ void customMessageHandler(QtMsgType type, const QMessageLogContext& context, con
.arg(context.line) .arg(context.line)
.arg(function); .arg(function);
ts << logMessage << "\n"; ts << logMessage << "\n";
break; std::cout << logMessage.toLocal8Bit().constData() << std::endl;
break;
} }
case QtWarningMsg: case QtWarningMsg:
{ {
@ -71,7 +73,8 @@ void customMessageHandler(QtMsgType type, const QMessageLogContext& context, con
.arg(context.line) .arg(context.line)
.arg(function); .arg(function);
ts << logMessage << "\n"; ts << logMessage << "\n";
break; std::cout << logMessage.toLocal8Bit().constData() << std::endl;
break;
} }
case QtFatalMsg: case QtFatalMsg:
{ {
@ -82,19 +85,19 @@ void customMessageHandler(QtMsgType type, const QMessageLogContext& context, con
.arg(context.line) .arg(context.line)
.arg(function); .arg(function);
ts << logMessage << "\n"; ts << logMessage << "\n";
abort(); std::cout << logMessage.toLocal8Bit().constData() << std::endl;
abort();
} }
} }
} }
int main(int argc, char *argv[]) int main(int argc, char* argv[])
{ {
qInstallMessageHandler(customMessageHandler); qInstallMessageHandler(customMessageHandler);
QApplication a(argc, argv); QApplication a(argc, argv);
showQGF3StripBatchProcessDialog(nullptr); showQGF3StripBatchProcessDialog(nullptr);
return a.exec(); return a.exec();
} }

Binary file not shown.