合并仿真、成像、影像合并的代码

Release
陈增辉 2024-11-25 09:30:14 +08:00
parent 3c2d1bcc7f
commit 81a8326364
46 changed files with 46549 additions and 19 deletions

Binary file not shown.

1
GF3PSTNClass.cpp Normal file
View File

@ -0,0 +1 @@
#include "GF3PSTNClass.h"

View File

@ -0,0 +1,358 @@
#include "GF3CalibrationAndGeocodingClass.h"
#include "SatelliteGF3xmlParser.h"
#include <QRegularExpression>
#include <QMessageBox>
ErrorCode GF3CalibrationRaster(QString inRasterPath, QString outRasterPath, double Qualifyvalue, double calibrationConst)
{
gdalImage imgraster(inRasterPath.toUtf8().constData());
if (!isExists(outRasterPath)) {
gdalImageComplex outraster = CreategdalImageComplex(outRasterPath, imgraster.height, imgraster.width, 1, imgraster.gt, imgraster.projection, false, true);
}
gdalImageComplex outraster(outRasterPath);
long blocklines = Memory1GB * 2 /8/ imgraster.width;
blocklines = blocklines < 100 ? 100 : blocklines;
Eigen::MatrixXd imgArrb1 = Eigen::MatrixXd::Zero(blocklines, imgraster.width);
Eigen::MatrixXd imgArrb2 = Eigen::MatrixXd::Zero(blocklines, imgraster.width);
Eigen::MatrixXcd imgArr = Eigen::MatrixXcd::Zero(blocklines, imgraster.width);
double quayCoff = Qualifyvalue * 1.0 / 32767;
double caliCoff = std::pow(10.0, (calibrationConst * 1.0 / 20));
qDebug() << "定标系数:\t" << quayCoff / caliCoff;
long startrow = 0;
for (startrow = 0; startrow < imgraster.height; startrow = startrow + blocklines) {
imgArrb1 = imgraster.getData(startrow, 0, blocklines, imgraster.width, 1);
imgArrb2 = imgraster.getData(startrow, 0, blocklines, imgraster.width, 2);
imgArr = outraster.getDataComplex(startrow, 0, blocklines, outraster.width, 1);
imgArr.real() = imgArrb1.array() * quayCoff / caliCoff;
imgArr.imag() = imgArrb2.array() * quayCoff / caliCoff;
outraster.saveImage(imgArr, startrow, 0, 1);
}
qDebug() << "影像写入到:" << outRasterPath;
return ErrorCode::SUCCESS;
}
ErrorCode ImportGF3L1ARasterToWorkspace(QString inMetaxmlPath, QString inRasterPath, QString outWorkDirPath, POLARTYPEENUM polsartype)
{
SatelliteGF3xmlParser gf3xml;
gf3xml.loadFile(inMetaxmlPath);
QString filename = getFileNameWidthoutExtend(inRasterPath);
SARSimulationImageL1Dataset l1dataset;
l1dataset.OpenOrNew(outWorkDirPath, filename,gf3xml.height,gf3xml.width);
l1dataset.setSateAntPos(SatellitePos2SatelliteAntPos(gf3xml.antposs));
l1dataset.setCenterFreq(gf3xml.RadarCenterFrequency);
l1dataset.setcolCount(gf3xml.width);
l1dataset.setrowCount(gf3xml.height);
l1dataset.setNearRange(gf3xml.nearRange);
l1dataset.setRefRange(gf3xml.refRange);
l1dataset.setFs(gf3xml.eqvFs);
l1dataset.setPRF(gf3xml.eqvPRF);
l1dataset.setCenterAngle((gf3xml.incidenceAngleNearRange + gf3xml.incidenceAngleFarRange) / 2.0); // 入射角
l1dataset.setDopplerParametersReferenceTime(gf3xml.DopplerParametersReferenceTime);
l1dataset.setTotalProcessedAzimuthBandWidth(gf3xml.TotalProcessedAzimuthBandWidth);
l1dataset.setIncidenceAngleFarRange(gf3xml.incidenceAngleFarRange);
l1dataset.setIncidenceAngleNearRangeet(gf3xml.incidenceAngleNearRange);
l1dataset.setDopplerParams(gf3xml.d0, gf3xml.d1, gf3xml.d2, gf3xml.d3, gf3xml.d4);
l1dataset.setDopplerCenterCoff(gf3xml.r0, gf3xml.r1,gf3xml.r2, gf3xml.r3, gf3xml.r4);
l1dataset.setLatitudeCenter(gf3xml.latitude_center);
l1dataset.setLongitudeCenter(gf3xml.longitude_center);
l1dataset.setLatitudeTopLeft(gf3xml.latitude_topLeft);
l1dataset.setLongitudeTopLeft(gf3xml.longitude_topLeft);
l1dataset.setLatitudeTopRight(gf3xml.latitude_topRight);
l1dataset.setLongitudeTopRight(gf3xml.longitude_topRight);
l1dataset.setLatitudeBottomLeft(gf3xml.latitude_bottomLeft);
l1dataset.setLongitudeBottomLeft(gf3xml.longitude_bottomLeft);
l1dataset.setLatitudeBottomRight(gf3xml.latitude_bottomRight);
l1dataset.setLongitudeBottomRight(gf3xml.longitude_bottomRight);
l1dataset.setStartImageTime(gf3xml.start);
l1dataset.setEndImageTime(gf3xml.end);
l1dataset.saveToXml();
QString outRasterpath = l1dataset.getImageRasterPath();
ErrorCode errorcode = ErrorCode::SUCCESS;
qDebug() << "导入数据:\t"<<inRasterPath;
switch (polsartype)
{
case POLARHH:
qDebug() << "极化HH";
errorcode=GF3CalibrationRaster(inRasterPath, outRasterpath, gf3xml.HH_QualifyValue, gf3xml.HH_CalibrationConst);
break;
case POLARHV:
qDebug() << "极化HH";
errorcode = GF3CalibrationRaster(inRasterPath, outRasterpath, gf3xml.HV_QualifyValue, gf3xml.HV_CalibrationConst);
break;
case POLARVH:
qDebug() << "极化VH";
errorcode = GF3CalibrationRaster(inRasterPath, outRasterpath, gf3xml.VH_QualifyValue, gf3xml.VH_CalibrationConst);
break;
case POLARVV:
qDebug() << "极化VV";
errorcode = GF3CalibrationRaster(inRasterPath, outRasterpath, gf3xml.VV_QualifyValue, gf3xml.VV_CalibrationConst);
break;
default:
break;
}
qDebug() << "导入数据状态:\t" << QString::fromStdString(errorCode2errInfo(errorcode));
return errorcode;
}
QVector<QString> SearchGF3DataTiff(QString inMetaxmlPath)
{
// 指定路径
QString xmlpath = inMetaxmlPath; // 替换为你的实际路径
QString absPath = QFileInfo(xmlpath).absolutePath();
// 获取路径所在的目录
QDir directory(absPath);
if (!directory.exists()) {
qDebug() << "Directory does not exist:" << directory.absolutePath();
return QVector<QString>(0);
}
// 设置过滤器以仅列出 .tif 文件
QStringList filters;
filters << "*.tif" << "*.TIF" << "*.tiff" << "*.TIFF";
QStringList files = directory.entryList(filters, QDir::Files);
qDebug() << "TIFF Files in the directory" << directory.absolutePath() << ":";
QVector<QString> filepath(0);
for (long i = 0; i < files.count(); i++) {
filepath.append(JoinPath(absPath, files[i]));
}
return filepath;
}
POLARTYPEENUM getDatasetGF3FilePolsarType(QString fileName)
{
// 提取极化情况
QRegularExpression re("_([A-Z]{2})_");
QRegularExpressionMatch match = re.match(fileName);
QString polarization = "";
if (match.hasMatch()) {
polarization = match.captured(1);
polarization = polarization.toLower().replace("_", "");
qDebug() << "Polarization extracted:" << polarization;
if (polarization == "hh") {
return POLARTYPEENUM::POLARHH;
}
else if (polarization == "hv") {
return POLARTYPEENUM::POLARHV;
}
else if (polarization == "vh") {
return POLARTYPEENUM::POLARVH;
}
else if (polarization == "vv") {
return POLARTYPEENUM::POLARVV;
}
else {
return POLARTYPEENUM::POLARUNKOWN;
}
}
else {
qDebug() << "No polarization found in the path.";
return POLARTYPEENUM::POLARUNKOWN;
}
return POLARTYPEENUM::POLARUNKOWN;
}
ErrorCode ImportGF3L1AProcess(QString inMetaxmlPath, QString outWorkDirPath)
{
QVector<QString> tiffpaths = SearchGF3DataTiff(inMetaxmlPath);
ErrorCode errorcode = ErrorCode::SUCCESS;
for (long i = 0; i < tiffpaths.count(); i++) {
QString tiffpath = tiffpaths[i];
QString filenamewithoutextern = getFileNameWidthoutExtend(tiffpath);
QString filename = getFileNameFromPath(tiffpath);
POLARTYPEENUM poltype = getDatasetGF3FilePolsarType(filename);
switch (poltype)
{
case POLARHH:
errorcode=ImportGF3L1ARasterToWorkspace(inMetaxmlPath, tiffpath, outWorkDirPath, POLARTYPEENUM::POLARHH);
break;
case POLARHV:
errorcode=ImportGF3L1ARasterToWorkspace(inMetaxmlPath, tiffpath, outWorkDirPath, POLARTYPEENUM::POLARHV);
break;
case POLARVH:
errorcode=ImportGF3L1ARasterToWorkspace(inMetaxmlPath, tiffpath, outWorkDirPath, POLARTYPEENUM::POLARVH);
break;
case POLARVV:
errorcode=ImportGF3L1ARasterToWorkspace(inMetaxmlPath, tiffpath, outWorkDirPath, POLARTYPEENUM::POLARVV);
break;
case POLARUNKOWN:
break;
default:
break;
}
if (errorcode == ErrorCode::SUCCESS) {
return errorcode;
}
else {
QMessageBox::warning(nullptr, u8"错误", u8"数据导入错误");
break;
}
}
return errorcode;
}
ErrorCode Complex2AmpRaster(QString inComplexPath, QString outRasterPath)
{
gdalImageComplex inimg(inComplexPath);
gdalImage ampimg= CreategdalImage(outRasterPath, inimg.height, inimg.width, inimg.band_num, inimg.gt, inimg.projection, true, true);
long blocklines = Memory1GB * 2 / 8 / inimg.width;
blocklines = blocklines < 100 ? 100 : blocklines;
Eigen::MatrixXd imgArrb1 = Eigen::MatrixXd::Zero(blocklines, ampimg.width);
Eigen::MatrixXcd imgArr = Eigen::MatrixXcd::Zero(blocklines, inimg.width);
long startrow = 0;
for (startrow = 0; startrow < inimg.height; startrow = startrow + blocklines) {
imgArrb1 = ampimg.getData(startrow, 0, blocklines, inimg.width, 1);
imgArr = inimg.getData(startrow, 0, blocklines, inimg.width, 2);
imgArrb1 = imgArr.array().abs();
ampimg.saveImage(imgArrb1, startrow, 0, 1);
}
qDebug() << "影像写入到:" << outRasterPath;
return ErrorCode::SUCCESS;
}
ErrorCode Complex2PhaseRaster(QString inComplexPath, QString outRasterPath)
{
gdalImageComplex inimg(inComplexPath);
gdalImage ampimg = CreategdalImage(outRasterPath, inimg.height, inimg.width, inimg.band_num, inimg.gt, inimg.projection, true, true);
long blocklines = Memory1GB * 2 / 8 / inimg.width;
blocklines = blocklines < 100 ? 100 : blocklines;
Eigen::MatrixXd imgArrb1 = Eigen::MatrixXd::Zero(blocklines, ampimg.width);
Eigen::MatrixXcd imgArr = Eigen::MatrixXcd::Zero(blocklines, inimg.width);
long startrow = 0;
for (startrow = 0; startrow < inimg.height; startrow = startrow + blocklines) {
imgArrb1 = ampimg.getData(startrow, 0, blocklines, inimg.width, 1);
imgArr = inimg.getData(startrow, 0, blocklines, inimg.width, 2);
imgArrb1 = imgArr.array().arg();
ampimg.saveImage(imgArrb1, startrow, 0, 1);
}
qDebug() << "影像写入到:" << outRasterPath;
return ErrorCode::SUCCESS;
}
ErrorCode Complex2dBRaster(QString inComplexPath, QString outRasterPath)
{
gdalImageComplex inimg(inComplexPath);
gdalImage ampimg = CreategdalImage(outRasterPath, inimg.height, inimg.width, inimg.band_num, inimg.gt, inimg.projection, true, true);
long blocklines = Memory1GB * 2 / 8 / inimg.width;
blocklines = blocklines < 100 ? 100 : blocklines;
Eigen::MatrixXd imgArrb1 = Eigen::MatrixXd::Zero(blocklines, ampimg.width);
Eigen::MatrixXcd imgArr = Eigen::MatrixXcd::Zero(blocklines, inimg.width);
long startrow = 0;
for (startrow = 0; startrow < inimg.height; startrow = startrow + blocklines) {
imgArrb1 = ampimg.getData(startrow, 0, blocklines, inimg.width, 1);
imgArr = inimg.getData(startrow, 0, blocklines, inimg.width, 2);
imgArrb1 = imgArr.array().abs().log10()*20.0;
ampimg.saveImage(imgArrb1, startrow, 0, 1);
}
qDebug() << "影像写入到:" << outRasterPath;
return ErrorCode::SUCCESS;
}
ErrorCode ResampleDEM(QString indemPath, QString outdemPath,double gridx,double gridy)
{
double gridlat = gridy / 110000.0;
double gridlon = gridx / 100000.0;
long espgcode = GetEPSGFromRasterFile(indemPath.toUtf8().constData());
if (espgcode == 4326) {
resampleRaster(indemPath.toUtf8().constData(), outdemPath.toUtf8().constData(), gridlon, gridlat);
return ErrorCode::SUCCESS;
}
else {
QMessageBox::warning(nullptr,u8"警告",u8"请输入WGS84坐标的DEM影像");
return ErrorCode::FAIL;
}
}
ErrorCode GF3RDCreateLookTable(QString inxmlPath, QString indemPath,QString outworkdir, QString outlooktablePath)
{
QString indemfilename = getFileNameWidthoutExtend(indemPath);
QString resampleDEMXYZPath = JoinPath(outworkdir, indemfilename + "_XYZ.tif");
QString resampleDEMSLOPEPath = JoinPath(outworkdir, indemfilename + "_slopevector.tif");
DEM2XYZRasterAndSlopRaster(indemPath, resampleDEMXYZPath, resampleDEMSLOPEPath);
gdalImage demxyz(resampleDEMXYZPath);// X,Y,Z
gdalImage demslope(resampleDEMSLOPEPath);// X,Y,Z
gdalImage rasterRC = CreategdalImage(outlooktablePath, demxyz.height, demxyz.width,2, demxyz.gt, demxyz.projection, true, true);// X,Y,Z
SARSimulationImageL1Dataset l1dataset;
l1dataset.Open(inxmlPath);
// RD 相关参数
QVector<double> dopplers = l1dataset.getDopplerParams();
double d0 = dopplers[0];
double d1 = dopplers[1];
double d2 = dopplers[2];
double d3 = dopplers[3];
double d4 = dopplers[4];
double fs = l1dataset.getFs();
double prf = (l1dataset.getEndImageTime()-l1dataset.getStartImageTime())/(l1dataset.getrowCount()-1);
// 构建轨道模型
return ErrorCode::SUCCESS;
}
ErrorCode GF3RDCreateLookTable(QString inxmlPath, QString indemPath, QString outworkdir, double gridx, double gridy)
{
SARSimulationImageL1Dataset l1dataset;
l1dataset.Open(inxmlPath);
DemBox box = l1dataset.getExtend();
double dlon = 0.1*(box.max_lon - box.min_lon);
double dlat = 0.1 * (box.max_lat - box.min_lat);
double minlat = box.min_lat - dlat;
double minlon = box.min_lon - dlon;
double maxlat = box.max_lat + dlat;
double maxlon = box.max_lon + dlon;
// 裁剪DEM
QString filename = getFileNameWidthoutExtend(l1dataset.getxmlFilePath());
filename = filename.right(5);
QString clipDEMPath = JoinPath(outworkdir, getFileNameWidthoutExtend(indemPath) + filename+"_clip.tif");
cropRasterByLatLon(indemPath.toUtf8().constData(), clipDEMPath.toUtf8().constData(), minlon, maxlon, minlat, maxlat);
QString resampleDEMPath = JoinPath(outworkdir, getFileNameWidthoutExtend(indemPath) + filename + "_clip_resample.tif");
resampleRaster(clipDEMPath.toUtf8().constData(), resampleDEMPath.toUtf8().constData(), gridx, gridy);
QString outlooktablePath= JoinPath(outworkdir, getFileNameWidthoutExtend(l1dataset.getxmlFilePath()) + "_looktable.tif");
if (GF3RDCreateLookTable(inxmlPath, resampleDEMPath, outworkdir, outlooktablePath) != ErrorCode::SUCCESS) {
qDebug() << "查找表生成错误:\t"+ getFileNameWidthoutExtend(inxmlPath);
return ErrorCode::FAIL;
}
return ErrorCode::SUCCESS;
}

View File

@ -0,0 +1,34 @@
#pragma once
#include "../BaseLibraryCPP/BaseConstVariable.h"
#include "../BaseLibraryCPP/ImageOperatorBase.h"
#include "../BaseLibraryCPP/LogInfoCls.h"
#include "../BaseLibraryCPP/SARSimulationImageL1.h"
#include <QString>
// 数据定标
ErrorCode GF3CalibrationRaster(QString inRasterPath, QString outRasterPath, double Qualifyvalue, double calibrationConst);
ErrorCode ImportGF3L1ARasterToWorkspace(QString inMetaxmlPath,QString inRasterPath, QString outWorkDirPath, POLARTYPEENUM polsartype);
QVector<QString> SearchGF3DataTiff(QString inMetaxmlPath);
POLARTYPEENUM getDatasetGF3FilePolsarType(QString fileName);
ErrorCode ImportGF3L1AProcess(QString inMetaxmlPath, QString outWorkDirPath);
// 复数转实部
ErrorCode Complex2AmpRaster(QString inComplexPath, QString outRasterPath);
//复数转相位
ErrorCode Complex2PhaseRaster(QString inComplexPath, QString outRasterPath);
ErrorCode Complex2dBRaster(QString inComplexPath, QString outRasterPath);
ErrorCode ResampleDEM(QString indemPath, QString outdemPath, double gridx, double gridy);
//创建查找表
ErrorCode GF3RDCreateLookTable(QString inxmlPath, QString indemPath, QString outworkdir, QString outlooktablePath);
// 正射处理流程
ErrorCode GF3RDCreateLookTable(QString inxmlPath, QString indemPath, QString outworkdir, double gridx, double gridy);

View File

View File

@ -0,0 +1,6 @@
#pragma once

View File

@ -0,0 +1,148 @@
#include "QComplex2AmpPhase.h"
#include <QtWidgets>
#include <QFileDialog>
#include "../BaseLibraryCPP/FileOperator.h"
#include "../BaseLibraryCPP/BaseTool.h"
#include "GF3CalibrationAndGeocodingClass.h"
QComplex2AmpPhase::QComplex2AmpPhase(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
QObject::connect(ui.radioButtonAmp,SIGNAL(toggled(bool)),this,SLOT(radioButtonAmptoggled(bool)));
QObject::connect(ui.radioButtonPhase, SIGNAL(toggled(bool)), this, SLOT(radioButtonPhasetoggled(bool)));
QObject::connect(ui.radioButtonSigma0, SIGNAL(toggled(bool)), this, SLOT(radioButtonSigma0toggled(bool)));
//toggled(bool )
}
QComplex2AmpPhase::~QComplex2AmpPhase()
{
}
void QComplex2AmpPhase::accept()
{
QProgressDialog progressDialog(u8"复数转换", u8"终止", 0, ui.listWidgetImg->count());
progressDialog.setWindowTitle(u8"复数转换");
progressDialog.setWindowModality(Qt::WindowModal);
progressDialog.setAutoClose(true);
progressDialog.setValue(0);
progressDialog.setMaximum(ui.listWidgetImg->count());
progressDialog.setMinimum(0);
progressDialog.show();
QString outworkdir = ui.lineEditWorkDir->text();
for (long i = 0; i < ui.listWidgetImg->count(); i++) {
QString imgfilepath = ui.listWidgetImg->item(i)->text();
progressDialog.setLabelText(u8"复数转换影像:" + getFileNameWidthoutExtend(imgfilepath));
QString filename = getFileNameWidthoutExtend(imgfilepath);
QString folderpath = getParantFromPath(imgfilepath);
SARSimulationImageL1Dataset slcl1(RasterLevel::RasterSLC);
slcl1.Open(folderpath, filename);
QString l2bfilename = filename + ui.lineEditHZ->text();
SARSimulationImageL1Dataset l1B(RasterLevel::RasterL1B);
slcl1.OpenOrNew(outworkdir, l2bfilename,slcl1.getrowCount(),slcl1.getcolCount());
QString srcxmlpath = slcl1.getxmlFilePath();
QString tarxmlpath = l1B.getxmlFilePath();
copyAndReplaceFile(srcxmlpath, tarxmlpath);
l1B.loadFromXml();
if (ui.radioButtonAmp->isChecked()) {
Complex2AmpRaster(imgfilepath, slcl1.getImageRasterPath());
}
else if (ui.radioButtonPhase->isChecked()) {
Complex2PhaseRaster(imgfilepath, slcl1.getImageRasterPath());
}
else if (ui.radioButtonSigma0->isChecked()) {
Complex2dBRaster(imgfilepath, slcl1.getImageRasterPath());
}
progressDialog.setValue(i);
}
progressDialog.close();
}
void QComplex2AmpPhase::reject()
{
this->close();
}
void QComplex2AmpPhase::onpushButtonAddClicked(bool)
{
QStringList fileNames = QFileDialog::getOpenFileNames(
this, // 父窗口
tr(u8"选择影像文件"), // 标题
QString(), // 默认路径
tr(u8"tif Files (*.tif);;data Files (*.data);;bin Files (*.bin);;All Files (*)") // 文件过滤器
);
// 如果用户选择了文件
if (!fileNames.isEmpty()) {
QString message = "选择的文件有:\n";
for (const QString& fileName : fileNames) {
this->ui.listWidgetImg->addItem(fileName);
}
}
else {
QMessageBox::information(this, tr(u8"没有选择文件"), tr(u8"没有选择任何文件。"));
}
}
void QComplex2AmpPhase::onpushButtonRemoveClicked(bool)
{
QList<QListWidgetItem*> selectedItems = this->ui.listWidgetImg->selectedItems();
for (QListWidgetItem* item : selectedItems) {
delete this->ui.listWidgetImg->takeItem(this->ui.listWidgetImg->row(item));
}
}
void QComplex2AmpPhase::onpushButtonWorkSpaceClicked(bool)
{
// 调用文件选择对话框并选择一个 .tif 文件
QString fileName = QFileDialog::getExistingDirectory(this, u8"选择工作空间路径", "");
if (!fileName.isEmpty()) {
this->ui.lineEditWorkDir->setText(fileName);
}
else {
QMessageBox::information(this, u8"没有选择文件夹", u8"没有选择任何文件夹");
}
}
void QComplex2AmpPhase::radioButtonAmptoggled(bool flag)
{
if (ui.radioButtonAmp->isChecked()) {
ui.lineEditHZ->setText("_amp");
}
else if (ui.radioButtonPhase->isChecked()) {
ui.lineEditHZ->setText("_phase");
}
else if (ui.radioButtonSigma0->isChecked()) {
ui.lineEditHZ->setText("_dB");
}
}
void QComplex2AmpPhase::radioButtonPhasetoggled(bool flag)
{
if (ui.radioButtonAmp->isChecked()) {
ui.lineEditHZ->setText("_amp");
}
else if (ui.radioButtonPhase->isChecked()) {
ui.lineEditHZ->setText("_phase");
}
else if (ui.radioButtonSigma0->isChecked()) {
ui.lineEditHZ->setText("_dB");
}
}
void QComplex2AmpPhase::radioButtonSigma0toggled(bool flag)
{
if (ui.radioButtonAmp->isChecked()) {
ui.lineEditHZ->setText("_amp");
}
else if (ui.radioButtonPhase->isChecked()) {
ui.lineEditHZ->setText("_phase");
}
else if(ui.radioButtonSigma0->isChecked()) {
ui.lineEditHZ->setText("_dB");
}
}

View File

@ -0,0 +1,25 @@
#pragma once
#include <QDialog>
#include "ui_QComplex2AmpPhase.h"
class QComplex2AmpPhase : public QDialog
{
Q_OBJECT
public:
QComplex2AmpPhase(QWidget *parent = nullptr);
~QComplex2AmpPhase();
public slots:
void accept();
void reject();
void onpushButtonAddClicked(bool);
void onpushButtonRemoveClicked(bool);
void onpushButtonWorkSpaceClicked(bool);
void radioButtonAmptoggled(bool);
void radioButtonPhasetoggled(bool);
void radioButtonSigma0toggled(bool);
private:
Ui::QComplex2AmpPhaseClass ui;
};

View File

@ -0,0 +1,217 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QComplex2AmpPhaseClass</class>
<widget class="QDialog" name="QComplex2AmpPhaseClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>596</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>复数图像转换为</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="listWidgetImg"/>
</item>
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="pushButtonAdd">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonRemove">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>删除</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_4">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="radioButtonAmp">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>振幅</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonPhase">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>相位</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonSigma0">
<property name="text">
<string>dB</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>后缀:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditHZ">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_3">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>输出地址:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditWorkDir">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonWorkSpace">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,87 @@
#include "QImportGF3StripL1ADataset.h"
#include <QtWidgets>
#include <QFileDialog>
QImportGF3StripL1ADataset::QImportGF3StripL1ADataset(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
QListWidget* listWidgetMetaxml;
QObject::connect( ui.pushButtonAdd,SIGNAL(clicked(clicked)),this,SLOT(onpushButtonAddClicked(bool)));
QObject::connect(ui.pushButtonRemove, SIGNAL(clicked(clicked)), this, SLOT(onpushButtonRemoveClicked(bool)));
QObject::connect(ui.pushButtonWorkSpace, SIGNAL(clicked(clicked)), this, SLOT(onpushButtonWorkSpaceClicked(bool)));
}
QImportGF3StripL1ADataset::~QImportGF3StripL1ADataset()
{
}
void QImportGF3StripL1ADataset::accept()
{
QProgressDialog progressDialog(u8"导入GF3条带L1A影像", u8"终止", 0, ui.listWidgetMetaxml->count());
progressDialog.setWindowTitle(u8"导入GF3条带L1A影像");
progressDialog.setWindowModality(Qt::WindowModal);
progressDialog.setAutoClose(true);
progressDialog.setValue(0);
progressDialog.setMaximum(ui.listWidgetMetaxml->count());
progressDialog.setMinimum(0);
progressDialog.show();
QString outworkdir = ui.lineEditWorkDir->text();
for (long i = 0; i < ui.listWidgetMetaxml->count(); i++) {
QString xmlmetafilepath = ui.listWidgetMetaxml->item(i)->text();
progressDialog.setLabelText(u8"导入影像:"+getFileNameWidthoutExtend(xmlmetafilepath));
ImportGF3L1AProcess(xmlmetafilepath, outworkdir);
progressDialog.setValue(i);
}
progressDialog.close();
}
void QImportGF3StripL1ADataset::reject()
{
this->close();
}
void QImportGF3StripL1ADataset::onpushButtonAddClicked(bool)
{
QStringList fileNames = QFileDialog::getOpenFileNames(
this, // 父窗口
tr(u8"选择元文件"), // 标题
QString(), // 默认路径
tr(u8"meta xml Files (*.meta.xml);;All Files (*)") // 文件过滤器
);
// 如果用户选择了文件
if (!fileNames.isEmpty()) {
QString message = "选择的文件有:\n";
for (const QString& fileName : fileNames) {
this->ui.listWidgetMetaxml->addItem(fileName);
}
}
else {
QMessageBox::information(this, tr(u8"没有选择文件"), tr(u8"没有选择任何文件。"));
}
}
void QImportGF3StripL1ADataset::onpushButtonRemoveClicked(bool)
{
QList<QListWidgetItem*> selectedItems = this->ui.listWidgetMetaxml->selectedItems();
for (QListWidgetItem* item : selectedItems) {
delete this->ui.listWidgetMetaxml->takeItem(this->ui.listWidgetMetaxml->row(item));
}
}
void QImportGF3StripL1ADataset::onpushButtonWorkSpaceClicked(bool)
{
// 调用文件选择对话框并选择一个 .tif 文件
QString fileName = QFileDialog::getExistingDirectory(this,u8"选择工作空间路径","");
if (!fileName.isEmpty()) {
this->ui.lineEditWorkDir->setText(fileName);
}
else {
QMessageBox::information(this, u8"没有选择文件夹", u8"没有选择任何文件夹");
}
}

View File

@ -0,0 +1,23 @@
#pragma once
#include <QDialog>
#include "ui_QImportGF3StripL1ADataset.h"
#include "GF3CalibrationAndGeocodingClass.h"
class QImportGF3StripL1ADataset : public QDialog
{
Q_OBJECT
public:
QImportGF3StripL1ADataset(QWidget *parent = nullptr);
~QImportGF3StripL1ADataset();
public slots:
void accept();
void reject();
void onpushButtonAddClicked(bool);
void onpushButtonRemoveClicked(bool);
void onpushButtonWorkSpaceClicked(bool);
private:
Ui::QImportGF3StripL1ADatasetClass ui;
};

View File

@ -0,0 +1,186 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QImportGF3StripL1ADatasetClass</class>
<widget class="QDialog" name="QImportGF3StripL1ADatasetClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>775</width>
<height>448</height>
</rect>
</property>
<property name="windowTitle">
<string>导入GF3条带模式</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="listWidgetMetaxml">
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="pushButtonAdd">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonRemove">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>删除</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_3">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>输出地址:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditWorkDir">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonWorkSpace">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QImportGF3StripL1ADatasetClass</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>247</x>
<y>371</y>
</hint>
<hint type="destinationlabel">
<x>299</x>
<y>199</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QImportGF3StripL1ADatasetClass</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>247</x>
<y>371</y>
</hint>
<hint type="destinationlabel">
<x>299</x>
<y>199</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,96 @@
#include "QRDOrthProcessClass.h"
#include <QtWidgets>
#include <QFileDialog>
QRDOrthProcessClass::QRDOrthProcessClass(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
QListWidget* listWidgetMetaxml;
QPushButton* pushButtonAdd;
QPushButton* pushButtonRemove;
QLineEdit* lineEditDEM;
QPushButton* pushButtonDEMSelect;
QHBoxLayout* horizontalLayout_2;
QLineEdit* lineEditWorkDir;
QPushButton* pushButtonWorkSpace;
QDialogButtonBox* buttonBox;
}
QRDOrthProcessClass::~QRDOrthProcessClass()
{}
void QRDOrthProcessClass::accept()
{
}
void QRDOrthProcessClass::reject()
{
this->close();
}
void QRDOrthProcessClass::onpushButtonAddClicked(bool)
{
QStringList fileNames = QFileDialog::getOpenFileNames(
this, // 父窗口
tr(u8"选择xml文件"), // 标题
QString(), // 默认路径
tr(u8"xml Files (*.xml);;All Files (*)") // 文件过滤器
);
// 如果用户选择了文件
if (!fileNames.isEmpty()) {
QString message = "选择的文件有:\n";
for (const QString& fileName : fileNames) {
this->ui.listWidgetMetaxml->addItem(fileName);
}
}
else {
QMessageBox::information(this, tr(u8"没有选择文件"), tr(u8"没有选择任何文件。"));
}
}
void QRDOrthProcessClass::onpushButtonRemoveClicked(bool)
{
QList<QListWidgetItem*> selectedItems = this->ui.listWidgetMetaxml->selectedItems();
for (QListWidgetItem* item : selectedItems) {
delete this->ui.listWidgetMetaxml->takeItem(this->ui.listWidgetMetaxml->row(item));
}
}
void QRDOrthProcessClass::onpushButtonWorkSpaceClicked(bool)
{
QString fileName = QFileDialog::getExistingDirectory(this, u8"选择工作空间路径", "");
if (!fileName.isEmpty()) {
this->ui.lineEditWorkDir->setText(fileName);
}
else {
QMessageBox::information(this, u8"没有选择文件夹", u8"没有选择任何文件夹");
}
}
void QRDOrthProcessClass::pushButtonDEMSelectClicked(bool)
{
QString fileName = QFileDialog::getOpenFileName(
this, // 父窗口
tr(u8"选择tif文件"), // 标题
QString(), // 默认路径
tr(u8"tif Files (*.tif);;All Files (*)") // 文件过滤器
);
// 如果用户选择了文件
if (!fileName.isEmpty()) {
QString message = "选择的文件有:\n";
ui.lineEditDEM->setText(fileName);
}
else {
QMessageBox::information(this, tr(u8"没有选择文件"), tr(u8"没有选择任何文件。"));
}
}

View File

@ -0,0 +1,25 @@
#pragma once
#include <QDialog>
#include "ui_QRDOrthProcessClass.h"
class QRDOrthProcessClass : public QDialog
{
Q_OBJECT
public:
QRDOrthProcessClass(QWidget *parent = nullptr);
~QRDOrthProcessClass();
public slots:
void accept();
void reject();
void onpushButtonAddClicked(bool);
void onpushButtonRemoveClicked(bool);
void onpushButtonWorkSpaceClicked(bool);
void pushButtonDEMSelectClicked(bool);
private:
Ui::QRDOrthProcessClassClass ui;
};

View File

@ -0,0 +1,292 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QRDOrthProcessClassClass</class>
<widget class="QDialog" name="QRDOrthProcessClassClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>656</width>
<height>616</height>
</rect>
</property>
<property name="windowTitle">
<string>正射代码</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="listWidgetMetaxml">
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="pushButtonAdd">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonRemove">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>删除</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_5">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>gridX(米)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_gridx">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>gridY(米)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_gridy">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_4">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>DEM路径</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditDEM">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonDEMSelect">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_3">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>输出地址:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditWorkDir">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonWorkSpace">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QRDOrthProcessClassClass</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>327</x>
<y>590</y>
</hint>
<hint type="destinationlabel">
<x>327</x>
<y>307</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QRDOrthProcessClassClass</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>327</x>
<y>590</y>
</hint>
<hint type="destinationlabel">
<x>327</x>
<y>307</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,86 @@
#include "SateOrbit.h"
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
using namespace std;
using namespace Eigen;
OrbitPoly::OrbitPoly()
{
}
OrbitPoly::OrbitPoly(int polynum, Eigen::MatrixX<double> polySatellitePara, double SatelliteModelStartTime)
{
if (polySatellitePara.rows() != polynum||polySatellitePara.cols()!=6) {
throw exception("?????????????????");
}
this->polySatellitePara = polySatellitePara;
this->SatelliteModelStartTime = SatelliteModelStartTime;
this->polynum = polynum;
}
OrbitPoly::~OrbitPoly()
{
}
Eigen::MatrixX<double> OrbitPoly::SatelliteSpacePoint(Eigen::MatrixX<double> satellitetime)
{
Eigen::MatrixX<double> result= SatelliteSpacePoints(satellitetime, this->SatelliteModelStartTime, this->polySatellitePara, this->polynum);
return result;
}
Eigen::MatrixX<double> OrbitPoly::SatelliteSpacePoint(long double satellitetime) {
if (this->polySatellitePara.rows() != polynum || this->polySatellitePara.cols() != 6) {
throw exception("the size of satellitetime has error!! row: p1,p2,p3,p4 col: x,y,z,vx,vy,vz ");
}
// ?????????
double satellitetime2 =double( satellitetime - this->SatelliteModelStartTime);
Eigen::MatrixX<double> satetime(1, polynum);
for (int i = 0; i < polynum; i++) {
satetime(0, i) = pow(satellitetime2, i);
}
// ????
Eigen::MatrixX<double> satellitePoints(1, 6);
satellitePoints = satetime * polySatellitePara;
return satellitePoints;
}
/// <summary>
/// ????????????????????
/// </summary>
/// <param name="satellitetime">???????</param>
/// <param name="SatelliteModelStartTime">??????????</param>
/// <param name="polySatellitePara">??????[x1,y1,z1,vx1,vy1,vz1; x2,y2,z2,vx2,vy2,vz2; ..... ]</param>
/// <param name="polynum">??????????</param>
/// <returns>????????</returns>
Eigen::MatrixX<double> SatelliteSpacePoints(Eigen::MatrixX<double>& satellitetime, double SatelliteModelStartTime, Eigen::MatrixX<double>& polySatellitePara, int polynum)
{
if (satellitetime.cols() != 1) {
throw exception("the size of satellitetime has error!!");
}
if (polySatellitePara.rows() != polynum || polySatellitePara.cols() != 6) {
throw exception("the size of satellitetime has error!! row: p1,p2,p3,p4 col: x,y,z,vx,vy,vz ");
}
// ?????????
int satellitetime_num = satellitetime.rows();
satellitetime = satellitetime.array() - SatelliteModelStartTime;
Eigen::MatrixX<double> satelliteTime(satellitetime_num, polynum);
for (int i = 0; i < polynum; i++) {
satelliteTime.col(i) = satellitetime.array().pow(i);
}
// ????
Eigen::MatrixX<double> satellitePoints(satellitetime_num, 6);
satellitePoints = satelliteTime * polySatellitePara;
return satellitePoints;
}

View File

@ -0,0 +1,52 @@
#pragma once
///
/// 计算卫星轨道
///
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
// 本地方法
#include "../BaseLibraryCPP/BaseTool.h"
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
//#include <armadillo>
using namespace std;
using namespace Eigen;
//using namespace arma;
/// <summary>
/// 多项式轨道模型
/// </summary>
class OrbitPoly {
public:
//OrbitPoly(std::string orbitModelPath);
OrbitPoly();
OrbitPoly(int polynum, Eigen::MatrixX<double> polySatellitePara, double SatelliteModelStartTime);
~OrbitPoly();
Eigen::MatrixX<double> SatelliteSpacePoint(Eigen::MatrixX<double> satellitetime);
Eigen::MatrixX<double> SatelliteSpacePoint(long double satellitetime);
public:
int polynum;
Eigen::MatrixX<double> polySatellitePara;
double SatelliteModelStartTime;
};
/// <summary>
/// 获取指定时刻的卫星轨道坐标
/// </summary>
/// <param name="satellitetime">卫星时刻</param>
/// <param name="SatelliteModelStartTime">模型起算时间</param>
/// <param name="polySatellitePara">模型参数[x1,y1,z1,vx1,vy1,vz1; x2,y2,z2,vx2,vy2,vz2; ..... ]</param>
/// <param name="polynum">模型参数数量</param>
/// <returns>卫星坐标</returns>
Eigen::MatrixX<double> SatelliteSpacePoints(Eigen::MatrixX<double> &satellitetime, double SatelliteModelStartTime, Eigen::MatrixX<double>& polySatellitePara, int polynum = 4);

View File

@ -0,0 +1,250 @@
#include "SatelliteGF3xmlParser.h"
#include <QDateTime>
bool SatelliteGF3xmlParser::loadFile(const QString& filename) {
QFile file(filename);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qWarning() << "Cannot open file:" << filename;
return false;
}
QDomDocument doc;
if (!doc.setContent(&file)) {
file.close();
qWarning() << "Failed to parse the file into a DOM tree.";
return false;
}
file.close();
xml = doc;
return true;
}
void SatelliteGF3xmlParser::parsePlatform() {
QDomElement platform = xml.firstChildElement("root").firstChildElement("platform");
if (!platform.isNull()) {
CenterTime = platform.firstChildElement("CenterTime").text();
Rs = platform.firstChildElement("Rs").text().toDouble();
satVelocity = platform.firstChildElement("satVelocity").text().toDouble();
RollAngle = platform.firstChildElement("RollAngle").text().toDouble();
PitchAngle = platform.firstChildElement("PitchAngle").text().toDouble();
YawAngle = platform.firstChildElement("YawAngle").text().toDouble();
Xs = platform.firstChildElement("Xs").text().toDouble();
Ys = platform.firstChildElement("Ys").text().toDouble();
Zs = platform.firstChildElement("Zs").text().toDouble();
Vxs = platform.firstChildElement("Vxs").text().toDouble();
Vys = platform.firstChildElement("Vys").text().toDouble();
Vzs = platform.firstChildElement("Vzs").text().toDouble();
qDebug() << "Platform Data:";
qDebug() << "CenterTime:" << CenterTime;
qDebug() << "Rs:" << Rs;
qDebug() << "satVelocity:" << satVelocity;
qDebug() << "RollAngle:" << RollAngle;
qDebug() << "PitchAngle:" << PitchAngle;
qDebug() << "YawAngle:" << YawAngle;
qDebug() << "Xs:" << Xs;
qDebug() << "Ys:" << Ys;
qDebug() << "Zs:" << Zs;
qDebug() << "Vxs:" << Vxs;
qDebug() << "Vys:" << Vys;
qDebug() << "Vzs:" << Vzs;
}
}
void SatelliteGF3xmlParser::parseGPS() {
QDomElement GPS = xml.firstChildElement("root").firstChildElement("GPS");
if (!GPS.isNull()) {
QDomNodeList GPSParams = GPS.elementsByTagName("GPSParam");
for (int i = 0; i < GPSParams.count(); ++i) {
QDomElement GPSParam = GPSParams.at(i).toElement();
SatellitePos satepos{0.0 ,0.0,0.0,0.0, 0.0,0.0,0.0 };
QString TimeStamp = GPSParam.firstChildElement("TimeStamp").text();
QString xPosition = GPSParam.firstChildElement("xPosition").text();
QString yPosition = GPSParam.firstChildElement("yPosition").text();
QString zPosition = GPSParam.firstChildElement("zPosition").text();
QString xVelocity = GPSParam.firstChildElement("xVelocity").text();
QString yVelocity = GPSParam.firstChildElement("yVelocity").text();
QString zVelocity = GPSParam.firstChildElement("zVelocity").text();
QDateTime dateTime = QDateTime::fromString(TimeStamp, "yyyy-MM-dd HH:mm:ss.zzzzzz");
satepos.time = dateTime.toMSecsSinceEpoch() / 1000.0;
satepos.Px= xPosition.toDouble();
satepos.Py= yPosition.toDouble();
satepos.Pz= zPosition.toDouble();
satepos.Vx= xVelocity.toDouble();
satepos.Vy= yVelocity.toDouble();
satepos.Vz= zVelocity.toDouble();
this->antposs.append(satepos);
qDebug() << "\nGPS Param Data:";
qDebug() << "TimeStamp:" << TimeStamp;
qDebug() << "xPosition:" << xPosition;
qDebug() << "yPosition:" << yPosition;
qDebug() << "zPosition:" << zPosition;
qDebug() << "xVelocity:" << xVelocity;
qDebug() << "yVelocity:" << yVelocity;
qDebug() << "zVelocity:" << zVelocity;
}
}
}
void SatelliteGF3xmlParser::parseImageInfo() {
QDomElement imageinfo = xml.firstChildElement("root").firstChildElement("imageinfo");
if (!imageinfo.isNull()) {
QDomElement imagingTime = imageinfo.firstChildElement("imagingTime");
;
start = QDateTime::fromString(imagingTime.firstChildElement("start").text(), "yyyy-MM-dd HH:mm:ss.zzzzzz").toMSecsSinceEpoch()/1000.0;
end = QDateTime::fromString(imagingTime.firstChildElement("end").text(), "yyyy-MM-dd HH:mm:ss.zzzzzz").toMSecsSinceEpoch() / 1000.0;
nearRange = imageinfo.firstChildElement("nearRange").text().toDouble();
refRange = imageinfo.firstChildElement("refRange").text().toDouble();
eqvFs = imageinfo.firstChildElement("eqvFs").text().toDouble();
eqvPRF = imageinfo.firstChildElement("eqvPRF").text().toDouble();
QDomElement center = imageinfo.firstChildElement("center");
latitude_center = center.firstChildElement("latitude").text().toDouble();
longitude_center = center.firstChildElement("longitude").text().toDouble();
QDomElement corner = imageinfo.firstChildElement("corner");
QDomElement topLeft = corner.firstChildElement("topLeft");
latitude_topLeft = topLeft.firstChildElement("latitude").text().toDouble();
longitude_topLeft = topLeft.firstChildElement("longitude").text().toDouble();
QDomElement topRight = corner.firstChildElement("topRight");
latitude_topRight = topRight.firstChildElement("latitude").text().toDouble();
longitude_topRight = topRight.firstChildElement("longitude").text().toDouble();
QDomElement bottomLeft = corner.firstChildElement("bottomLeft");
latitude_bottomLeft = bottomLeft.firstChildElement("latitude").text().toDouble();
longitude_bottomLeft = bottomLeft.firstChildElement("longitude").text().toDouble();
QDomElement bottomRight = corner.firstChildElement("bottomRight");
latitude_bottomRight = bottomRight.firstChildElement("latitude").text().toDouble();
longitude_bottomRight = bottomRight.firstChildElement("longitude").text().toDouble();
width = imageinfo.firstChildElement("width").text().toInt();
height = imageinfo.firstChildElement("height").text().toInt();
widthspace = imageinfo.firstChildElement("widthspace").text().toDouble();
heightspace = imageinfo.firstChildElement("heightspace").text().toDouble();
sceneShift = imageinfo.firstChildElement("sceneShift").text().toDouble();
imagebit = imageinfo.firstChildElement("imagebit").text();
QDomElement qualifyValue = imageinfo.firstChildElement("QualifyValue");
bool HH_QualifyValueISNULL=false;
bool HV_QualifyValueISNULL=false;
bool VH_QualifyValueISNULL=false;
bool VV_QualifyValueISNULL = false;
HH_QualifyValue = qualifyValue.firstChildElement("HH").text().toDouble(&HH_QualifyValueISNULL);
HV_QualifyValue = qualifyValue.firstChildElement("HV").text().toDouble(&HV_QualifyValueISNULL);
VH_QualifyValue = qualifyValue.firstChildElement("HH").text().toDouble(&VH_QualifyValueISNULL);
VV_QualifyValue = qualifyValue.firstChildElement("HV").text().toDouble(&VV_QualifyValueISNULL);
HH_QualifyValue = HH_QualifyValueISNULL ? HH_QualifyValue : -1;
HV_QualifyValue = HV_QualifyValueISNULL ? HV_QualifyValue : -1;
VH_QualifyValue = VH_QualifyValueISNULL ? VH_QualifyValue : -1;
VV_QualifyValue = VV_QualifyValueISNULL ? VV_QualifyValue : -1;
QDomElement echoSaturation = imageinfo.firstChildElement("echoSaturation");
HH_echoSaturation = echoSaturation.firstChildElement("HH").text().toDouble();
HV_echoSaturation = echoSaturation.firstChildElement("HV").text().toDouble();
incidenceAngleNearRange = imageinfo.firstChildElement("incidenceAngleNearRange").text().toDouble();
incidenceAngleFarRange = imageinfo.firstChildElement("incidenceAngleFarRange").text().toDouble();
qDebug() << "\nImage Info Data:";
qDebug() << "Start:" << start;
qDebug() << "End:" << end;
qDebug() << "Near Range:" << nearRange;
qDebug() << "Ref Range:" << refRange;
qDebug() << "Eqv Fs:" << eqvFs;
qDebug() << "Eqv PRF:" << eqvPRF;
qDebug() << "Center Latitude:" << latitude_center << ", Longitude:" << longitude_center;
qDebug() << "Top Left Corner Latitude:" << latitude_topLeft << ", Longitude:" << longitude_topLeft;
qDebug() << "Top Right Corner Latitude:" << latitude_topRight << ", Longitude:" << longitude_topRight;
qDebug() << "Bottom Left Corner Latitude:" << latitude_bottomLeft << ", Longitude:" << longitude_bottomLeft;
qDebug() << "Bottom Right Corner Latitude:" << latitude_bottomRight << ", Longitude:" << longitude_bottomRight;
qDebug() << "Width:" << width;
qDebug() << "Height:" << height;
qDebug() << "Width Space:" << widthspace;
qDebug() << "Height Space:" << heightspace;
qDebug() << "Scene Shift:" << sceneShift;
qDebug() << "Image Bit:" << imagebit;
qDebug() << "HH Qualify Value:" << HH_QualifyValue;
qDebug() << "HV Qualify Value:" << HV_QualifyValue;
qDebug() << "HH Echo Saturation:" << HH_echoSaturation;
qDebug() << "HV Echo Saturation:" << HV_echoSaturation;
qDebug() << "incidenceAngleNearRange:" << incidenceAngleNearRange;
qDebug() << "incidenceAngleFarRange:" << incidenceAngleFarRange;
}
}
void SatelliteGF3xmlParser::parseAdditionalData() {
QDomElement calibrationConst = xml.firstChildElement("root").firstChildElement("CalibrationConst");
if (!calibrationConst.isNull()) {
bool HH_CalibrationConstISNULL=false;
bool HV_CalibrationConstISNULL=false;
bool VH_CalibrationConstISNULL=false;
bool VV_CalibrationConstISNULL = false;
HH_CalibrationConst = calibrationConst.firstChildElement("HH").text().toDouble(&HH_CalibrationConstISNULL);
HV_CalibrationConst = calibrationConst.firstChildElement("HV").text().toDouble(&HV_CalibrationConstISNULL);
VH_CalibrationConst = calibrationConst.firstChildElement("VH").text().toDouble(&VH_CalibrationConstISNULL);
VV_CalibrationConst = calibrationConst.firstChildElement("VV").text().toDouble(&VV_CalibrationConstISNULL);
HH_CalibrationConst = HH_CalibrationConstISNULL ? HH_CalibrationConst : -1;
HV_CalibrationConst = HV_CalibrationConstISNULL ? HV_CalibrationConst : -1;
VH_CalibrationConst = VH_CalibrationConstISNULL ? VH_CalibrationConst : -1;
VV_CalibrationConst = VV_CalibrationConstISNULL ? VV_CalibrationConst : -1;
qDebug() << "\nCalibration Const Data:";
qDebug() << "HH Calibration Const:" << HH_CalibrationConst;
qDebug() << "HV Calibration Const:" << HV_CalibrationConst;
qDebug() << "VH Calibration Const:" << VH_CalibrationConst;
qDebug() << "VV Calibration Const:" << VV_CalibrationConst;
}
AzFdc0 = xml.firstChildElement("root").firstChildElement("AzFdc0").text().toDouble();
AzFdc1 = xml.firstChildElement("root").firstChildElement("AzFdc1").text().toDouble();
sensorID = xml.firstChildElement("root").firstChildElement("sensorID").text();
imagingMode = xml.firstChildElement("root").firstChildElement("imagingMode").text();
lamda = xml.firstChildElement("root").firstChildElement("lamda").text().toDouble();
RadarCenterFrequency = xml.firstChildElement("root").firstChildElement("RadarCenterFrequency").text().toDouble();
TotalProcessedAzimuthBandWidth = xml.firstChildElement("root").firstChildElement("TotalProcessedAzimuthBandWidth").text().toDouble();
DopplerParametersReferenceTime = xml.firstChildElement("root").firstChildElement("DopplerParametersReferenceTime").text().toDouble();
QDomElement dopplerCentroidCoefficients = xml.firstChildElement("root").firstChildElement("DopplerCentroidCoefficients");
d0 = dopplerCentroidCoefficients.firstChildElement("d0").text().toDouble();
d1 = dopplerCentroidCoefficients.firstChildElement("d1").text().toDouble();
d2 = dopplerCentroidCoefficients.firstChildElement("d2").text().toDouble();
d3 = dopplerCentroidCoefficients.firstChildElement("d3").text().toDouble();
d4 = dopplerCentroidCoefficients.firstChildElement("d4").text().toDouble();
QDomElement dopplerRateValuesCoefficients = xml.firstChildElement("root").firstChildElement("DopplerRateValuesCoefficients");
r0 = dopplerRateValuesCoefficients.firstChildElement("r0").text().toDouble();
r1 = dopplerRateValuesCoefficients.firstChildElement("r1").text().toDouble();
r2 = dopplerRateValuesCoefficients.firstChildElement("r2").text().toDouble();
r3 = dopplerRateValuesCoefficients.firstChildElement("r3").text().toDouble();
r4 = dopplerRateValuesCoefficients.firstChildElement("r4").text().toDouble();
DEM = xml.firstChildElement("root").firstChildElement("DEM").text().toDouble();
qDebug() << "\nAdditional Data:";
qDebug() << "AzFdc0:" << AzFdc0;
qDebug() << "AzFdc1:" << AzFdc1;
qDebug() << "Sensor ID:" << sensorID;
qDebug() << "Imaging Mode:" << imagingMode;
qDebug() << "Lambda:" << lamda;
qDebug() << "Radar Center Frequency:" << RadarCenterFrequency;
qDebug() << "Total Processed Azimuth Band Width:" << TotalProcessedAzimuthBandWidth;
qDebug() << "Doppler Parameters Reference Time:" << DopplerParametersReferenceTime;
qDebug() << "Doppler Centroid Coefficients: d0=" << d0 << ", d1=" << d1 << ", d2=" << d2 << ", d3=" << d3 << ", d4=" << d4;
qDebug() << "Doppler Rate Values Coefficients: r0=" << r0 << ", r1=" << r1 << ", r2=" << r2 << ", r3=" << r3 << ", r4=" << r4;
qDebug() << "DEM:" << DEM;
}

View File

@ -0,0 +1,53 @@
#pragma once
#include <QCoreApplication>
#include <QFile>
#include <QDomDocument>
#include <QDebug>
#include "../BaseLibraryCPP/SARSimulationImageL1.h"
class SatelliteGF3xmlParser {
public:
bool loadFile(const QString& filename);
void parsePlatform();
void parseGPS();
void parseImageInfo();
void parseAdditionalData();
public:
QDomDocument xml;
// Platform data
QString CenterTime;
double Rs, satVelocity, RollAngle, PitchAngle, YawAngle, Xs, Ys, Zs, Vxs, Vys, Vzs;
// GPS data
QVector<SatellitePos> antposs;
// Image info data
double start, end;
double nearRange, refRange, eqvFs, eqvPRF, latitude_center, longitude_center,
latitude_topLeft, longitude_topLeft, latitude_topRight, longitude_topRight,
latitude_bottomLeft, longitude_bottomLeft, latitude_bottomRight, longitude_bottomRight,
widthspace, heightspace, sceneShift, HH_QualifyValue, HV_QualifyValue, VH_QualifyValue, VV_QualifyValue,
HH_echoSaturation, HV_echoSaturation, VH_echoSaturation, VV_echoSaturation;
int width, height;
QString imagebit;
// Additional data
double HH_CalibrationConst, HV_CalibrationConst;
double VH_CalibrationConst, VV_CalibrationConst;
double AzFdc0, AzFdc1;
QString sensorID, imagingMode;
double lamda, RadarCenterFrequency;
double TotalProcessedAzimuthBandWidth, DopplerParametersReferenceTime;
double d0, d1, d2, d3, d4;
double r0, r1, r2, r3, r4;
double DEM;
double incidenceAngleNearRange, incidenceAngleFarRange;
};

View File

@ -0,0 +1,19 @@
#pragma once
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <math.h>
#include <string>
#include <omp.h>
#include <complex>
#include <gdal.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
#include <ogrsf_frmts.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core/eigen.hpp>
#include <opencv2/features2d.hpp>
#include <fstream>
#include "../BaseLibraryCPP/BaseTool.h"
#include"WGS84_J2000.h"

View File

@ -0,0 +1,10 @@
#pragma once
#include <stdlib.h>
#include <vector>
#include <iostream>
#include <omp.h>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include "../BaseLibraryCPP/BaseTool.h"
#include <string>

File diff suppressed because it is too large Load Diff

224
GF3ProcessToolbox/simptsn.h Normal file
View File

@ -0,0 +1,224 @@
#pragma once
///
/// 仿真成像算法
///
//#define EIGEN_USE_MKL_ALL
//#define EIGEN_VECTORIZE_SSE4_2
//#include <mkl.h>
// 本地方法
#include "../BaseLibraryCPP/BaseTool.h"
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
//#include <mkl.h>
#include <omp.h>
#include "SateOrbit.h"
using namespace std;
using namespace Eigen;
////////////// 常用函数 ////////////////////////
double getRangeColumn(long double R, long double NearRange, long double Fs, long double lamda);
Eigen::MatrixXd getRangeColumn(Eigen::MatrixXd R, long double NearRange, long double Fs, long double lamda);
double getRangebyColumn(double j, long double NearRange, long double Fs, long double lamda);
Eigen::MatrixXd getRangebyColumn(Eigen::MatrixXd j, long double NearRange, long double Fs, long double lamda);
///////////// ptsn 算法 /////////////////////
class PSTNAlgorithm {
public:
// 初始化与析构函数
PSTNAlgorithm();
PSTNAlgorithm(QString parameterPath);
~PSTNAlgorithm();
int dem2lat_lon(QString dem_path, QString lon_path, QString lat_path);
int dem2SAR_RC(QString dem_path, QString sim_rc_path);
// 模拟算法函数
Eigen::MatrixX<double> calNumericalDopplerValue(Eigen::MatrixX<double> R);// 数值模拟法计算多普勒频移值
double calNumericalDopplerValue(double R);// 数值模拟法计算多普勒频移值
Eigen::MatrixX<double> calTheoryDopplerValue(Eigen::MatrixX<double> R, Eigen::MatrixX<double> R_s1, Eigen::MatrixX<double> V_s1);//根据理论模型计算多普勒频移值
double calTheoryDopplerValue(double R, Eigen::MatrixX<double> R_s1, Eigen::MatrixX<double> V_s1);
Eigen::MatrixX<double> PSTN(Eigen::MatrixX<double> TargetPostion, double ave_dem, double dt, bool isCol ); // 输入DEM
//Eigen::MatrixXd WGS842J2000(Eigen::MatrixXd blh);
//Landpoint WGS842J2000(Landpoint p);
public: // WGS84 到 J2000 之间的变换参数
Eigen::MatrixXd UTC;
double Xp = 0.204071;
double Yp = 0.318663;
double Dut1 = 0.0366742;
double Dat = 37;
public:
int height; // 影像的高
int width;
// 入射角
double near_in_angle;// 近入射角
double far_in_angle;// 远入射角
// SAR的成像参数
double fs;// 距离向采样率
double R0;//近斜距
double LightSpeed; // 光速
double lamda;// 波长
double refrange;// 参考斜距
double imgStartTime;// 成像起始时间
double PRF;// 脉冲重复率
int doppler_paramenter_number;//多普勒系数个数
MatrixX<double> doppler_paras;// 多普勒系数
OrbitPoly orbit; // 轨道模型
};
/// <summary>
/// 侧视入射角,角度值
/// </summary>
/// <param name="satepoint"></param>
/// <param name="landpoint"></param>
/// <returns></returns>
double getIncAngle(Landpoint& satepoint, Landpoint& landpoint);
/// <summary>
/// ASF计算方法
/// </summary>
class ASFOrthClass {
public:
Eigen::MatrixXd Satellite2ECR(Eigen::Vector3d Rsc, Eigen::Vector3d Vsc); // 根据卫星坐标计算变换矩阵 M
Eigen::Vector3d UnitVectorOfSatelliteAndTarget(double alpha, double beta, Eigen::MatrixXd M);
double GetLookFromRangeYaw(double R, double alpha, double beta, Eigen::Vector3d SatellitePosition, Eigen::Vector3d SatelliteVelocity, double R_threshold, double H = 0);
Eigen::Vector3d GetXYZByBetaAlpha(double alpha,double beta, Eigen::Vector3d SatellitePosition,double R, Eigen::MatrixXd M);
double FD(double alpha, double beta, Eigen::Vector3d SatelliteVelocity, Eigen::Vector3d TargetVelocity,double R,double lamda, Eigen::MatrixXd M);
double FR(double alpha, double beta, Eigen::Vector3d SatellitePosition, Eigen::MatrixXd M, double R_threshold, double H = 0);
Eigen::Vector3d ASF(double R, Eigen::Vector3d SatellitePosition, Eigen::Vector3d SatelliteVelocity, Eigen::Vector3d TargetPosition, PSTNAlgorithm PSTN, double R_threshold, double H = 0, double alpha0 = 0, double beta0 = 0);
};
/// <summary>
/// 仿真处理流程
/// </summary>
class simProcess {
public:
simProcess();
~simProcess();
int parameters(int argc, char* argv[]);
int InitSimulationSAR(QString paras_path,QString workspace_path,QString out_dir_path,QString in_dem_path,QString in_sar_path); // 间接定位法
int CreateSARDEM();
int dem2SAR(); // 切换行号
int SARIncidentAngle();
int SARSimulationWGS();
int SARSimulation();
int in_sar_power();
int ReflectTable_WGS2Range();
int InitRPCIncAngle(QString paras_path, QString workspace_path, QString out_dir_path, QString in_dem_path,QString in_rpc_lon_lat_path,QString out_inc_angle_path, QString out_local_inc_angle_path, QString out_inc_angle_geo_path, QString out_local_inc_angle_geo_path);
int dem2SAR_row(); // 切换行号
int SARIncidentAngle_RPC();
int createRPCDEM();
// 格网离散插值
int Scatter2Grid(QString lon_lat_path, QString data_tiff, QString grid_path, double space);
// ASF 模块计算
int InitASFSAR(QString paras_path, QString workspace_path, QString out_dir_path, QString in_dem_path);
int ASF(QString in_dem_path, QString out_latlon_path, ASFOrthClass asfclass, PSTNAlgorithm PSTN);
//int dem2simSAR(QString dem_path, QString out_sim_path, PSTNAlgorithm PSTN); // 根据DEM生成输出仿真图像
int sim_SAR(QString dem_path, QString sim_rc_path, QString sim_sar_path, PSTNAlgorithm PSTN);
int dem2aspect_slope(QString dem_path, QString aspect_path, QString slope_path);
int sim_sum_SAR(QString sim_dem_path,QString sim_rc_path, QString sim_orth_path, QString sim_sum_path,PSTNAlgorithm pstn);
void interpolation_GTC_sar_sigma(QString in_rc_wgs84_path, QString in_ori_sar_path, QString out_orth_sar_path, PSTNAlgorithm pstn);
// 原始影像强度图
int ori_sar_power(QString ori_sar_path, QString out_sar_power_path);
// 匹配偏移模型构建
int createImageMatchModel(QString ori_sar_rsc_path, QString ori_sar_rsc_jpg_path, QString sim_sar_path, QString sim_sar_jpg_path, QString matchmodel_path);
int correct_ati(QString orth_rc_path, QString dem_path, QString out_inclocal_path, QString out_dem_path, QString out_count_path, PSTNAlgorithm PSTN);
void calcalIncident_localIncident_angle(QString in_dem_path, QString in_rc_wgs84_path, QString out_incident_angle_path, QString out_local_incident_angle_path, PSTNAlgorithm PSTN);
void calGEC_Incident_localIncident_angle(QString in_dem_path, QString in_gec_lon_lat_path,QString out_incident_angle_path, QString out_local_incident_angle_path,PSTNAlgorithm PSTN);
void interpolation_GTC_sar(QString in_rc_wgs84_path, QString in_ori_sar_path, QString out_orth_sar_path, PSTNAlgorithm pstn);
// RPC
void CreateRPC_DEM(QString in_rpc_rc_path, QString in_dem_path, QString out_rpc_dem_path);
void CreateRPC_refrenceTable(QString in_rpc_tiff_path, QString in_merge_dem, QString out_rpc_lon_lat_tiff_path);
void CorrectionFromSLC2Geo(QString in_lon_lat_path, QString in_radar_path, QString out_radar_path, int in_band_ids);
// 内部参数
public:
bool isMatchModel;
QString workSpace_path;// 工作空间路径
QString outSpace_path;// 输出工作空间路径
PSTNAlgorithm pstn; // 参数组件
///// RPC 局地入射角 ///////////////////////////////////
QString in_rpc_lon_lat_path;
QString out_dir_path;
QString workspace_path;
// 临时文件
QString rpc_wgs_path;
QString ori_sim_count_tiff;// 映射角文件
// 输出文件
QString out_inc_angle_rpc_path;
QString out_local_inc_angle_rpc_path;
// 输出文件
QString out_inc_angle_geo_path;
QString out_local_inc_angle_geo_path;
///// 正向仿真方法 /////////
// 临时产品文件
QString in_dem_path; // 输入DEM
QString dem_path; // 重采样之后DEM
QString dem_r_path;// 行号影像
QString dem_rc_path; // 行列号
QString sar_sim_wgs_path;
QString sar_sim_path;
QString in_sar_path;
QString sar_jpg_path;
QString sar_power_path;
// 最终产品
QString out_dem_rc_path; // 经纬度与行列号变换文件
QString out_dem_slantRange_path; // 斜距文件
QString out_plant_slantRange_path;// 平面斜距文件
//// ASF 方法 /////////////
QString out_lon_path;// 经度
QString out_lat_path;// 纬度
QString out_slantRange_path;// 斜距文件
/// 共同文件 ///
QString out_localIncidenct_path;// 计算局地入射角
QString out_incidence_path; // 入射角文件
QString out_ori_sim_tiff;// 映射角文件'
QString out_sim_ori_tiff;
};
bool PtInRect(Point3 pCur, Point3 pLeftTop, Point3 pRightTop, Point3 pRightBelow, Point3 pLeftBelow);

View File

@ -0,0 +1,495 @@

#include "ImageShowDialogClass.h"
#include "ui_ImageShowDialogClass.h"
ImageShowDialogClass ::ImageShowDialogClass(QWidget *parent)
: QDialog(parent)
{
ui=new Ui::ImageShowDialogClass;
ui->setupUi(this);
ui->m_plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
connect(this->ui->m_plot, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(updateCursor(QMouseEvent*)));
this->graphclass=LAMPDATASHOWCLASS::NOWINDOWS;
this->menubar = new QMenuBar(this);
QMenu* windowsMenu = this->menubar->addMenu(u8"数据");
QAction* action_cursor_enable = windowsMenu->addAction(u8"打开游标");
QObject::connect(action_cursor_enable,SIGNAL(triggered()),this,SLOT(on_action_cursor_enable_trigged()));
this->tracer=new QCPItemTracer(this->ui->m_plot);
this->m_plot = ui->m_plot;
this->desCursor = nullptr;
this->HlineCursor = nullptr;
this->VlineCursor = nullptr;
this->desCursorflag=false;
this->HlineCursorflag=false;
this->VlineCursorflag = false;
this->statusbar=new QStatusBar(this);
this->statusbar->setMaximumHeight(20);
this->statusbar->setMinimumHeight(20);
ui->verticalLayout->setMenuBar(this->menubar);
ui->verticalLayout->addWidget(this->statusbar);
this->setLayout(ui->verticalLayout);
}
ImageShowDialogClass::~ImageShowDialogClass()
{}
void ImageShowDialogClass::on_action_cursor_enable_trigged()
{
this->desCursor = new ImageShowCursorDesClass(this);
this->desCursorflag = true;
for (size_t i = 0; i < this->getGraphCount(); i++) {
if (this->getGraphClass(i) == LAMPDATASHOWCLASS::LAMPColorMap) {
this->HlineCursorflag = true;
this->VlineCursorflag = true;
}
}
//下面的代码就是设置游标的外观
this->setMouseTracking(true);
tracer->setInterpolating(false);//禁用插值
tracer->setPen(QPen(Qt::DashLine));//虚线游标
tracer->setStyle(QCPItemTracer::tsPlus);//游标样式:十字星、圆圈、方框
tracer->setBrush(Qt::red);//游标颜色
if (this->graphclass == LAMPDATASHOWCLASS::LAMPColorMap) {
this->HlineCursor = new ImageShowCursorLineClass(this);
this->VlineCursor = new ImageShowCursorLineClass(this);
QObject::connect(this->HlineCursor, SIGNAL(windowsClose()), this, SLOT(on_action_Hlinecursor_close_trigged()));
QObject::connect(this->VlineCursor, SIGNAL(windowsClose()), this, SLOT(on_action_VVlinecursor_close_trigged()));
QObject::connect(this->ui->m_plot->xAxis, SIGNAL(rangeChanged(QCPRange)), this->HlineCursor, SLOT(xAxisRangeChanged(QCPRange)));
QObject::connect(this->ui->m_plot->yAxis, SIGNAL(rangeChanged(QCPRange)), this->HlineCursor, SLOT(xAxisRangeChanged(QCPRange)));
this->HlineCursor->show();
this->VlineCursor->show();
}
this->desCursor->show();
QObject::connect(this->desCursor, SIGNAL(windowsClose()), this, SLOT(on_action_descursor_close_trigged()));
}
void ImageShowDialogClass::PlotLine(QVector<double> xs, QVector<double> dataValues,QString Name)
{
if (dataValues.count() == 0) { return; }
QCPGraph* graph = ui->m_plot->addGraph();
graph->setName(Name);
graph->setData(xs, dataValues);
double min_y = dataValues[0];
double max_y = dataValues[0];
for (size_t i = 0; i < dataValues.count(); i++) {
min_y = min_y > dataValues[i] ? dataValues[i] : min_y;
max_y = max_y < dataValues[i] ? dataValues[i] : max_y;
}
double min_x = xs[0];
double max_x = xs[0];
for (size_t i = 0; i < xs.count(); i++) {
min_x = min_x > xs[i] ? xs[i] : min_x;
max_x = max_x < xs[i] ? xs[i] : max_x;
}
ui->m_plot->xAxis->setRange(min_x, max_x);
ui->m_plot->yAxis->setRange(min_y, max_y);
ui->m_plot->legend->setVisible(true);
ui->m_plot->replot();
//下面的代码就是设置游标的外观
this->setMouseTracking(true);
tracer->setInterpolating(false);//禁用插值
tracer->setPen(QPen(Qt::DashLine));//虚线游标
tracer->setStyle(QCPItemTracer::tsPlus);//游标样式:十字星、圆圈、方框
tracer->setBrush(Qt::red);//游标颜色
tracer->setGraph(graph); // 确保游标跟随
this->m_graphMap.insert(Name, graph);
}
void ImageShowDialogClass::Scatter(double dx,double dy)
{
QVector<double>xs(0);
QVector<double>ys(0);
xs.push_back(dx);
ys.push_back(dy);
// 设置画笔风格
QPen drawPen;
drawPen.setColor(Qt::red);
drawPen.setWidth(4);
// 绘制散点
QCPGraph* curGraph = ui->m_plot->addGraph();
curGraph->setPen(drawPen);
curGraph->setLineStyle(QCPGraph::lsNone);
curGraph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 2));
curGraph->setData(xs, ys);
ui->m_plot->xAxis->setVisible(true);
ui->m_plot->yAxis->setVisible(true);
}
void ImageShowDialogClass::Scatter(QVector<double> xs, QVector<double> ys)
{
// 设置画笔风格
QPen drawPen;
drawPen.setColor(Qt::red);
drawPen.setWidth(4);
// 绘制散点
QCPGraph* curGraph = ui->m_plot->addGraph();
curGraph->setPen(drawPen);
curGraph->setLineStyle(QCPGraph::lsNone);
curGraph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 2));
curGraph->setData(xs, ys);
ui->m_plot->xAxis->setVisible(true);
ui->m_plot->yAxis->setVisible(true);
}
void ImageShowDialogClass::load_double_MatrixX_data(Eigen::MatrixXd data, QString name)
{
this->setWindowTitle(name);
this->graphclass = LAMPDATASHOWCLASS::LAMPColorMap;
int ny = data.rows(); // 行数
int nx = data.cols(); // 列数
// 创建 Color Map
QCPColorMap* colorMap = new QCPColorMap(ui->m_plot->xAxis, ui->m_plot->yAxis);
colorMap->data()->setSize(nx, ny); // 设置 Color Map 的大小
colorMap->data()->setRange(QCPRange(0, nx), QCPRange(0, ny)); // 设置坐标轴的范围
// 填充数据
for (int xIndex = 0; xIndex < nx; ++xIndex) {
for (int yIndex = 0; yIndex < ny; ++yIndex) {
double magnitude = data(yIndex, xIndex); // 或者使用 std::arg() 获取相位
colorMap->data()->setCell(xIndex, yIndex,magnitude);
}
}
colorMap->setGradient(QCPColorGradient::gpJet);
colorMap->rescaleDataRange(true);
ui->m_plot->rescaleAxes();
ui->m_plot->replot();
}
void ImageShowDialogClass::load_double_MatrixX_data(Eigen::MatrixXd X, Eigen::MatrixXd Y, Eigen::MatrixXd data, QString name)
{
this->graphclass = LAMPDATASHOWCLASS::LAMPColorMap;
int nx = data.cols(); // 行数
int ny = data.rows(); // 列数
// 创建 Color Map
ui->m_plot->xAxis->setRange(X(0, 0), X(0, nx - 1));
ui->m_plot->yAxis->setRange(Y(0, 0), Y(ny - 1, 0));
QCPColorMap* colorMap = new QCPColorMap(ui->m_plot->xAxis, ui->m_plot->yAxis);
colorMap->data()->setSize(ny, nx); // 设置 Color Map 的大小
colorMap->data()->setRange(QCPRange(X(0,0), X(0,nx-1)), QCPRange(Y(0,0),Y(ny-1,0))); // 设置坐标轴的范围
// 填充数据
for (int xIndex = 0; xIndex < nx; ++xIndex) {
for (int yIndex = 0; yIndex < ny; ++yIndex) {
double magnitude = data(yIndex, xIndex); // 或者使用 std::arg() 获取相位
colorMap->data()->setCell(yIndex, xIndex, magnitude);
}
}
// add a color scale:
QCPColorScale* m_colorScale = new QCPColorScale(m_plot);
m_plot->plotLayout()->addElement(0, 1, m_colorScale);
m_colorScale->setType(QCPAxis::atRight);
colorMap->setColorScale(m_colorScale);
colorMap->setGradient(QCPColorGradient::gpJet);
colorMap->rescaleDataRange(true);
ui->m_plot->rescaleAxes();
ui->m_plot->replot();
}
void ImageShowDialogClass::remove_Data(QString name)
{
for(size_t i=0;i<this->m_plot->graphCount();i++){
if (this->m_plot->graph(i)->name() == name) {
this->m_plot->removeGraph(i);
this->m_plot->replot();
return;
}
}
}
LAMPDATASHOWCLASS ImageShowDialogClass::getGraphClass(size_t i)
{
if (this->m_plot->graphCount() == 0 || i > this->m_plot->graphCount())
{
return LAMPDATASHOWCLASS::NOWINDOWS;
}
QCPAbstractPlottable* plottable = this->ui->m_plot->plottable(i);
if (dynamic_cast<QCPGraph*>(plottable)) {
return LAMPDATASHOWCLASS::LAMPGraph;
}
else if (dynamic_cast<QCPScatterStyle*>(plottable)) {
return LAMPDATASHOWCLASS::LAMPScatterStyle;
}
else if (dynamic_cast<QCPColorMap*>(plottable)) {
return LAMPDATASHOWCLASS::LAMPColorMap;
}
else {
return LAMPDATASHOWCLASS::NOWINDOWS;
}
}
size_t ImageShowDialogClass::getGraphCount()
{
return this->m_plot->graphCount();
}
void ImageShowDialogClass::on_action_descursor_close_trigged()
{
this->desCursorflag = false;
}
void ImageShowDialogClass::on_action_Hlinecursor_close_trigged()
{
this->HlineCursorflag = false;
}
void ImageShowDialogClass::on_action_VVlinecursor_close_trigged()
{
this->VlineCursorflag = false;
}
void ImageShowDialogClass::updateCursor(QMouseEvent *event)
{
if (this->desCursorflag &&this->HlineCursorflag &&this->VlineCursorflag) {
//下面的代码就是设置游标的外观
this->setMouseTracking(false);
}
else {
// 准备获取数据
QPoint pos = event->pos();
double x=this->m_plot->xAxis->pixelToCoord(pos.x()); // 将鼠标位置映射到图表坐标系中
double y = this->m_plot->yAxis->pixelToCoord(pos.y());
this->statusbar->showMessage(u8"X: "+QString::number(x,'f', 6)+" y: "+QString::number(y, 'f', 6));
if (this->desCursorflag) {
if (this->graphclass == LAMPDATASHOWCLASS::LAMPColorMap) {
QCPColorMap* colorMap = dynamic_cast<QCPColorMap*>(this->ui->m_plot->plottable(0));
double dataValue = colorMap->data()->data(x, y);
this->desCursor->updateCursorContent(u8"X: " + QString::number(x, 'f', 6) + " y: " + QString::number(y, 'f', 6) +u8"\n" +u8"DataValue: "+QString::number(dataValue));
double xMin = this->m_plot->xAxis->range().lower;
double xMax = this->m_plot->xAxis->range().upper;
double yMin = this->m_plot->yAxis->range().lower;
double yMax = this->m_plot->yAxis->range().upper;
long XCount = 1000;
double xdelte = (xMax - xMin) / (XCount-1);
double ydelte = (yMax - yMin) / (XCount-1);
qDebug() << xMin << "," << xMax << " " << yMin << "," << yMax << " " << XCount<<" "<<xdelte<<" "<<ydelte;
QVector<double> Hx(XCount);
QVector<double> Hy(XCount);
QVector<double> Vx(XCount);
QVector<double> Vy(XCount);
for (long i = 0; i < XCount; i++)
{
Hx[i] = i * xdelte + xMin;
Hy[i] = colorMap->data()->data(Hx[i], y);
Vx[i] = i * ydelte + yMin;
Vy[i] = colorMap->data()->data(x, Vx[i]);
}
this->HlineCursor->UpdatePlotLine(Hx, Hy, u8"水平"); // 水平
this->VlineCursor->UpdatePlotLine(Vx, Vy, u8"垂直"); // 垂直
}
else if (this->graphclass == LAMPDATASHOWCLASS::LAMPGraph) {
}
else if (this->graphclass == LAMPDATASHOWCLASS::LAMPScatterStyle) {
}
else {
this->desCursor->updateCursorContent(u8"无法识别图像类型");
}
}
if (this->HlineCursorflag) {
}
if (this->VlineCursorflag) {
}
}
}
ImageShowCursorDesClass::ImageShowCursorDesClass(QWidget* parent)
{
// 创建 QLabel
label = new QLabel(this);
QFont font;
font.setPointSize(20); // 设置字体大小为20
label->setFont(font);
// 创建布局
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(label);
// 设置布局
setLayout(layout);
this->resize(100, 50);
}
ImageShowCursorDesClass::~ImageShowCursorDesClass()
{
}
void ImageShowCursorDesClass::closeEvent(QCloseEvent* event)
{
QDialog::closeEvent(event);
}
void ImageShowCursorDesClass::updateCursorContent(QString content) {
this->label->setText(content);
}
ImageShowCursorLineClass::ImageShowCursorLineClass(QWidget* parent):QDialog(parent)
{
this->menubar = new QMenuBar(this);
//QMenu* toolMenu = this->menubar->addMenu(u8"工具");
//QAction* action_add_compare_line = toolMenu->addAction(u8"添加对比数据");
//QObject::connect(action_add_compare_line, SIGNAL(triggered()), this, SLOT(load_new_compare_line()));
this->tracerEnable = false;
this->tracer = nullptr;
this->tracerXText = nullptr;
this->tracerYText = nullptr;
// 创建 QLabel
this->customPlot = new QCustomPlot(this);
// 创建布局
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(this->customPlot);
// 设置布局
setLayout(layout);
this->tracer = new QCPItemTracer(this->customPlot);
this->tracerYText = new QCPItemText(this->customPlot);
this->tracerXText = new QCPItemText(this->customPlot);
QObject::connect(this->customPlot, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(updateCursor(QMouseEvent*)));
this->customPlot->legend->setVisible(true);
this->setMinimumWidth(600);
this->setMinimumHeight(400);
}
ImageShowCursorLineClass::~ImageShowCursorLineClass()
{
}
void ImageShowCursorLineClass::loadPlotLine(QVector<double> xs, QVector<double> dataValues,QString Name)
{
if (dataValues.count() == 0) { return; }
QCPGraph* graph = this->customPlot->addGraph();
graph->setName(Name);
graph->setData(xs, dataValues);
double min_y = dataValues[0];
double max_y = dataValues[0];
for (size_t i = 0; i < dataValues.count(); i++) {
min_y = min_y > dataValues[i] ? dataValues[i] : min_y;
max_y = max_y < dataValues[i] ? dataValues[i] : max_y;
}
double min_x = xs[0];
double max_x = xs[0];
for (size_t i = 0; i < xs.count(); i++) {
min_x = min_x > xs[i] ? xs[i] : min_x;
max_x = max_x < xs[i] ? xs[i] : max_x;
}
customPlot->xAxis->setRange(min_x, max_x);
customPlot->yAxis->setRange(min_y, max_y);
customPlot->legend->setVisible(true);
customPlot->replot();
//下面的代码就是设置游标的外观
this->setMouseTracking(true);
tracer->setInterpolating(false);//禁用插值
tracer->setPen(QPen(Qt::DashLine));//虚线游标
tracer->setStyle(QCPItemTracer::tsPlus);//游标样式:十字星、圆圈、方框
tracer->setBrush(Qt::red);//游标颜色
tracer->setGraph(graph); // 确保游标跟随
this->m_graphMap.insert(Name, graph);
this->TrackName = Name;
}
void ImageShowCursorLineClass::UpdatePlotLine(QVector<double> xs, QVector<double> dataValues, QString Name)
{
this->customPlot->clearGraphs();
this->loadPlotLine(xs, dataValues, Name);
}
void ImageShowCursorLineClass::updateCursor(QMouseEvent* event)
{
if (tracerEnable)//游标使能
{
double x = this->customPlot->xAxis->pixelToCoord(event->pos().x());//鼠标点的像素坐标转plot坐标
tracer->setGraphKey(x);//设置游标的X值这就是游标随动的关键代码
double traceX = tracer->position->key();
double traceY = tracer->position->value();
tracerXText->setText(QDateTime::fromMSecsSinceEpoch(traceX * 1000.0).toString("hh:mm:ss.zzz"));//游标文本框指示游标的X值
tracerYText->setText(QString::number(traceY));//游标文本框指示游标的Y值
////计算游标X值对应的所有曲线的Y值
//for (int i = 0; i < this->customPlot->graphCount(); i++)
//{
// QCPGraph* graph = dynamic_cast<QCPGraph*>(this->customPlot->plottable(i));
// //搜索左边离traceX最近的key对应的点详情参考findBegin函数的帮助
// QCPDataContainer<QCPGraphData>::const_iterator coorPoint = graph->data().data()->findBegin(traceX, true);//true代表向左搜索
// qDebug() << QString("graph%1对应的Y值是").arg(i) << coorPoint->value;
//}
}
}
void ImageShowCursorLineClass::closeEvent(QCloseEvent* event)
{
QDialog::closeEvent(event);
}
void ImageShowCursorLineClass::xAxisRangeChanged(QCPRange range) {
this->customPlot->xAxis->setRange(range);
customPlot->replot();
}
void ImageShowCursorLineClass::yAxisRangeChanged(QCPRange range) {
this->customPlot->yAxis->setRange(range);
customPlot->replot();
}
void ImageShowCursorLineClass::on_SwichTracerGraph_Name()
{
}
void ImageShowCursorLineClass::load_new_compare_line()
{
}

View File

@ -0,0 +1,154 @@

#pragma once
#ifndef IMAGESHOWDIALOGCLASS_H
#define IMAGESHOWDIALOGCLASS_H
#include "../BaseLibraryCPP/BaseConstVariable.h"
#include <QDialog>
#include <QLabel>
#include "qcustomplot.h"
#include <Eigen/Core>
#include <Eigen/Dense>
//===========================
// 定义需要绘制的图像的类型
//===========================
enum LAMPDATASHOWCLASS {
LAMPGraph,
LAMPColorMap,
LAMPScatterStyle,
NOWINDOWS
};
namespace Ui {
class ImageShowDialogClass;
};
//===========================
// 构建游标类型
// 1. 单纯的描述游标,主要用来展示坐标,还有当前数据信息
// 2. 区域性描述游标,通过线,等用来展示某一个区域的信息
//===========================
class ImageShowCursorDesClass : public QDialog
{
Q_OBJECT
public:
QLabel* label;
public:
ImageShowCursorDesClass(QWidget* parent = nullptr);
~ImageShowCursorDesClass();
public slots:
void updateCursorContent(QString content);
signals:
bool windowsClose();
protected:
void closeEvent(QCloseEvent* event) override;
};
class ImageShowCursorLineClass :public QDialog {
Q_OBJECT
public:
QMenuBar* menubar;
QMenu* DataList;
QMenu* RemoveList;
QCustomPlot* customPlot;
bool tracerEnable;
QCPItemTracer* tracer; //游标
QCPItemText* tracerYText; //图标标签
QCPItemText* tracerXText; //游标标签
QMap<QString, QCPAbstractPlottable*> m_graphMap;
QMap<QString, QAction*> data_action_map;
QString TrackName;
public:
ImageShowCursorLineClass(QWidget* parent = nullptr);
~ImageShowCursorLineClass();
public:
void loadPlotLine(QVector<double> xs, QVector<double> dataValues, QString Name);
void UpdatePlotLine(QVector<double> xs, QVector<double> dataValues, QString Name);
void updateCursor(QMouseEvent* event);
public slots:
void xAxisRangeChanged(QCPRange);
void yAxisRangeChanged(QCPRange);
void on_SwichTracerGraph_Name();
void load_new_compare_line();
signals:
bool windowsClose();
protected:
void closeEvent(QCloseEvent* event) override;
};
//===========================
// 构建数据展示窗口
// 1. 单纯的描述游标,主要用来展示坐标,还有当前数据信息
// 2. 区域性描述游标,通过线,等用来展示某一个区域的信息
//===========================
class ImageShowDialogClass : public QDialog
{
Q_OBJECT
private:
LAMPDATASHOWCLASS graphclass;
public:
QMenuBar* menubar;
QStatusBar* statusbar;
ImageShowCursorDesClass* desCursor; // 描述游标
ImageShowCursorLineClass* HlineCursor;// H 游标
ImageShowCursorLineClass* VlineCursor;// V 游标
bool desCursorflag;
bool HlineCursorflag;
bool VlineCursorflag;
QCustomPlot* m_plot;
QCPItemTracer* tracer; //游标
public:
QMap<QString, QCPAbstractPlottable*> m_graphMap;
public:
ImageShowDialogClass(QWidget *parent = nullptr);
~ImageShowDialogClass();
public:
void PlotLine(QVector<double> xs, QVector<double> ys, QString Name);
void Scatter(double dx, double dy);
void Scatter(QVector<double> xs, QVector<double> ys);
void load_double_MatrixX_data(Eigen::MatrixXd data, QString name);
void load_double_MatrixX_data(Eigen::MatrixXd X,Eigen::MatrixXd Y,Eigen::MatrixXd data, QString name);
void remove_Data( QString name);
LAMPDATASHOWCLASS getGraphClass(size_t i = 0);
size_t getGraphCount();
private:
Ui::ImageShowDialogClass* ui;
public slots:
void updateCursor(QMouseEvent* event);
public slots: // cursor
void on_action_cursor_enable_trigged();
void on_action_descursor_close_trigged();
void on_action_Hlinecursor_close_trigged();
void on_action_VVlinecursor_close_trigged();
};
#endif

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImageShowDialogClass</class>
<widget class="QDialog" name="ImageShowDialogClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>复数展示</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCustomPlot" name="m_plot" native="true"/>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QCustomPlot</class>
<extends>QWidget</extends>
<header location="global">qcustomplot.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

30216
Imageshow/qcustomplot.cpp Normal file

File diff suppressed because it is too large Load Diff

6675
Imageshow/qcustomplot.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
<RCC>
<qresource prefix="qcustomplot">
</qresource>
</RCC>

28
Imageshow/qcustomplot.ui Normal file
View File

@ -0,0 +1,28 @@
<UI version="4.0" >
<class>qcustomplotClass</class>
<widget class="QMainWindow" name="qcustomplotClass" >
<property name="objectName" >
<string notr="true">qcustomplotClass</string>
</property>
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle" >
<string>qcustomplot</string>
</property> <widget class="QMenuBar" name="menuBar" />
<widget class="QToolBar" name="mainToolBar" />
<widget class="QWidget" name="centralWidget" />
<widget class="QStatusBar" name="statusBar" />
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources>
<include location="qcustomplot.qrc"/>
</resources>
<connections/>
</UI>

View File

@ -12,7 +12,7 @@ QMergeRasterProcessDialog::QMergeRasterProcessDialog(QWidget *parent)
QObject::connect(ui.pushButtonSelect, SIGNAL(clicked(bool)), this, SLOT(onpushButtonSelectClick(bool)));
QObject::connect(ui.AddpushButton, SIGNAL(clicked(bool)), this, SLOT(onAddpushButtonClick(bool)));
QObject::connect(ui.RemovepushButton, SIGNAL(clicked(bool())), this, SLOT(onRemovepushButtonClick(bool)));
QObject::connect(ui.RemovepushButton, SIGNAL(clicked(bool)), this, SLOT(onRemovepushButtonClick(bool)));
QObject::connect(ui.buttonBoxDialog, SIGNAL(accepted()), this, SLOT(acceptclick()));
QObject::connect(ui.buttonBoxDialog, SIGNAL(rejected()), this, SLOT(rejectclick()));
}
@ -86,4 +86,5 @@ void QMergeRasterProcessDialog::acceptclick()
void QMergeRasterProcessDialog::rejectclick()
{
this->close();
}

View File

@ -6,21 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>538</width>
<width>802</width>
<height>450</height>
</rect>
</property>
<property name="windowTitle">
<string>QMergeRasterProcessDialog</string>
<string>GF3图像slc合并</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttonBoxDialog">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
@ -45,6 +38,9 @@
<height>30</height>
</size>
</property>
<property name="text">
<string>D:\Programme\vs2022\RasterMergeTest\RasterMergeTest.tif</string>
</property>
</widget>
</item>
<item>
@ -63,7 +59,14 @@
</layout>
</widget>
</item>
<item row="1" column="2">
<item row="5" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttonBoxDialog">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
@ -108,8 +111,122 @@
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QListWidget" name="listWidgetRaster"/>
<item row="3" column="1">
<widget class="QListWidget" name="listWidgetRaster">
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
<item>
<property name="text">
<string>D:\Programme\vs2022\RasterMergeTest\inraster\GF3B_KSC_QPSI_010328_E86.1_N44.3_20231109_L1A_AHV_L10000262133-ortho-SSAA.tif</string>
</property>
</item>
<item>
<property name="text">
<string>D:\Programme\vs2022\RasterMergeTest\inraster\GF3B_KSC_QPSI_010364_E85.9_N44.6_20231112_L1A_AHV_L10000263359-ortho-SSAA.tif</string>
</property>
</item>
<item>
<property name="text">
<string>D:\Programme\vs2022\RasterMergeTest\inraster\GF3C_KSC_QPSI_008440_E86.0_N44.7_20231113_L1A_AHV_L10000215825-ortho-SSAA.tif</string>
</property>
</item>
<item>
<property name="text">
<string>D:\Programme\vs2022\RasterMergeTest\inraster\GF3C_KSC_QPSI_008440_E86.1_N44.4_20231113_L1A_AHV_L10000215824-ortho-SSAA.tif</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QWidget" name="widget_5" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string> 裁剪shp</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditOutPath_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>D:\Programme\vs2022\RasterMergeTest\RasterMergeTesClip.shp</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonSelect_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>打开</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QWidget" name="widget_6" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string> DEM影像</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditOutPath_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>D:\Programme\vs2022\RasterMergeTest\pinjie\demMerge.tif</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonSelect_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>打开</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>

BIN
RasterProcessTool.rar Normal file

Binary file not shown.

View File

@ -30,6 +30,9 @@
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseInteloneMKL>Parallel</UseInteloneMKL>
<UseILP64Interfaces1A>true</UseILP64Interfaces1A>
<UseIntelMPI>true</UseIntelMPI>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')">
@ -103,7 +106,18 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="SimulationSAR\RTPCProcessCls.cpp" />
<ClCompile Include="SimulationSAR\SARSatelliteSimulationAbstractCls.cpp" />
<ClCompile Include="SimulationSAR\SARSimulationTaskSetting.cpp" />
<ClCompile Include="SimulationSAR\SatelliteOribtModel.cpp" />
<ClCompile Include="SimulationSAR\SigmaDatabase.cpp" />
<QtRcc Include="Imageshow\qcustomplot.qrc" />
<QtRcc Include="RasterProcessTool.qrc" />
<QtUic Include="GF3ProcessToolbox\QComplex2AmpPhase.ui" />
<QtUic Include="GF3ProcessToolbox\QImportGF3StripL1ADataset.ui" />
<QtUic Include="GF3ProcessToolbox\QRDOrthProcessClass.ui" />
<QtUic Include="Imageshow\ImageShowDialogClass.ui" />
<QtUic Include="Imageshow\qcustomplot.ui" />
<QtUic Include="QMergeRasterProcessDialog.ui" />
<QtUic Include="QToolProcessBarDialog.ui" />
<QtUic Include="RasterProcessTool.ui" />
@ -119,6 +133,17 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="GF3ProcessToolbox\GF3CalibrationAndGeocodingClass.cpp" />
<ClCompile Include="GF3ProcessToolbox\GF3PSTNClass.cpp" />
<ClCompile Include="GF3ProcessToolbox\QComplex2AmpPhase.cpp" />
<ClCompile Include="GF3ProcessToolbox\QImportGF3StripL1ADataset.cpp" />
<ClCompile Include="GF3ProcessToolbox\QRDOrthProcessClass.cpp" />
<ClCompile Include="GF3ProcessToolbox\SatelliteGF3xmlParser.cpp" />
<ClCompile Include="GF3ProcessToolbox\SateOrbit.cpp" />
<ClCompile Include="GF3ProcessToolbox\simptsn.cpp" />
<ClCompile Include="GF3ProcessToolbox\WGS84_J2000.cpp" />
<ClCompile Include="Imageshow\ImageShowDialogClass.cpp" />
<ClCompile Include="Imageshow\qcustomplot.cpp" />
<ClCompile Include="QMergeRasterProcessDialog.cpp" />
<ClCompile Include="QToolProcessBarDialog.cpp" />
<ClCompile Include="RasterProcessTool.cpp" />
@ -130,10 +155,26 @@
<ClInclude Include="BaseLibraryCPP\EchoDataFormat.h" />
<ClInclude Include="BaseLibraryCPP\FileOperator.h" />
<ClInclude Include="BaseLibraryCPP\GeoOperator.h" />
<ClInclude Include="BaseLibraryCPP\ImageOperatorBase.h" />
<ClInclude Include="SimulationSAR\RTPCProcessCls.h" />
<ClInclude Include="SimulationSAR\SARSatelliteSimulationAbstractCls.h" />
<ClInclude Include="SimulationSAR\SARSimulationTaskSetting.h" />
<ClInclude Include="SimulationSAR\SatelliteOribtModel.h" />
<ClInclude Include="SimulationSAR\SigmaDatabase.h" />
<QtMoc Include="BaseLibraryCPP\ImageOperatorBase.h" />
<ClInclude Include="BaseLibraryCPP\LogInfoCls.h" />
<ClInclude Include="BaseLibraryCPP\SARSimulationImageL1.h" />
<ClInclude Include="BaseLibraryCPP\stdafx.h" />
<ClInclude Include="GF3ProcessToolbox\GF3CalibrationAndGeocodingClass.h" />
<ClInclude Include="GF3ProcessToolbox\GF3PSTNClass.h" />
<QtMoc Include="GF3ProcessToolbox\QImportGF3StripL1ADataset.h" />
<QtMoc Include="GF3ProcessToolbox\QComplex2AmpPhase.h" />
<QtMoc Include="GF3ProcessToolbox\QRDOrthProcessClass.h" />
<ClInclude Include="GF3ProcessToolbox\SatelliteGF3xmlParser.h" />
<ClInclude Include="GF3ProcessToolbox\SateOrbit.h" />
<ClInclude Include="GF3ProcessToolbox\simptsn.h" />
<ClInclude Include="GF3ProcessToolbox\WGS84_J2000.h" />
<QtMoc Include="Imageshow\qcustomplot.h" />
<QtMoc Include="Imageshow\ImageShowDialogClass.h" />
<QtMoc Include="QToolProcessBarDialog.h" />
<QtMoc Include="QMergeRasterProcessDialog.h" />
</ItemGroup>

View File

@ -24,6 +24,15 @@
<Filter Include="BaseLibraryCPP">
<UniqueIdentifier>{101c627b-537e-4c7f-862c-380d3f7f226f}</UniqueIdentifier>
</Filter>
<Filter Include="Imageshow">
<UniqueIdentifier>{dec5c630-193b-4820-a36a-e1dada57e814}</UniqueIdentifier>
</Filter>
<Filter Include="GF3ProcessToolbox">
<UniqueIdentifier>{c49d5cbf-5e46-46f8-880c-1f1f9d6e32e9}</UniqueIdentifier>
</Filter>
<Filter Include="SimulationSAR">
<UniqueIdentifier>{c019ab22-835f-44bd-8689-f5550c9c690d}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<QtRcc Include="RasterProcessTool.qrc">
@ -38,6 +47,9 @@
<ClCompile Include="RasterProcessTool.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<QtRcc Include="Imageshow\qcustomplot.qrc">
<Filter>Imageshow</Filter>
</QtRcc>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
@ -73,6 +85,54 @@
<ClCompile Include="QToolProcessBarDialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Imageshow\ImageShowDialogClass.cpp">
<Filter>Imageshow</Filter>
</ClCompile>
<ClCompile Include="Imageshow\qcustomplot.cpp">
<Filter>Imageshow</Filter>
</ClCompile>
<ClCompile Include="GF3ProcessToolbox\GF3CalibrationAndGeocodingClass.cpp">
<Filter>GF3ProcessToolbox</Filter>
</ClCompile>
<ClCompile Include="GF3ProcessToolbox\GF3PSTNClass.cpp">
<Filter>GF3ProcessToolbox</Filter>
</ClCompile>
<ClCompile Include="GF3ProcessToolbox\SatelliteGF3xmlParser.cpp">
<Filter>GF3ProcessToolbox</Filter>
</ClCompile>
<ClCompile Include="GF3ProcessToolbox\SateOrbit.cpp">
<Filter>GF3ProcessToolbox</Filter>
</ClCompile>
<ClCompile Include="GF3ProcessToolbox\simptsn.cpp">
<Filter>GF3ProcessToolbox</Filter>
</ClCompile>
<ClCompile Include="GF3ProcessToolbox\WGS84_J2000.cpp">
<Filter>GF3ProcessToolbox</Filter>
</ClCompile>
<ClCompile Include="GF3ProcessToolbox\QImportGF3StripL1ADataset.cpp">
<Filter>GF3ProcessToolbox</Filter>
</ClCompile>
<ClCompile Include="GF3ProcessToolbox\QComplex2AmpPhase.cpp">
<Filter>GF3ProcessToolbox</Filter>
</ClCompile>
<ClCompile Include="GF3ProcessToolbox\QRDOrthProcessClass.cpp">
<Filter>GF3ProcessToolbox</Filter>
</ClCompile>
<ClCompile Include="SimulationSAR\RTPCProcessCls.cpp">
<Filter>SimulationSAR</Filter>
</ClCompile>
<ClCompile Include="SimulationSAR\SARSatelliteSimulationAbstractCls.cpp">
<Filter>SimulationSAR</Filter>
</ClCompile>
<ClCompile Include="SimulationSAR\SARSimulationTaskSetting.cpp">
<Filter>SimulationSAR</Filter>
</ClCompile>
<ClCompile Include="SimulationSAR\SatelliteOribtModel.cpp">
<Filter>SimulationSAR</Filter>
</ClCompile>
<ClCompile Include="SimulationSAR\SigmaDatabase.cpp">
<Filter>SimulationSAR</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="BaseLibraryCPP\BaseConstVariable.h">
@ -90,9 +150,6 @@
<ClInclude Include="BaseLibraryCPP\GeoOperator.h">
<Filter>BaseLibraryCPP</Filter>
</ClInclude>
<ClInclude Include="BaseLibraryCPP\ImageOperatorBase.h">
<Filter>BaseLibraryCPP</Filter>
</ClInclude>
<ClInclude Include="BaseLibraryCPP\LogInfoCls.h">
<Filter>BaseLibraryCPP</Filter>
</ClInclude>
@ -102,6 +159,39 @@
<ClInclude Include="BaseLibraryCPP\stdafx.h">
<Filter>BaseLibraryCPP</Filter>
</ClInclude>
<ClInclude Include="GF3ProcessToolbox\GF3CalibrationAndGeocodingClass.h">
<Filter>GF3ProcessToolbox</Filter>
</ClInclude>
<ClInclude Include="GF3ProcessToolbox\GF3PSTNClass.h">
<Filter>GF3ProcessToolbox</Filter>
</ClInclude>
<ClInclude Include="GF3ProcessToolbox\SatelliteGF3xmlParser.h">
<Filter>GF3ProcessToolbox</Filter>
</ClInclude>
<ClInclude Include="GF3ProcessToolbox\SateOrbit.h">
<Filter>GF3ProcessToolbox</Filter>
</ClInclude>
<ClInclude Include="GF3ProcessToolbox\simptsn.h">
<Filter>GF3ProcessToolbox</Filter>
</ClInclude>
<ClInclude Include="GF3ProcessToolbox\WGS84_J2000.h">
<Filter>GF3ProcessToolbox</Filter>
</ClInclude>
<ClInclude Include="SimulationSAR\RTPCProcessCls.h">
<Filter>SimulationSAR</Filter>
</ClInclude>
<ClInclude Include="SimulationSAR\SARSatelliteSimulationAbstractCls.h">
<Filter>SimulationSAR</Filter>
</ClInclude>
<ClInclude Include="SimulationSAR\SARSimulationTaskSetting.h">
<Filter>SimulationSAR</Filter>
</ClInclude>
<ClInclude Include="SimulationSAR\SatelliteOribtModel.h">
<Filter>SimulationSAR</Filter>
</ClInclude>
<ClInclude Include="SimulationSAR\SigmaDatabase.h">
<Filter>SimulationSAR</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<QtMoc Include="QMergeRasterProcessDialog.h">
@ -110,6 +200,24 @@
<QtMoc Include="QToolProcessBarDialog.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="Imageshow\ImageShowDialogClass.h">
<Filter>Imageshow</Filter>
</QtMoc>
<QtMoc Include="Imageshow\qcustomplot.h">
<Filter>Imageshow</Filter>
</QtMoc>
<QtMoc Include="GF3ProcessToolbox\QImportGF3StripL1ADataset.h">
<Filter>GF3ProcessToolbox</Filter>
</QtMoc>
<QtMoc Include="GF3ProcessToolbox\QComplex2AmpPhase.h">
<Filter>GF3ProcessToolbox</Filter>
</QtMoc>
<QtMoc Include="BaseLibraryCPP\ImageOperatorBase.h">
<Filter>BaseLibraryCPP</Filter>
</QtMoc>
<QtMoc Include="GF3ProcessToolbox\QRDOrthProcessClass.h">
<Filter>GF3ProcessToolbox</Filter>
</QtMoc>
</ItemGroup>
<ItemGroup>
<QtUic Include="QMergeRasterProcessDialog.ui">
@ -118,5 +226,20 @@
<QtUic Include="QToolProcessBarDialog.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="Imageshow\ImageShowDialogClass.ui">
<Filter>Imageshow</Filter>
</QtUic>
<QtUic Include="Imageshow\qcustomplot.ui">
<Filter>Imageshow</Filter>
</QtUic>
<QtUic Include="GF3ProcessToolbox\QImportGF3StripL1ADataset.ui">
<Filter>GF3ProcessToolbox</Filter>
</QtUic>
<QtUic Include="GF3ProcessToolbox\QComplex2AmpPhase.ui">
<Filter>GF3ProcessToolbox</Filter>
</QtUic>
<QtUic Include="GF3ProcessToolbox\QRDOrthProcessClass.ui">
<Filter>GF3ProcessToolbox</Filter>
</QtUic>
</ItemGroup>
</Project>

View File

@ -0,0 +1,774 @@
#include "stdafx.h"
#include "RTPCProcessCls.h"
#include "BaseConstVariable.h"
#include "SARSatelliteSimulationAbstractCls.h"
#include "SARSimulationTaskSetting.h"
#include "SatelliteOribtModel.h"
#include <QDebug>
#include "ImageOperatorBase.h"
#include "GeoOperator.h"
#include "EchoDataFormat.h"
#include <QDir>
#include <QDatetime>
#include <omp.h>
#ifdef DEBUGSHOWDIALOG
#include "ImageShowDialogClass.h"
#endif
RTPCProcessCls::RTPCProcessCls()
{
this->PluseCount = 0;
this->PlusePoint = 0;
this->TaskSetting = nullptr;
this->EchoSimulationData = nullptr;
this->DEMTiffPath="";
this->LandCoverPath="";
this->HHSigmaPath="";
this->HVSigmaPath="";
this->VHSigmaPath="";
this->VVSigmaPath = "";
this->OutEchoPath = "";
this->DEMTiffPath.clear();
this->LandCoverPath.clear();
this->HHSigmaPath.clear();
this->HVSigmaPath.clear();
this->VHSigmaPath.clear();
this->VVSigmaPath.clear();
this->OutEchoPath.clear();
this->SigmaDatabasePtr=std::shared_ptr<SigmaDatabase>(new SigmaDatabase);
}
RTPCProcessCls::~RTPCProcessCls()
{
}
void RTPCProcessCls::setTaskSetting(std::shared_ptr < AbstractSARSatelliteModel> TaskSetting)
{
this->TaskSetting= std::shared_ptr < AbstractSARSatelliteModel>(TaskSetting);
qDebug() << "RTPCProcessCls::setTaskSetting";
}
void RTPCProcessCls::setEchoSimulationDataSetting(std::shared_ptr<EchoL0Dataset> EchoSimulationData)
{
this->EchoSimulationData =std::shared_ptr<EchoL0Dataset> (EchoSimulationData);
qDebug() << "RTPCProcessCls::setEchoSimulationDataSetting";
}
void RTPCProcessCls::setTaskFileName(QString EchoFileName)
{
this->TaskFileName = EchoFileName;
}
void RTPCProcessCls::setDEMTiffPath(QString DEMTiffPath)
{
this->DEMTiffPath = DEMTiffPath;
}
void RTPCProcessCls::setLandCoverPath(QString LandCoverPath)
{
this->LandCoverPath = LandCoverPath;
}
void RTPCProcessCls::setHHSigmaPath(QString HHSigmaPath)
{
this->HHSigmaPath = HHSigmaPath;
}
void RTPCProcessCls::setHVSigmaPath(QString HVSigmaPath)
{
this->HVSigmaPath = HVSigmaPath;
}
void RTPCProcessCls::setVHSigmaPath(QString VHSigmaPath)
{
this->VHSigmaPath = VHSigmaPath;
}
void RTPCProcessCls::setVVSigmaPath(QString VVSigmaPath)
{
this->VVSigmaPath = VVSigmaPath;
}
void RTPCProcessCls::setOutEchoPath(QString OutEchoPath)
{
this->OutEchoPath = OutEchoPath;
}
ErrorCode RTPCProcessCls::Process(long num_thread)
{
// RTPC 算法
qDebug() << u8"params init ....";
ErrorCode stateCode = this->InitParams();
if (stateCode != ErrorCode::SUCCESS){
return stateCode;
}
else {}
qDebug() << "DEMMainProcess";
stateCode = this->DEMPreprocess();
if (stateCode != ErrorCode::SUCCESS) {
return stateCode;
}
else {}
qDebug() << "RTPCMainProcess";
stateCode = this->RTPCMainProcess(num_thread);
if (stateCode != ErrorCode::SUCCESS) {
return stateCode;
}else{}
return ErrorCode::SUCCESS;
}
ErrorCode RTPCProcessCls::InitParams()
{
if (nullptr==this->TaskSetting||this->DEMTiffPath.isEmpty() ||
this->LandCoverPath.isEmpty() || this->HHSigmaPath.isEmpty() ||
this->HVSigmaPath.isEmpty() || this->VHSigmaPath.isEmpty() ||
this->VVSigmaPath.isEmpty()) {
return ErrorCode::RTPC_PARAMSISEMPTY;
}
else {
}
// 归一化绝对路径
this->OutEchoPath = QDir(this->OutEchoPath).absolutePath();
// 回波大小
double imgStart_end = this->TaskSetting->getSARImageEndTime() - this->TaskSetting->getSARImageStartTime();
this->PluseCount = ceil(imgStart_end * this->TaskSetting->getPRF());
double rangeTimeSample = (this->TaskSetting->getFarRange() - this->TaskSetting->getNearRange()) * 2.0 / LIGHTSPEED;
this->PlusePoint = ceil(rangeTimeSample * this->TaskSetting->getFs());
// 初始化回波存放位置
qDebug() << "--------------Echo Data Setting ---------------------------------------";
this->EchoSimulationData=std::shared_ptr<EchoL0Dataset>(new EchoL0Dataset);
this->EchoSimulationData->setCenterFreq(this->TaskSetting->getCenterFreq());
this->EchoSimulationData->setNearRange(this->TaskSetting->getNearRange());
this->EchoSimulationData->setFarRange(this->TaskSetting->getFarRange());
this->EchoSimulationData->setFs(this->TaskSetting->getFs());
this->EchoSimulationData->setCenterAngle(this->TaskSetting->getCenterLookAngle());
this->EchoSimulationData->setLookSide(this->TaskSetting->getIsRightLook() ? "R" : "L");
this->EchoSimulationData->OpenOrNew(OutEchoPath, TaskFileName, PluseCount, PlusePoint);
QString tmpfolderPath = QDir(OutEchoPath).filePath("tmp");
if (QDir(tmpfolderPath).exists() == false) {
QDir(OutEchoPath).mkpath(tmpfolderPath);
}
this->tmpfolderPath = tmpfolderPath;
return ErrorCode::SUCCESS;
}
ErrorCode RTPCProcessCls::DEMPreprocess()
{
this->demxyzPath = QDir(tmpfolderPath).filePath("demxyz.tif");
gdalImage demds(this->DEMTiffPath);
gdalImage demxyz = CreategdalImage(demxyzPath, demds.height, demds.width, 3, demds.gt, demds.projection, true, true);// X,Y,Z
// 分块计算并转换为XYZ
Eigen::MatrixXd demArr = demds.getData(0, 0, demds.height, demds.width, 1);
Eigen::MatrixXd demR = demArr;
Landpoint LandP{ 0,0,0 };
Point3 GERpoint{ 0,0,0 };
double R = 0;
double dem_row = 0, dem_col = 0, dem_alt = 0;
long line_invert = 1000;
double rowidx = 0;
double colidx = 0;
for (int max_rows_ids = 0; max_rows_ids < demds.height; max_rows_ids = max_rows_ids + line_invert) {
Eigen::MatrixXd demdata = demds.getData(max_rows_ids, 0, line_invert, demds.width, 1);
Eigen::MatrixXd xyzdata_x = demdata.array() * 0;
Eigen::MatrixXd xyzdata_y = demdata.array() * 0;
Eigen::MatrixXd xyzdata_z = demdata.array() * 0;
int datarows = demdata.rows();
int datacols = demdata.cols();
for (int i = 0; i < datarows; i++) {
for (int j = 0; j < datacols; j++) {
rowidx = i + max_rows_ids;
colidx = j;
demds.getLandPoint(rowidx, colidx, demdata(i, j), LandP); // 获取地理坐标
LLA2XYZ(LandP, GERpoint); // 经纬度转换为地心坐标系
xyzdata_x(i, j) = GERpoint.x;
xyzdata_y(i, j) = GERpoint.y;
xyzdata_z(i, j) = GERpoint.z;
}
}
demxyz.saveImage(xyzdata_x, max_rows_ids, 0, 1);
demxyz.saveImage(xyzdata_y, max_rows_ids, 0, 2);
demxyz.saveImage(xyzdata_z, max_rows_ids, 0, 3);
}
// 计算坡向角
this->demsloperPath=QDir(tmpfolderPath).filePath("demsloper.tif");
this->demmaskPath = QDir(tmpfolderPath).filePath("demmask.tif");
gdalImage demsloperxyz = CreategdalImage(this->demsloperPath, demds.height, demds.width, 4, demds.gt, demds.projection, true, true);// X,Y,Z,cosangle
gdalImage demmask = CreategdalImage(this->demmaskPath, demxyz.height, demxyz.width, 1, demxyz.gt, demxyz.projection, true, true);// X,Y,Z
line_invert = 1000;
long start_ids = 0;
long dem_rows = 0, dem_cols = 0;
for (start_ids = 1; start_ids < demds.height; start_ids = start_ids + line_invert) {
Eigen::MatrixXd demdata = demds.getData(start_ids - 1, 0, line_invert + 2, demxyz.width, 1);
long startlineid = start_ids;
Eigen::MatrixXd maskdata = demmask.getData(start_ids - 1, 0, line_invert + 2, demxyz.width, 1);
Eigen::MatrixXd demsloper_x = demsloperxyz.getData(start_ids - 1, 0, line_invert + 2, demxyz.width, 1);
Eigen::MatrixXd demsloper_y = demsloperxyz.getData(start_ids - 1, 0, line_invert + 2, demxyz.width, 2);
Eigen::MatrixXd demsloper_z = demsloperxyz.getData(start_ids - 1, 0, line_invert + 2, demxyz.width, 3);
Eigen::MatrixXd demsloper_angle = demsloperxyz.getData(start_ids - 1, 0, line_invert + 2, demxyz.width, 4);
maskdata = maskdata.array() * 0;
Landpoint p0, p1, p2, p3, p4,pslopeVector,pp;
Vector3D slopeVector;
dem_rows = maskdata.rows();
dem_cols = maskdata.cols();
double sloperAngle = 0;
Vector3D Zaxis = { 0,0,1 };
double rowidx = 0, colidx = 0;
for (long i = 1; i < dem_rows - 1; i++) {
for (long j = 1; j < dem_cols - 1; j++) {
rowidx = i + startlineid;
colidx = j;
demds.getLandPoint(rowidx, colidx, demdata(i, j), p0);
demds.getLandPoint(rowidx-1, colidx, demdata(i-1, j), p1);
demds.getLandPoint(rowidx, colidx-1, demdata(i, j-1), p2);
demds.getLandPoint(rowidx+1, colidx, demdata(i+1, j), p3);
demds.getLandPoint(rowidx, colidx+1, demdata(i, j+1), p4);
pslopeVector = getSlopeVector(p0, p1, p2, p3, p4); // 地面坡向矢量
slopeVector = { pslopeVector.lon,pslopeVector.lat,pslopeVector.ati };
pp = LLA2XYZ(p0);
Zaxis.x = pp.lon;
Zaxis.y = pp.lat;
Zaxis.z = pp.ati;
sloperAngle = getCosAngle(slopeVector, Zaxis) ; // 地面坡向角
demsloper_x(i, j) = slopeVector.x;
demsloper_y(i, j) = slopeVector.y;
demsloper_z(i, j) = slopeVector.z;
demsloper_angle(i, j) = sloperAngle;
maskdata(i, j)++;
}
}
demmask.saveImage(maskdata, start_ids - 1, 0, 1);
demsloperxyz.saveImage(demsloper_x, start_ids - 1, 0, 1);
demsloperxyz.saveImage(demsloper_y, start_ids - 1, 0, 2);
demsloperxyz.saveImage(demsloper_z, start_ids - 1, 0, 3);
demsloperxyz.saveImage(demsloper_angle, start_ids - 1, 0, 4);
}
return ErrorCode::SUCCESS;
}
ErrorCode RTPCProcessCls::RTPCMainProcess(long num_thread)
{
omp_set_num_threads(num_thread);// 设置openmp 线程数量
double widthSpace = LIGHTSPEED/2/this->TaskSetting->getFs();
double prf_time = 0;
double dt = 1 / this->TaskSetting->getPRF();// 获取每次脉冲的时间间隔
bool antflag = true; // 计算天线方向图
Landpoint LandP{ 0,0,0 };
Point3 GERpoint{ 0,0,0 };
double R = 0;
double dem_row = 0 , dem_col=0, dem_alt=0;
long double imageStarttime = 0;
imageStarttime=this->TaskSetting->getSARImageStartTime();
//std::vector<SatelliteOribtNode> sateOirbtNodes(this->PluseCount);
std::shared_ptr<SatelliteOribtNode[]> sateOirbtNodes(new SatelliteOribtNode[this->PluseCount], delArrPtr);
{ // 姿态计算不同
// 计算姿态
std::shared_ptr<double> antpos = this->EchoSimulationData->getAntPos();
double dAt = 1e-6;
double prf_time_dt = 0;
Landpoint InP{0,0,0}, outP{0,0,0};
for (long prf_id = 0; prf_id < this->PluseCount; prf_id++) {
prf_time = dt * prf_id;
prf_time_dt = prf_time + dAt;
SatelliteOribtNode sateOirbtNode;
SatelliteOribtNode sateOirbtNode_dAt;
this->TaskSetting->getSatelliteOribtNode(prf_time, sateOirbtNode, antflag);
this->TaskSetting->getSatelliteOribtNode(prf_time_dt, sateOirbtNode_dAt, antflag);
sateOirbtNode.AVx = (sateOirbtNode_dAt.Vx - sateOirbtNode.Vx) / dAt; // 加速度
sateOirbtNode.AVy = (sateOirbtNode_dAt.Vy - sateOirbtNode.Vy) / dAt;
sateOirbtNode.AVz = (sateOirbtNode_dAt.Vz - sateOirbtNode.Vz) / dAt;
InP.lon = sateOirbtNode.Px;
InP.lat = sateOirbtNode.Py;
InP.ati = sateOirbtNode.Pz;
outP=XYZ2LLA(InP);
antpos.get()[prf_id * 16 + 0] = prf_time + imageStarttime;
antpos.get()[prf_id * 16 + 1] = sateOirbtNode.Px;
antpos.get()[prf_id * 16 + 2] = sateOirbtNode.Py;
antpos.get()[prf_id * 16 + 3] = sateOirbtNode.Pz;
antpos.get()[prf_id * 16 + 4] = sateOirbtNode.Vx;
antpos.get()[prf_id * 16 + 5] = sateOirbtNode.Vy;
antpos.get()[prf_id * 16 + 6] = sateOirbtNode.Vz;
antpos.get()[prf_id * 16 + 7] = sateOirbtNode.AntDirecX;
antpos.get()[prf_id * 16 + 8] = sateOirbtNode.AntDirecY;
antpos.get()[prf_id * 16 + 9] = sateOirbtNode.AntDirecZ;
antpos.get()[prf_id * 16 + 10] = sateOirbtNode.AVx;
antpos.get()[prf_id * 16 + 11] = sateOirbtNode.AVy;
antpos.get()[prf_id * 16 + 12] = sateOirbtNode.AVz;
antpos.get()[prf_id * 16 + 13] = outP.lon;
antpos.get()[prf_id * 16 + 14] = outP.lat;
antpos.get()[prf_id * 16 + 15] = outP.ati;
sateOirbtNodes[prf_id] = sateOirbtNode;
}
this->EchoSimulationData->saveAntPos(antpos);
antpos.reset();
qDebug() << "Ant position finished sucessfully !!!";
}
// 回波
long echoIdx = 0;
gdalImage demxyz (demxyzPath );// 地面点坐标
gdalImage demlandcls(this->LandCoverPath);// 地表覆盖类型
gdalImage demsloperxyz(this->demsloperPath);// 地面坡向
double NearRange = this->EchoSimulationData->getNearRange(); // 近斜据
double FarRange = this->EchoSimulationData->getFarRange();
double TimgNearRange = 2 * NearRange / LIGHTSPEED;
double TimgFarRange = 2 * FarRange / LIGHTSPEED;
double Fs = this->TaskSetting->getFs(); // 距离向采样率
double Pt = this->TaskSetting->getPt()*this->TaskSetting->getGri();// 发射电压 1v
//double GainAntLen = -3;// -3dB 为天线半径
long pluseCount = this->PluseCount;
// 天线方向图
std::shared_ptr<AbstractRadiationPattern> TransformPattern = this->TaskSetting->getTransformRadiationPattern(); // 发射天线方向图
std::shared_ptr< AbstractRadiationPattern> ReceivePattern = this->TaskSetting->getReceiveRadiationPattern(); // 接收天线方向图
std::shared_ptr<std::complex<double>> echo = this->EchoSimulationData->getEchoArr();
long PlusePoint = this->EchoSimulationData->getPlusePoints();
// 初始化 为 0
for (long i = 0; i < pluseCount * PlusePoint; i++) {
echo.get()[i] = std::complex<double>(0,0);
}
this->EchoSimulationData->saveEchoArr(echo, 0, PluseCount);
POLARTYPEENUM polartype = this->TaskSetting->getPolarType();
long demrowStep = std::ceil(Memory1MB*10 / 8 / demxyz.width) ;
long line_invert = demrowStep > 3 ? demrowStep : 3;
double lamda = this->TaskSetting->getCenterLamda(); // 波长
omp_lock_t lock; // 定义锁
omp_init_lock(&lock); // 初始化锁
// DEM计算
long start_ids = 1250;
for (start_ids = 1; start_ids < demxyz.height; start_ids = start_ids + line_invert) { // 8+ 17 + 0.3 MB
QDateTime current = QDateTime::currentDateTime();
long pluseStep = Memory1MB * 100 / 3 / PlusePoint;
if (pluseStep * num_thread *3 > this->PluseCount) {
pluseStep = this->PluseCount / num_thread /3;
}
pluseStep = pluseStep > 50 ? pluseStep : 50;
qDebug()<< current.toString("yyyy-MM-dd HH:mm:ss.zzz") <<" \tstart \t "<< start_ids << " - "<< start_ids + line_invert <<"\t" << demxyz.height<<"\t pluseCount:\t"<< pluseStep;
// 文件读取
Eigen::MatrixXd dem_x = demxyz.getData(start_ids - 1, 0, line_invert + 1, demxyz.width, 1); //
Eigen::MatrixXd dem_y = demxyz.getData(start_ids - 1, 0, line_invert + 1, demxyz.width, 2); //
Eigen::MatrixXd dem_z = demxyz.getData(start_ids - 1, 0, line_invert + 1, demxyz.width, 3); //
// 地表覆盖
std::shared_ptr<long> dem_landcls = readDataArr<long>(demlandcls, start_ids - 1, 0, line_invert + 1, demxyz.width, 1, GDALREADARRCOPYMETHOD::VARIABLEMETHOD); // 地表覆盖类型
long* dem_landcls_ptr = dem_landcls.get();
double localAngle = 30.0;
bool sigmaNoZeroFlag = true;
for (long ii = 0; ii < dem_x.rows(); ii++) {
for (long jj = 0; jj < dem_y.cols(); jj++) {
if (0 != this->SigmaDatabasePtr->getAmp(dem_landcls_ptr[dem_x.cols() * ii + jj], localAngle, polartype)) {
sigmaNoZeroFlag = false;
break;
}
}
if (!sigmaNoZeroFlag) {
break;
}
}
if (sigmaNoZeroFlag) {
continue;
}
//#ifdef DEBUGSHOWDIALOG
// dialog->load_double_MatrixX_data(dem_z, "dem_z");
//#endif
Eigen::MatrixXd demsloper_x = demsloperxyz.getData(start_ids - 1, 0, line_invert + 1, demxyz.width, 1); //
Eigen::MatrixXd demsloper_y = demsloperxyz.getData(start_ids - 1, 0, line_invert + 1, demxyz.width, 2); //
Eigen::MatrixXd demsloper_z = demsloperxyz.getData(start_ids - 1, 0, line_invert + 1, demxyz.width, 3); //
Eigen::MatrixXd sloperAngle = demsloperxyz.getData(start_ids - 1, 0, line_invert + 1, demxyz.width, 4); //
sloperAngle = sloperAngle.array() * T180_PI;
long dem_rows = dem_x.rows();
long dem_cols = dem_x.cols();
long freqidx = 0;//
#ifdef DEBUGSHOWDIALOG
ImageShowDialogClass* dialog = new ImageShowDialogClass(nullptr);
dialog->show();
Eigen::MatrixXd landaArr = Eigen::MatrixXd::Zero(dem_rows, dem_cols);
for (long i = 0; i < dem_rows; i++) {
for (long j = 0; j < dem_cols; j++) {
landaArr(i, j) = dem_landcls.get()[i * dem_cols + j];
}
}
dialog->load_double_MatrixX_data(landaArr, "landCover");
#endif
//qDebug() << " pluse bolck size :\t " << pluseStep << " all size:\t" << this->PluseCount;
#pragma omp parallel for
for (long startprfidx = 0; startprfidx < this->PluseCount; startprfidx=startprfidx+ pluseStep) { // 17 + 0.3 MB
long prfcount_step = startprfidx + pluseStep < this->PluseCount ? pluseStep : this->PluseCount- startprfidx;
Eigen::MatrixXcd echoPluse = Eigen::MatrixXcd::Zero(prfcount_step, PlusePoint); // 当前脉冲的回波积分情况
// 内存预分配
Eigen::MatrixXd Rst_x = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd Rst_y = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd Rst_z = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd R = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd localangle = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd Vst_x = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd Vst_y = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd Vst_z = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd fde = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd fr = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd Rx = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd sigam = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd echoAmp = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols()).array() + Pt;
Eigen::MatrixXd Rphi = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd TimeRange = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd TransAnt = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd ReciveAnt = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd AntTheta = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
Eigen::MatrixXd AntPhi = Eigen::MatrixXd::Zero(dem_x.rows(), dem_x.cols());
double minR = 0, maxR = 0;
double minLocalAngle = 0, maxLocalAngle = 0;
Vector3D Rt = { 0,0,0 };
SatelliteOribtNode oRs = SatelliteOribtNode{0};;
Vector3D p0 = {}, slopeVector = {}, sateAntDirect = {};
Vector3D Rs = {}, Vs = {}, Ast = {};
SatelliteAntDirect antdirectNode = {};
std::complex<double> echofreq;
std::complex<double> Imag1(0, 1);
double TAntPattern = 1; // 发射天线方向图
double RAntPanttern = 1;// 接收天线方向图
double maxechoAmp = 1;
double tempAmp = 1;
for (long prfidx = 0; prfidx < prfcount_step; prfidx++)
{
oRs = sateOirbtNodes[prfidx + startprfidx];
// 计算天线方向图
for (long jj = 1; jj < dem_cols - 1; jj++) {
for (long ii = 1; ii < dem_rows - 1; ii++) {
p0.x = dem_x(ii, jj);
p0.y = dem_y(ii, jj);
p0.z = dem_z(ii, jj);
this->TaskSetting->getSatelliteAntDirectNormal(oRs, p0, antdirectNode);
//antdirectNode.ThetaAnt = antdirectNode.ThetaAnt * r2d;
//antdirectNode.PhiAnt = antdirectNode.PhiAnt * r2d;
AntTheta(ii, jj) = antdirectNode.ThetaAnt * r2d;
AntPhi(ii, jj) = antdirectNode.PhiAnt * r2d;
}
}
// 计算发射天线方向图
for (long jj = 1; jj < dem_cols - 1; jj++) {
for (long ii = 1; ii < dem_rows - 1; ii++) {
TransformPattern->getGainLinear(AntTheta(ii, jj), AntPhi(ii, jj), TransAnt(ii, jj));
//TransAnt(ii, jj) = TAntPattern;
}
}
// 计算接收天线方向图
for (long jj = 1; jj < dem_cols - 1; jj++) {
for (long ii = 1; ii < dem_rows - 1; ii++) {
TransformPattern->getGainLinear(AntTheta(ii, jj), AntPhi(ii, jj), ReciveAnt(ii, jj));
//ReciveAnt(ii, jj) = RAntPanttern;
}
}
// 计算经过增益的能量
echoAmp = Pt * TransAnt.array() * ReciveAnt.array();
maxechoAmp = echoAmp.maxCoeff();
if (std::abs(maxechoAmp) < PRECISIONTOLERANCE) { // 这种情况下,不在合成孔径范围中
continue;
}
Rs.x = sateOirbtNodes[prfidx+startprfidx].Px; // 卫星位置
Rs.y = sateOirbtNodes[prfidx+startprfidx].Py;
Rs.z = sateOirbtNodes[prfidx+startprfidx].Pz;
Vs.x = sateOirbtNodes[prfidx+startprfidx].Vx; // 卫星速度
Vs.y = sateOirbtNodes[prfidx+startprfidx].Vy;
Vs.z = sateOirbtNodes[prfidx+startprfidx].Vz;
Ast.x = sateOirbtNodes[prfidx+startprfidx].AVx;// 卫星加速度
Ast.y = sateOirbtNodes[prfidx+startprfidx].AVy;
Ast.z = sateOirbtNodes[prfidx+startprfidx].AVz;
Rst_x = Rs.x - dem_x.array(); // Rst = Rs - Rt;
Rst_y = Rs.y - dem_y.array();
Rst_z = Rs.z - dem_z.array();
R = (Rst_x.array().pow(2) + Rst_y.array().pow(2) + Rst_z.array().pow(2)).array().sqrt(); // R
minR = R.minCoeff();
maxR = R.maxCoeff();
//qDebug() << "minR:\t" << minR << " maxR:\t" << maxR;
if (maxR<NearRange || minR>FarRange) {
continue;
}
else {}
// getCosAngle
// double c = dot(a, b) / (getlength(a) * getlength(b));
// return acos(c > 1 ? 1 : c < -1 ? -1 : c) * r2d;
// localangle = getCosAngle(Rst, slopeVector) * T180_PI; // 注意这个只能实时计算,因为非实时计算代价太大
localangle = (Rst_x.array() * demsloper_x.array() + Rst_y.array() * demsloper_y.array() + Rst_z.array() * demsloper_z.array()).array(); // dot(a, b)
localangle = localangle.array() / R.array();
localangle = localangle.array() / (demsloper_x.array().pow(2) + demsloper_y.array().pow(2) + demsloper_z.array().pow(2)).array().sqrt().array();
localangle = localangle.array().acos(); // 弧度值
minLocalAngle = localangle.minCoeff();
maxLocalAngle = localangle.maxCoeff();
if (maxLocalAngle<0 || minLocalAngle>PI/2) {
continue;
}
else {}
//Vst_x = Vs.x + 1 * earthRoute * dem_y.array(); // Vst = Vs - Vt;
//Vst_y = Vs.y - 1 * earthRoute * dem_x.array();
//Vst_z = Vs.z - Eigen::MatrixXd::Zero(dem_x.rows(), dem_y.cols()).array();
//// 计算多普勒中心频率 Rst, Vst : ( - 2 / lamda) * dot(Rs - Rt, Vs - Vt) / R; // 星载合成孔径雷达原始回波数据模拟研究 3.18
//fde = (-2 / lamda) * (Rst_x.array() * Vst_x.array() + Rst_y.array() * Vst_y.array() + Rst_z.array() * Vst_z.array()).array() / (R.array());
//// 计算多普勒频率斜率 // 星载合成孔径雷达原始回波数据模拟研究 3.19
//// -(2/lamda)*( dot(Vs - Vt, Vs - Vt)/R + dot(Ast, Rs - Rt)/R - std::pow(dot(Vs - Vt, Rs - Rt),2 )/std::pow(R,3));
//fr = (-2 / lamda) *
// (Vst_x.array() * Vst_x.array() + Vst_y.array() * Vst_y.array() + Vst_z.array() * Vst_z.array()).array() / (R.array()) +
// (-2 / lamda) *
// (Ast.x * Rst_x.array() + Ast.y * Rst_y.array() + Ast.z * Rst_z.array()).array() / (R.array()) -
// (-2 / lamda) *
// (Vst_x.array() * Rst_x.array() + Vst_y.array() * Rst_y.array() + Vst_z.array() * Rst_z.array()).array().pow(2) / (R.array().pow(3));
// 计算回波
Rx = R;// -(lamda / 2) * (fde * TRx + 0.5 * fr * TRx * TRx); // 斜距历程值
// 逐点计算 this->SigmaDatabasePtr->getAmp(covercls, localangle, polartype); // 后向散射系数 HH
for (long ii = 0; ii < dem_x.rows(); ii++) {
for (long jj = 0; jj < dem_y.cols(); jj++) {
sigam(ii, jj) = this->SigmaDatabasePtr->getAmp(dem_landcls_ptr[dem_x.cols() * ii + jj], localangle(ii, jj)*r2d, polartype);
}
}
if (sigam.maxCoeff() > 0) {}
else {
continue;
}
// projArea = 1 / std::cos(sloperAngle) * std::sin(localangle); // 投影面积系数,单位投影面积 1m x 1m --注意这里是假设,后期再补充
// echoAmp = projArea*TAntPattern * RAntPanttern * sigam / (4 * PI * R * R);
echoAmp = echoAmp.array()*sigam.array() * (1 / sloperAngle.array().cos() * localangle.array().sin()); // 反射强度
echoAmp = echoAmp.array() / (4 * PI * R.array().pow(2)); // 距离衰减
Rphi = -4 * PI / lamda * Rx.array();// 距离徙动相位
// 积分
TimeRange = ((2 * R.array() / LIGHTSPEED - TimgNearRange).array() * Fs).array();
double localAnglepoint = -1;
long prf_freq_id = 0;
for (long jj = 1; jj < dem_cols - 1; jj++) {
for (long ii = 1; ii < dem_rows - 1; ii++) {
prf_freq_id =std::floor(TimeRange(ii, jj));
if (prf_freq_id < 0 || prf_freq_id >= PlusePoint|| localangle(ii, jj) <0 || localangle(ii, jj) >PI / 2|| echoAmp(ii, jj)==0) {
continue;
}
echofreq = echoAmp(ii, jj) * std::exp( Rphi(ii, jj)* Imag1);
echoPluse(prfidx, prf_freq_id) = echoPluse(prfidx, prf_freq_id) + echofreq;
}
}
#ifdef DEBUGSHOWDIALOG
ImageShowDialogClass* localangledialog = new ImageShowDialogClass(dialog);
localangledialog->show();
localangledialog->load_double_MatrixX_data(localangle.array()*r2d, "localangle");
ImageShowDialogClass* sigamdialog = new ImageShowDialogClass(dialog);
sigamdialog->show();
sigamdialog->load_double_MatrixX_data(TimeRange, "TimeRange");
ImageShowDialogClass* ampdialog = new ImageShowDialogClass(dialog);
ampdialog->show();
ampdialog->load_double_MatrixX_data(echoAmp, "echoAmp");
Eigen::MatrixXd echoPluseamp = echoPluse.array().abs().cast<double>().array();
ImageShowDialogClass* echoampdialog = new ImageShowDialogClass(dialog);
echoampdialog->show();
echoampdialog->load_double_MatrixX_data(echoPluseamp, "echoPluseamp");
dialog->exec();
#endif
//qDebug() << QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz") << " end " << prfidx;
}
//qDebug() << QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz")<<" step "<< prfcount_step;
omp_set_lock(&lock); // 回波整体赋值处理
for (long prfidx = 0; prfidx < prfcount_step; prfidx++) {
for (long freqidx = 0; freqidx < PlusePoint; freqidx++)
{
//qDebug() << prfidx << " " << freqidx << " " << echoPluse(prfidx, freqidx).real() << " + " << echoPluse(prfidx, freqidx).imag() << " j";
echo.get()[(prfidx + startprfidx) * PlusePoint + freqidx] = echo.get()[(prfidx + startprfidx) * PlusePoint + freqidx] + echoPluse(prfidx, freqidx);
}
}
//this->EchoSimulationData->saveEchoArr(echo, 0, PluseCount);
omp_unset_lock(&lock); // 解锁
//qDebug() << QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz") << " step 2" << prfcount_step;
}
omp_set_lock(&lock); // 保存文件
this->EchoSimulationData->saveEchoArr(echo ,0, PluseCount);
omp_unset_lock(&lock); // 解锁
qDebug() << QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz") << " \t " << start_ids << "\t--\t " << start_ids + line_invert<<"\t/\t" << demxyz.height;
}
omp_destroy_lock(&lock); // 销毁锁
this->EchoSimulationData->saveEchoArr(echo, 0, PluseCount);
return ErrorCode::SUCCESS;
}
void RTPCProcessMain(long num_thread,QString TansformPatternFilePath, QString ReceivePatternFilePath, QString simulationtaskName,QString OutEchoPath,QString GPSXmlPath, QString TaskXmlPath, QString demTiffPath , QString LandCoverPath , QString HHSigmaPath , QString HVSigmaPath , QString VHSigmaPath , QString VVSigmaPath)
{
std::vector<RadiationPatternGainPoint> TansformPatternGainpoints = ReadGainFile(TansformPatternFilePath);
std::shared_ptr<AbstractRadiationPattern> TansformPatternGainPtr = CreateAbstractRadiationPattern(TansformPatternGainpoints);
std::vector<RadiationPatternGainPoint> ReceivePatternGainpoints = ReadGainFile(ReceivePatternFilePath);
std::shared_ptr<AbstractRadiationPattern> ReceivePatternGainPtr = CreateAbstractRadiationPattern(ReceivePatternGainpoints);
std::shared_ptr < AbstractSARSatelliteModel> task = ReadSimulationSettingsXML(TaskXmlPath);
if (nullptr == task)
{
return;
}
else {
// 打印参数
qDebug() << "--------------Task Seting ---------------------------------------";
qDebug() << "SARImageStartTime: " << task->getSARImageStartTime() ;
qDebug() << "SARImageEndTime: " << task->getSARImageEndTime() ;
qDebug() << "BandWidth: " << task->getBandWidth();
qDebug() << "CenterFreq: " << task->getCenterFreq();
qDebug() << "PRF: " << task->getPRF();
qDebug() << "Fs: " << task->getFs();
qDebug() << "POLAR: " << task->getPolarType();
qDebug() << "NearRange: " << task->getNearRange();
qDebug() << "FarRange: " << task->getFarRange();
qDebug() << (task->getFarRange() - task->getNearRange()) * 2 / LIGHTSPEED * task->getFs();
qDebug() << "\n\n";
}
// 1.2 设置天线方向图
task->setTransformRadiationPattern(TansformPatternGainPtr);
task->setReceiveRadiationPattern(ReceivePatternGainPtr);
//2. 读取GPS节点
std::vector<SatelliteOribtNode> nodes;
ErrorCode stateCode = ReadSateGPSPointsXML(GPSXmlPath, nodes);
if (stateCode != ErrorCode::SUCCESS)
{
qWarning() << QString::fromStdString(errorCode2errInfo(stateCode));
return;
}
else {}
std::shared_ptr<AbstractSatelliteOribtModel> SatelliteOribtModel = CreataPolyfitSatelliteOribtModel(nodes,task->getSARImageStartTime(),3); // 以成像开始时间作为 时间参考起点
SatelliteOribtModel->setbeamAngle(task->getCenterLookAngle(), task->getIsRightLook()); // 设置天线方向图
if (nullptr == SatelliteOribtModel)
{
return;
}
else {
task->setSatelliteOribtModel(SatelliteOribtModel);
}
qDebug() << "-------------- RTPC init ---------------------------------------";
RTPCProcessCls rtpc;
rtpc.setTaskSetting(task); //qDebug() << "setTaskSetting";
rtpc.setTaskFileName(simulationtaskName); //qDebug() << "setTaskFileName";
rtpc.setDEMTiffPath(demTiffPath); //qDebug() << "setDEMTiffPath";
rtpc.setLandCoverPath( LandCoverPath); //qDebug() << "setLandCoverPath";
rtpc.setHHSigmaPath( HHSigmaPath ); //qDebug() << "setHHSigmaPath";
rtpc.setHVSigmaPath( HVSigmaPath ); //qDebug() << "setHVSigmaPath";
rtpc.setVHSigmaPath( VHSigmaPath ); //qDebug() << "setVHSigmaPath";
rtpc.setVVSigmaPath( VVSigmaPath ); //qDebug() << "setVVSigmaPath";
rtpc.setOutEchoPath(OutEchoPath); //qDebug() << "setOutEchoPath";
qDebug() << "-------------- RTPC start---------------------------------------";
rtpc.Process(num_thread); // 处理程序
qDebug() << "-------------- RTPC end---------------------------------------";
}

View File

@ -0,0 +1,83 @@
#pragma once
/*****************************************************************//**
* \file RTPCProcessCls.h
* \brief Range Time domain Pulse Coherent
*
*
* cumming ,
* Mark A.Richards,
*
* InSAR
* SAR仿
*
* SAR仿
*
*
*
*
* \author
* \date October 2024
*********************************************************************/
#include "BaseConstVariable.h"
#include "SARSatelliteSimulationAbstractCls.h"
#include "SARSimulationTaskSetting.h"
#include "SatelliteOribtModel.h"
#include "EchoDataFormat.h"
#include "SigmaDatabase.h"
class RTPCProcessCls
{
public:
RTPCProcessCls();
~RTPCProcessCls();
public:
void setTaskSetting(std::shared_ptr < AbstractSARSatelliteModel> TaskSetting);
void setEchoSimulationDataSetting(std::shared_ptr < EchoL0Dataset> EchoSimulationData);
void setTaskFileName(QString EchoFileName);
void setDEMTiffPath(QString DEMTiffPath);
void setLandCoverPath(QString LandCoverPath);
void setHHSigmaPath(QString HHSigmaPath);
void setHVSigmaPath(QString HVSigmaPath);
void setVHSigmaPath(QString VHSigmaPath);
void setVVSigmaPath(QString VVSigmaPath);
void setOutEchoPath(QString OutEchoPath);
private:
std::shared_ptr <AbstractSARSatelliteModel> TaskSetting; // 仿真任务设置
std::shared_ptr <EchoL0Dataset> EchoSimulationData; // GPS数据
std::shared_ptr<SigmaDatabase> SigmaDatabasePtr;
long PluseCount; // 脉冲数量
long PlusePoint; // 脉冲点数
QString DEMTiffPath; // DEM Tiff 文件路径
QString LandCoverPath;
QString HHSigmaPath;
QString HVSigmaPath;
QString VHSigmaPath;
QString VVSigmaPath;
QString OutEchoPath; // 输出回波路径
QString TaskFileName;
QString tmpfolderPath;
public:
ErrorCode Process(long num_thread); // 处理
private: // 处理流程
ErrorCode InitParams();// 1. 初始化参数
ErrorCode DEMPreprocess(); // 2. 裁剪DEM范围
ErrorCode RTPCMainProcess(long num_thread);
private:
QString demxyzPath;
QString demmaskPath;
QString demsloperPath;
};
void RTPCProcessMain(long num_thread,QString TansformPatternFilePath,QString ReceivePatternFilePath,QString simulationtaskName, QString OutEchoPath, QString GPSXmlPath,QString TaskXmlPath,QString demTiffPath, QString LandCoverPath, QString HHSigmaPath, QString HVSigmaPath, QString VHSigmaPath, QString VVSigmaPath);

View File

@ -0,0 +1,776 @@
#include "stdafx.h"
#include "SARSatelliteSimulationAbstractCls.h"
#include <Eigen/Core>
#include <Eigen/Dense>
#include <QDebug>
#include <QFile>
#include <QDomDocument>
#include <QDateTime>
#include <QString>
#include "BaseTool.h"
#include <QCoreApplication>
#include <QFile>
#include <QTextStream>
#include <QStringList>
#include <QDebug>
#include <vector>
#include <unordered_map>
AbstractSatelliteOribtModel::~AbstractSatelliteOribtModel()
{
}
SatelliteOribtNode AbstractSatelliteOribtModel::getSatelliteOribtNode(double& timeFromStartTime, bool& antAzAngleFlag)
{
return SatelliteOribtNode();
}
ErrorCode AbstractSatelliteOribtModel::getSatelliteOribtNode(double& timeFromStartTime, SatelliteOribtNode& node, bool& antAzAngleFlag)
{
return ErrorCode::VIRTUALABSTRACT;
}
ErrorCode AbstractSatelliteOribtModel::getSatelliteAntDirectNormal(SatelliteOribtNode& Rs, Vector3D& Rt, SatelliteAntDirect& antNode)
{
return ErrorCode();
}
void AbstractSatelliteOribtModel::setSatelliteOribtStartTime(long double oribtRefrenceTime)
{
}
long double AbstractSatelliteOribtModel::getSatelliteOribtStartTime()
{
return 0;
}
void AbstractSatelliteOribtModel::setbeamAngle(double beamAngle, bool RightLook)
{
}
void AbstractSatelliteOribtModel::setAzAngleRange(double cycletime, double minAzAngle, double maxAzAngle, double referenceAzAngle, double referenceTimeFromStartTime)
{
}
double AbstractSatelliteOribtModel::getAzAngleInCurrentTimeFromStartTime(double& currentTime)
{
return 0.0;
}
ErrorCode AbstractSatelliteOribtModel::getAzAngleInCurrentTimeFromStartTime(double& currentTime, double& AzAngle)
{
return ErrorCode::VIRTUALABSTRACT;
}
void AbstractSatelliteOribtModel::setAntnnaAxisX(double X, double Y, double Z)
{
}
void AbstractSatelliteOribtModel::setAntnnaAxisY(double X, double Y, double Z)
{
}
void AbstractSatelliteOribtModel::setAntnnaAxisZ(double X, double Y, double Z)
{
}
ErrorCode AbstractSatelliteOribtModel::getAntnnaDirection(SatelliteOribtNode& node)
{
return ErrorCode::VIRTUALABSTRACT;
}
double AbstractSatelliteOribtModel::getPt()
{
return 0.0;
}
double AbstractSatelliteOribtModel::getGri()
{
return 0.0;
}
void AbstractSatelliteOribtModel::setPt(double Pt)
{
}
void AbstractSatelliteOribtModel::setGri(double gri)
{
}
SatelliteOribtNode AbstractSARSatelliteModel::getSatelliteOribtNode(double& timeFromStartTime, bool& antAzAngleFlag)
{
return SatelliteOribtNode();
}
ErrorCode AbstractSARSatelliteModel::getSatelliteOribtNode(double& timeFromStartTime, SatelliteOribtNode& node, bool& antAzAngleFlag)
{
return ErrorCode();
}
ErrorCode AbstractSARSatelliteModel::getSatelliteAntDirectNormal(SatelliteOribtNode& Rs, Vector3D& Rt, SatelliteAntDirect& antNode)
{
return ErrorCode();
}
void AbstractSARSatelliteModel::setSatelliteOribtModel(std::shared_ptr<AbstractSatelliteOribtModel> model)
{
}
void AbstractSARSatelliteModel::setSARImageStartTime(long double imageStartTime)
{
}
void AbstractSARSatelliteModel::setSARImageEndTime(long double imageEndTime)
{
}
double AbstractSARSatelliteModel::getSARImageStartTime()
{
return 0;
}
double AbstractSARSatelliteModel::getSARImageEndTime()
{
return 0;
}
double AbstractSARSatelliteModel::getNearRange()
{
return 0.0;
}
void AbstractSARSatelliteModel::setNearRange(double NearRange)
{
}
double AbstractSARSatelliteModel::getFarRange()
{
return 0.0;
}
void AbstractSARSatelliteModel::setFarRange(double FarRange)
{
}
bool AbstractSARSatelliteModel::getIsRightLook()
{
return false;
}
void AbstractSARSatelliteModel::setIsRightLook(bool isR)
{
}
void AbstractSARSatelliteModel::setCenterFreq(double Freq)
{
}
double AbstractSARSatelliteModel::getCenterFreq()
{
return 0.0;
}
void AbstractSARSatelliteModel::setCenterLamda(double Lamda)
{
}
double AbstractSARSatelliteModel::getCenterLamda()
{
return 0.0;
}
void AbstractSARSatelliteModel::setBandWidth(double bandwidth)
{
}
double AbstractSARSatelliteModel::getBandWidth()
{
return 0.0;
}
POLARTYPEENUM AbstractSARSatelliteModel::getPolarType()
{
return POLARTYPEENUM();
}
void AbstractSARSatelliteModel::setPolarType(POLARTYPEENUM type)
{
}
void AbstractSARSatelliteModel::setPRF(double prf)
{
}
double AbstractSARSatelliteModel::getPRF()
{
return 0;
}
double AbstractSARSatelliteModel::getFs()
{
return 0;
}
void AbstractSARSatelliteModel::setFs(double Fs)
{
}
double AbstractSARSatelliteModel::getCenterLookAngle()
{
return 0.0;
}
void AbstractSARSatelliteModel::setCenterLookAngle(double angle)
{
}
void AbstractSARSatelliteModel::setTransformRadiationPattern(std::shared_ptr<AbstractRadiationPattern> radiationPanttern)
{
}
void AbstractSARSatelliteModel::setReceiveRadiationPattern(std::shared_ptr<AbstractRadiationPattern> radiationPanttern)
{
}
std::shared_ptr<AbstractRadiationPattern> AbstractSARSatelliteModel::getTransformRadiationPattern()
{
return std::shared_ptr<AbstractRadiationPattern>();
}
std::shared_ptr<AbstractRadiationPattern> AbstractSARSatelliteModel::getReceiveRadiationPattern()
{
return std::shared_ptr<AbstractRadiationPattern>();
}
double AbstractSARSatelliteModel::getPt()
{
return 0.0;
}
double AbstractSARSatelliteModel::getGri()
{
return 0.0;
}
void AbstractSARSatelliteModel::setPt(double Pt)
{
}
void AbstractSARSatelliteModel::setGri(double gri)
{
}
ErrorCode ReadSateGPSPointsXML(QString xmlPath, std::vector<SatelliteOribtNode>& nodes)
{
// 读取文件
QFile file(xmlPath);
if (!file.open(QIODevice::ReadOnly)) {
qDebug() << "Cannot open file for reading.";
return ErrorCode::FILEOPENFAIL;
}
QDomDocument doc;
if (!doc.setContent(&file)) {
qDebug() << "Failed to parse the XML.";
file.close();
return ErrorCode::XMLPARSEFAIL;
}
file.close();
QDomElement root = doc.documentElement();
QDomNodeList gpsParamList = root.firstChildElement("GPS").elementsByTagName("GPSParam");
nodes.clear();
for (int i = 0; i < gpsParamList.size(); ++i) {
QDomElement gpsParam = gpsParamList.at(i).toElement();
QDomElement timeStampElement = gpsParam.firstChildElement("TimeStamp");
QDomElement xPositionElement = gpsParam.firstChildElement("xPosition");
QDomElement yPositionElement = gpsParam.firstChildElement("yPosition");
QDomElement zPositionElement = gpsParam.firstChildElement("zPosition");
QDomElement xVelocityElement = gpsParam.firstChildElement("xVelocity");
QDomElement yVelocityElement = gpsParam.firstChildElement("yVelocity");
QDomElement zVelocityElement = gpsParam.firstChildElement("zVelocity");
if (timeStampElement.isNull() ||
xPositionElement.isNull() || yPositionElement.isNull() || zPositionElement.isNull() ||
xVelocityElement.isNull() ||yVelocityElement.isNull() ||zVelocityElement.isNull()) {
nodes.clear();
return ErrorCode::XMLNOTFOUNDElEMENT;
}
QString timeStamp = timeStampElement.text();
QString xPosition = xPositionElement.text();
QString yPosition = yPositionElement.text();
QString zPosition = zPositionElement.text();
QString xVelocity = xVelocityElement.text();
QString yVelocity = yVelocityElement.text();
QString zVelocity = zVelocityElement.text();
// 转换
long double timestamp = convertToMilliseconds(timeStamp.toStdString());
SatelliteOribtNode node;
node.time = timestamp;
node.Px = xPosition.toDouble();
node.Py = yPosition.toDouble();
node.Pz = zPosition.toDouble();
node.Vx = xVelocity.toDouble();
node.Vy = yVelocity.toDouble();
node.Vz = zVelocity.toDouble();
nodes.push_back(node);
}
qDebug() << "--- GPS Node Extracted -----------------------------------------------------------";
qDebug() << "time\tPx\tPy\tPz\tVx\tVy\tVz";
for (int i = 0; i < nodes.size(); ++i) {
SatelliteOribtNode node= nodes[i];
// 打印解译结果
qDebug() << (double)node.time << "\t" << node.Px << "\t" << node.Py << "\t" << node.Pz << "\t" << node.Vx << "\t" << node.Vy << "\t" << node.Vz;
}
qDebug() << "\n\n\n";
return ErrorCode::SUCCESS;
}
std::vector<SatelliteOribtNode> FilterSatelliteOribtNode(std::vector<SatelliteOribtNode>& nodes, double startTime, double endTime, long minCount)
{
if (minCount < nodes.size()) {
return std::vector<SatelliteOribtNode>(0);
}
else {}
std::vector<double> dtime(nodes.size());
double centerTime = startTime + (endTime-startTime) / 2.0;
// 排序 小 --> 大
std::sort(nodes.begin(), nodes.end(), [](SatelliteOribtNode& a, SatelliteOribtNode& b) {
return a.time < b.time;
});
// 计算插值
for (long i = 0; i < nodes.size(); i++) {
dtime[i] =std::abs(nodes[i].time - centerTime);
}
// find min value idx
long minIdx = 0;
double min = dtime[0];
for (long i = 1; i < nodes.size(); i++) {
if (dtime[i] < min) {
min = (dtime[i]);
minIdx = i;
}
else {}
}
std::vector<SatelliteOribtNode> result(0);
// 左右查找
long left = minIdx;
long right = minIdx+1;
while (left >= 0 || right < nodes.size()) {
// 左右检索
if (left >= 0) {
result.push_back(nodes[left]);
}
else {}
left--;
if (right < nodes.size()) {
result.push_back(nodes[right]);
}
else {}
right++;
if (result.size() > minCount) {
break;
}
}
return result;
}
std::shared_ptr<AbstractRadiationPattern> CreateAbstractRadiationPattern(std::vector<RadiationPatternGainPoint> antPatternPoints)
{
std::shared_ptr<AbstractRadiationPattern> pattern = std::make_shared<AbstractRadiationPattern>();
for (long i = 0; i < antPatternPoints.size(); i++) {
RadiationPatternGainPoint point = antPatternPoints[i];
pattern->setGain(point.theta, point.phi, point.GainValue);
}
pattern->RecontructGainMatrix();
return pattern;
}
std::vector<RadiationPatternGainPoint> ReadGainFile(QString antPatternFilePath)
{
std::vector<RadiationPatternGainPoint> dataPoints(0);
QFile file(antPatternFilePath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "Failed to open the file.";
return dataPoints; // 返回空向量
}
QTextStream in(&file);
QStringList headers = in.readLine().split(","); // 读取标题行
qDebug() << "Headers:" << headers;
if (headers.count() < 3) {
file.close();
return dataPoints;
}
qDebug() << "parase ant radiation pattern contains ";
long theta_id = -1;
long phi_id = -1;
long gain_id = -1;
for (long i = 0; i < headers.size(); i++) {
if (headers[i].toLower().contains("theta")) {
theta_id = i;
}
else if (headers[i].toLower().contains("phi")) {
phi_id = i;
}
else if (headers[i].toLower().contains("gain")) {
gain_id = i;
}
}
if (theta_id == -1 || phi_id == -1 || gain_id == -1) {
qDebug() << "Failed to find the field.";
file.close();
return dataPoints; // 返回空向量
}
QString line = "";
do{
QString line = in.readLine();
if (line.isNull()) {
break;
}
if (line.isEmpty()) {
continue;
}
QStringList fields = line.split(",");
if (fields.size() >=3) {
if (fields[0].isEmpty()) {
continue;
}
RadiationPatternGainPoint point{0,0,0};
bool thetaflag = false;
bool phiflag = false;
bool gainflag = false;
point.theta = fields[theta_id].toDouble(&thetaflag); // 这里存在风险,如果数据不是数字,会导致程序崩溃
point.phi = fields[phi_id].toDouble(&phiflag);
point.GainValue = fields[gain_id].toDouble(&gainflag);
if (!(thetaflag && phiflag && gainflag)) {
file.close();
return std::vector< RadiationPatternGainPoint>(0);
}
// 角度转换为 -180 ~ 180
point.theta = point.theta > 180 ? point.theta - 360 : point.theta;
point.phi = point.phi > 180 ? point.phi - 360 : point.phi;
dataPoints.push_back(point);
}
else {}
} while (!line.isNull());
qDebug() << "over";
file.close();
return dataPoints;
}
double getDopplerCenterFreq(double& lamda, double& R, Vector3D& Rs, Vector3D& Rt, Vector3D& Vs, Vector3D& Vt)
{
return ( - 2 / lamda) * dot(Rs - Rt, Vs - Vt) / R; // 星载合成孔径雷达原始回波数据模拟研究 3.18
}
double getDopplerFreqRate(double& lamda, double& R, Vector3D& Rs, Vector3D& Rt, Vector3D& Vs, Vector3D& Vt, Vector3D& Ast)
{
return -(2/lamda)*(dot(Vs - Vt, Vs - Vt)/R+ dot(Ast, Rs - Rt) /R- std::pow(dot(Vs - Vt, Rs - Rt),2 )/std::pow(R,3));// 星载合成孔径雷达原始回波数据模拟研究 3.19
}
AbstractRadiationPattern::AbstractRadiationPattern()
{
this->GainMap = std::vector<RadiationPatternGainPoint>(0);
this->thetas = std::vector<double>(0);
this->phis = std::vector<double>(0);
this->GainMatrix = Eigen::MatrixXd(0, 0);
}
AbstractRadiationPattern::~AbstractRadiationPattern()
{
}
double AbstractRadiationPattern::getGain(double& theta, double& phi )
{
double gainValue = 0;
ErrorCode state = getGain(theta, phi, gainValue);
return gainValue;
}
std::vector<RadiationPatternGainPoint> AbstractRadiationPattern::getGainList()
{
return this->GainMap;
}
ErrorCode AbstractRadiationPattern::getGain(double& theta, double& phi, double& GainValue)
{
if (this->mintheta > theta || this->maxtheta<theta || this->minphi>phi || this->maxphi < phi) {
GainValue = 0;
return ErrorCode::OUTOFRANGE;
}
if (theta>=0&&std::sin(theta * d2r)*std::cos(phi*d2r) > this->EdgeXMax) { // 越界
GainValue = 0;
return ErrorCode::OUTOFRANGE;
}
if (theta < 0 && -1*std::sin(theta * d2r) * std::cos(phi * d2r) < this->EdgeXMin) {
GainValue = 0;
return ErrorCode::OUTOFRANGE;
}
// 插值计算增益
if (this->GainMap.size() == 0) { // 原始增益
GainValue = 1;
}
else {
// --双线性插值
if (this->GainMatrix.rows() != this->phis.size() || this->GainMatrix.cols() != this->thetas.size()) {
this->RecontructGainMatrix();
}
// 考虑根据双线性采样方法
long lasttheta = FindValueInStdVectorLast(this->thetas,theta);
long nextTheta = lasttheta+1;
long lastphi = FindValueInStdVectorLast(this->phis, phi);;
long nextPhi = lastphi+1;
if (lasttheta == -1 || nextTheta == -1 || lastphi == -1 || nextPhi == -1) {
return ErrorCode::FIND_ID_ERROR;
}
double x1 = this->thetas[lasttheta];
double x2 = this->thetas[nextTheta];
double y1 = this->phis[lastphi];
double y2 = this->phis[nextPhi];
//double z11 = this->GainMatrix(lasttheta, lastphi);//std::pow(10,this->GainMatrix(lasttheta, lastphi)/10);
//double z12 = this->GainMatrix(lasttheta, nextPhi);//std::pow(10,this->GainMatrix(lasttheta, nextPhi)/10);
//double z21 = this->GainMatrix(nextTheta, lastphi);//std::pow(10,this->GainMatrix(nextTheta, lastphi)/10);
//double z22 = this->GainMatrix(nextTheta, nextPhi);//std::pow(10,this->GainMatrix(nextTheta, nextPhi)/10);
double z11 = std::pow(10,this->GainMatrix(lasttheta, lastphi)/10);
double z12 = std::pow(10,this->GainMatrix(lasttheta, nextPhi)/10);
double z21 = std::pow(10,this->GainMatrix(nextTheta, lastphi)/10);
double z22 = std::pow(10,this->GainMatrix(nextTheta, nextPhi)/10);
double x = theta;
double y = phi;
GainValue = (z11 * (x2 - x) * (y2 - y)
+ z21 * (x - x1) * (y2 - y)
+ z12 * (x2 - x) * (y - y1)
+ z22 * (x - x1) * (y - y1));
GainValue = GainValue / ((x2 - x1) * (y2 - y1));
GainValue = 10.0 * std::log10(GainValue); // 返回dB
//qDebug() << "GainValue:" << GainValue << " " << lasttheta << " " << nextTheta << " " << lastphi << " " << nextPhi << " " << z11 << " " << z12 << " " << z21 << " " << z22;
ErrorCode::SUCCESS;
}
return ErrorCode::SUCCESS;
}
ErrorCode AbstractRadiationPattern::getGainLinear(double& theta, double& phi, double& GainValue)
{
ErrorCode statecode=this->getGain(theta, phi, GainValue);
if (statecode == ErrorCode::OUTOFRANGE) {
GainValue = 0;
return ErrorCode::SUCCESS;
}
else {
return statecode;
}
}
ErrorCode AbstractRadiationPattern::setGain(double& theta, double& phi, double& GainValue)
{
this->GainMap.push_back(RadiationPatternGainPoint{ theta,phi,GainValue });
return ErrorCode::SUCCESS;
}
ErrorCode AbstractRadiationPattern::RecontructGainMatrix(double threshold )
{
this->thetas.clear();
this->phis.clear();
for(long i=0;i<this->GainMap.size();i++){
double thetatempp = this->GainMap[i].theta;
double phitempp = this->GainMap[i].phi;
InsertValueInStdVector(this->thetas, this->GainMap[i].theta, false);
InsertValueInStdVector(this->phis, this->GainMap[i].phi, false);
}
this->GainMatrix = Eigen::MatrixXd::Zero(this->phis.size(), this->thetas.size());
for (long i = 0; i < this->GainMap.size(); i++) {
long theta_idx = FindValueInStdVector(this->thetas, this->GainMap[i].theta);
long phi_idx = FindValueInStdVector(this->phis, this->GainMap[i].phi);
if (theta_idx == -1 || phi_idx == -1) {
qDebug() << "Error: RecontructGainMatrix failed";
return ErrorCode::FIND_ID_ERROR;
}
this->GainMatrix(theta_idx, phi_idx) = this->GainMap[i].GainValue;
}
// double mintheta, maxtheta, minphi, maxphi;
this->mintheta = this->thetas[0];
this->maxtheta = this->thetas[this->thetas.size() - 1];
this->minphi = this->phis[0];
this->maxphi = this->phis[this->phis.size() - 1];
this->maxGain = this->GainMatrix.maxCoeff();// 最大增益
{
this->EdgethetaMin = -90;
this->EdgethetaMax = 90;
this->EdgeXMax = 1;
this->EdgeXMin = -1;
}
{
double phi = 0;
double theta = 0;
double dt = 1e-6;
double maxphiGain = 0;
this->getGain(theta, phi, maxphiGain);
double gain_tmep = maxphiGain;
while (theta <= 90) {
this->getGain(theta, phi, gain_tmep);
if (gain_tmep > maxphiGain) {
maxphiGain = gain_tmep;
}
theta = theta + dt;
}
while (theta >=- 90) {
gain_tmep = this->getGain(theta, phi);
if (gain_tmep > maxphiGain) {
maxphiGain = gain_tmep;
}
theta = theta - dt;
}
this->maxPhiGain = maxphiGain;
qDebug() << "phi=0 Gain : \t" << maxphiGain << " -- " << theta << " -- " << phi;
}
{
double phi = 90;
double theta = 0;
double dt = 1;
double maxphiGain = 0;
this->getGain(theta, phi, maxphiGain);
double gain_tmep = maxphiGain;
while (theta <= 90) {
this->getGain(theta, phi, gain_tmep);
if (gain_tmep > maxphiGain) {
maxphiGain = gain_tmep;
}
else {}
theta = theta + dt;
}
theta = 0;
while (theta >= -90) {
gain_tmep = this->getGain(theta, phi);
if (gain_tmep > maxphiGain) {
maxphiGain = gain_tmep;
}
theta = theta - dt;
}
this->maxThetaGain = maxphiGain;
qDebug() << "phi=90 Gain : \t" << maxphiGain << " -- " << theta << " -- " << phi;
}
// 根据阈值计算方位向扫描角的范围注意这里以dB为单位选择phi=0 时即飞行方向求解不同theta的最大增益
{
double thetaEdgeMax = 0;
double thetaEdgeMin = 0;
double nexttheta = 0;
double gain_temp = this->maxPhiGain;
double phi = 0;
double dt = 1e-5;
double dgain = 0;
// 直接循环以1e-6次方为步长
while (thetaEdgeMax <= 90) {
gain_temp = this->getGain(thetaEdgeMax, phi);
if (gain_temp - this->maxPhiGain < threshold) {
break;
}
thetaEdgeMax = thetaEdgeMax + dt;
}
while (thetaEdgeMin > -90) {
gain_temp = this->getGain(thetaEdgeMin, phi);
if (gain_temp - this->maxPhiGain < threshold) {
break;
}
thetaEdgeMin = thetaEdgeMin - dt;
}
this->EdgethetaMax = thetaEdgeMax;
this->EdgethetaMin = thetaEdgeMin;
qDebug() << "phi=0 theta :\t" << thetaEdgeMin << " -- " << thetaEdgeMax;
this->EdgeXMax = std::sin(thetaEdgeMax * d2r); // 计算X 轴范围
this->EdgeXMin = -1*std::sin(thetaEdgeMin * d2r);
}
return ErrorCode::SUCCESS;
}
std::vector<double> AbstractRadiationPattern::getThetas()
{
return this->thetas;
}
std::vector<double> AbstractRadiationPattern::getPhis()
{
return this->phis;
}
Eigen::MatrixXd AbstractRadiationPattern::getGainMatrix()
{
return this->GainMatrix;
}

View File

@ -0,0 +1,331 @@
#pragma once
/*****************************************************************//**
* \file SARSatelliteSimulationAbstractCls.h
* \brief SAR仿,
*
*
* 1.
* 2. 线
* 3. 线 线0Z->Y theta , X->Y phi )
* 4. (PRFFs)
* 线 phi=0 X G(phi)>G(theta) G(V)>G(H)
* 线 phi=90 y G(phi)<G(theta) G(V)<G(H)
* \author
* \date October 2024
*********************************************************************/
#include "BaseConstVariable.h"
#include "LogInfoCls.h"
#include <QString>
#include <vector>
#include <Eigen/Core>
#include <Eigen/Dense>
#include "GeoOperator.h"
/// <summary>
/// 轨道节点,坐标系统为WGS84
/// </summary>
struct SatelliteOribtNode {
double time;
double Px;// 位置
double Py;
double Pz;
double Vx;// 速度
double Vy;
double Vz;
double AVx; // 加速度
double AVy;
double AVz;
double AntXaxisX; // X天线指向对应翻滚角等参数
double AntXaxisY; //
double AntXaxisZ; //
double AntYaxisX; // Y天线指向对应翻滚角等参数
double AntYaxisY; //
double AntYaxisZ; //
double AntZaxisX; // Z天线指向对应翻滚角等参数
double AntZaxisY; //
double AntZaxisZ; //
double AntDirecX; // 天线指向,对应翻滚角等参数
double AntDirecY;
double AntDirecZ;
double beamAngle; // 波位角
double AzAngle;// 摆动角
};
struct SatelliteAntDirect {
double Xst; // 地面-->卫星矢量
double Yst;
double Zst;
double Vxs; // 卫星速度
double Vys;
double Vzs;
double Xant; // 天线坐标系下的 矢量坐标
double Yant;
double Zant;
double Norm;
double ThetaAnt; // 天线坐标系下的 theta 坐标系
double PhiAnt;
};
struct RadiationPatternGainPoint {
double theta;
double phi;
double GainValue;
};
/// <summary>
/// 天线方向图的获取
/// 注意这里存在一定的插值方法
/// </summary>
class AbstractRadiationPattern {
public:
AbstractRadiationPattern();
virtual ~AbstractRadiationPattern();
public:
virtual double getGain(double& theta, double& phi);
virtual std::vector<RadiationPatternGainPoint> getGainList();
virtual ErrorCode getGain(double& theta, double& phi, double& GainValue);
virtual ErrorCode getGainLinear(double& theta, double& phi, double& GainValue);
virtual ErrorCode setGain(double& theta, double& phi, double& GainValue);
virtual ErrorCode RecontructGainMatrix(double threshold=-3);
virtual std::vector<double> getThetas();
virtual std::vector<double> getPhis();
virtual Eigen::MatrixXd getGainMatrix();
private:
std::vector<RadiationPatternGainPoint> GainMap; // 天线方向图
std::vector<double> thetas;
std::vector<double> phis;
Eigen::MatrixXd GainMatrix;
double maxGain, maxThetaGain, maxPhiGain;
double mintheta, maxtheta, minphi, maxphi;
double EdgethetaMin, EdgethetaMax;
double EdgeXMin, EdgeXMax;
};
/// <summary>
/// 卫星轨道模型,与姿态控制
/// 如无特别说明,所有角度都是弧度制
/// 如果没有特别说明卫星天线坐标系参考GF3:
/// 天线展开放方向轴为X轴
/// X轴定义为 天线摆动角为0时卫星飞行方向
/// Z轴定义为纵向理论上 Z轴应该为天线指向方向
/// H 极化定义为 垂直极化Z->X 平面
/// V 极化定义为 水平极化Z->Y 平面
/// -Z
/// |
/// [=====]X<---Y---[======]
/// _
/// ___
/// _____
/// _________
///
///
///
/// -Z
/// ^
/// |
/// X<-Fly-Y
/// _
/// ___
/// _______
///
/// 左右视
/// 左视(+ 右视(-
/// Z Z Z
/// ^ \ /
/// | \ /
/// x<--O--- x<--O--- x<--O---
/// | |\ /|
/// \ /
///
///
/// X=Y x Z 摆动角(- 摆动角(+
/// Z Z Z
/// ^ \ /
/// | \ /
/// y<--X--- y<--X--- y<--X---
/// | |\ /|
/// \ /
/// 注多普勒时间按照《合成孔径雷达成像算法与实现cumming》中前视为 - ,后视为 +
///
/// </summary>
class AbstractSatelliteOribtModel {
public:
virtual ~AbstractSatelliteOribtModel();
public: // 卫星轨道节点
virtual SatelliteOribtNode getSatelliteOribtNode(double& timeFromStartTime,bool& antAzAngleFlag); // 获取轨道节点
virtual ErrorCode getSatelliteOribtNode(double& timeFromStartTime, SatelliteOribtNode& node, bool& antAzAngleFlag); // 获取轨道节点
virtual ErrorCode getSatelliteAntDirectNormal(SatelliteOribtNode& Rs, Vector3D& Rt, SatelliteAntDirect& antNode); // 计算目标在天线方向图中的位置
public: // 卫星轨道模型的参考时间节点
virtual void setSatelliteOribtStartTime(long double oribtStartTime);// 设置卫星模型参考时间
virtual long double getSatelliteOribtStartTime();// 获取卫星模型参考时间
public: // 入射角相关参数
virtual void setbeamAngle(double beamAngle,bool RightLook);// 设置波位角
public: // 天线摆动角相关参数
virtual void setAzAngleRange(double cycletime,double minAzAngle,double maxAzAngle,double referenceAzAngle, double referenceTimeFromStartTime);//方位角变换循环时间 ;方位角变换范围; 特定时间的方位角,用于计算方位角变化情况
virtual double getAzAngleInCurrentTimeFromStartTime(double& currentTime);// 获取当前时间的 天线摆动角
virtual ErrorCode getAzAngleInCurrentTimeFromStartTime(double& currentTime, double& AzAngle);// 获取当前时间的 天线摆动角
public: // 定义在原始天线坐标下的天线坐标系的调整,其中仍然定义-Z 轴为 天线指向方向
virtual void setAntnnaAxisX(double X,double Y,double Z); // 设置天线X轴指向
virtual void setAntnnaAxisY(double X, double Y, double Z); // 设置天线X轴指向
virtual void setAntnnaAxisZ(double X, double Y, double Z); // 设置天线X轴指向
virtual ErrorCode getAntnnaDirection( SatelliteOribtNode &node); // 获取天线指向方向
public:
virtual double getPt();
virtual double getGri();
virtual void setPt(double Pt);
virtual void setGri(double gri);
};
/// <summary>
/// SAR卫星的相关信息
/// 1. 坐标系统为 WGS84坐标单位是 米,时间单位是: 秒
/// 2. 注意一般来说PRF图像行数相关Fs 与 图像列数是相关得
/// 3.
/// </summary>
class AbstractSARSatelliteModel
{
public: // 轨道模型
virtual SatelliteOribtNode getSatelliteOribtNode(double& timeFromStartTime, bool& antAzAngleFlag);// 设置轨道节点,
virtual ErrorCode getSatelliteOribtNode(double& timeFromStartTime, SatelliteOribtNode& node, bool& antAzAngleFlag); // 获取轨道节点
virtual ErrorCode getSatelliteAntDirectNormal(SatelliteOribtNode& Rs, Vector3D& Rt, SatelliteAntDirect& antNode); // 计算目标在天线方向图中的位置
virtual void setSatelliteOribtModel(std::shared_ptr<AbstractSatelliteOribtModel> model); // 设置轨道模型
public:// 影像成像时间
virtual void setSARImageStartTime(long double imageStartTime);// 成像开始时间
virtual void setSARImageEndTime(long double imageEndTime); // 成像结束时间
virtual double getSARImageStartTime();
virtual double getSARImageEndTime();
virtual double getNearRange(); // 近斜距 -- 快时间门
virtual void setNearRange(double NearRange);
virtual double getFarRange(); // 最远斜距
virtual void setFarRange(double FarRange);
virtual bool getIsRightLook() ; // 是否右视
virtual void setIsRightLook(bool isR) ;
public: // 成像参数
virtual void setCenterFreq(double Freq); // 中心频率
virtual double getCenterFreq();
virtual void setCenterLamda(double Lamda); // 波长
virtual double getCenterLamda();
virtual void setBandWidth(double bandwidth); // 带宽范围
virtual double getBandWidth();
virtual POLARTYPEENUM getPolarType();// 极化类型
virtual void setPolarType(POLARTYPEENUM type);
public: // 设置PRF、FS
virtual void setPRF(double prf); // 方位向采样频率
virtual double getPRF();
virtual double getFs(); // 距离向采样频率
virtual void setFs(double Fs);
virtual double getCenterLookAngle() ;
virtual void setCenterLookAngle(double angle) ;
public:// 天线方向图
virtual void setTransformRadiationPattern(std::shared_ptr<AbstractRadiationPattern> radiationPanttern); // 极化发射方向图
virtual void setReceiveRadiationPattern(std::shared_ptr<AbstractRadiationPattern> radiationPanttern); // V 极化接收方向图
virtual std::shared_ptr<AbstractRadiationPattern> getTransformRadiationPattern();// H 极化发射方向图
virtual std::shared_ptr<AbstractRadiationPattern> getReceiveRadiationPattern();// V 极化发射方向图
public:
virtual double getPt();
virtual double getGri();
virtual void setPt(double Pt);
virtual void setGri(double gri);
};
/** 通用函数 ************************************************************************** */
/// <summary>
/// 从xml文件中读取卫星集合坐标节点
/// </summary>
/// <param name="xmlPath"></param>
/// <param name="nodes"></param>
/// <returns></returns>
ErrorCode ReadSateGPSPointsXML(QString xmlPath, std::vector<SatelliteOribtNode>& nodes);
std::vector<SatelliteOribtNode> FilterSatelliteOribtNode(std::vector<SatelliteOribtNode>& nodes, double startTime, double endTime,long minCount=10);
std::shared_ptr<AbstractRadiationPattern> CreateAbstractRadiationPattern(std::vector<RadiationPatternGainPoint> antPatternPoints);
std::vector<RadiationPatternGainPoint> ReadGainFile(QString antPatternFilePath);
/** 天线方向图文件展示 ********************************************************************** */
/** 多普勒频率计算相关内容 ********************************************************************** */
/**
*
* cumming ,
* Mark A.Richards,
*
* InSAR
* SAR仿
*
* SAR仿
*
*
* .
*/
// 多普勒中心频率
double getDopplerCenterFreq(double &lamda,double &R,Vector3D &Rs,Vector3D &Rt,Vector3D &Vs,Vector3D &Vt);
// 多普勒调频率(斜率)
double getDopplerFreqRate(double& lamda, double& R, Vector3D& Rs, Vector3D& Rt, Vector3D& Vs, Vector3D& Vt,Vector3D &Ast);

View File

@ -0,0 +1,306 @@
#include "stdafx.h"
#include "BaseConstVariable.h"
#include "BaseTool.h"
#include "SARSimulationTaskSetting.h"
#include <QFile>
#include <QDomDocument>
#include <QDateTime>
#include <QString>
#include <QDebug>
SatelliteOribtNode SARSimulationTaskSetting::getSatelliteOribtNode(double& timeFromStartTime, bool& antAzAngleFlag)
{
return this->OribtModel->getSatelliteOribtNode(timeFromStartTime, antAzAngleFlag);
}
ErrorCode SARSimulationTaskSetting::getSatelliteOribtNode(double& timeFromStartTime, SatelliteOribtNode& node, bool& antAzAngleFlag)
{
return this->OribtModel->getSatelliteOribtNode(timeFromStartTime, node, antAzAngleFlag);
}
void SARSimulationTaskSetting::setSatelliteOribtModel(std::shared_ptr < AbstractSatelliteOribtModel> model)
{
this->OribtModel = model;
}
ErrorCode SARSimulationTaskSetting::getSatelliteAntDirectNormal(SatelliteOribtNode& Rs, Vector3D& Rt, SatelliteAntDirect& antNode)
{
return this->OribtModel->getSatelliteAntDirectNormal(Rs, Rt, antNode);
}
void SARSimulationTaskSetting::setSARImageStartTime(long double imageStartTime)
{
this->imageStartTime = imageStartTime;
}
void SARSimulationTaskSetting::setSARImageEndTime(long double imageEndTime)
{
this->imageEndTime = imageEndTime;
}
double SARSimulationTaskSetting::getSARImageStartTime()
{
return this->imageStartTime;
}
double SARSimulationTaskSetting::getSARImageEndTime()
{
return this->imageEndTime;
}
double SARSimulationTaskSetting::getNearRange()
{
return this->NearRange;
}
void SARSimulationTaskSetting::setNearRange(double NearRange)
{
this->NearRange = NearRange;
}
double SARSimulationTaskSetting::getFarRange()
{
return this->FarRange;
}
void SARSimulationTaskSetting::setFarRange(double FarRange)
{
this->FarRange = FarRange;
}
bool SARSimulationTaskSetting::getIsRightLook()
{
return this->isR;
}
void SARSimulationTaskSetting::setIsRightLook(bool isR)
{
this->isR = isR;
}
void SARSimulationTaskSetting::setCenterFreq(double Freq)
{
this->centerFreq = Freq;
this->centerLamda = LIGHTSPEED / Freq;
}
double SARSimulationTaskSetting::getCenterFreq()
{
return this->centerFreq;
}
void SARSimulationTaskSetting::setCenterLamda(double Lamda)
{
this->centerFreq = LIGHTSPEED/Lamda;
this->centerLamda = this->centerFreq;
}
double SARSimulationTaskSetting::getCenterLamda()
{
return this->centerLamda;
}
void SARSimulationTaskSetting::setBandWidth(double bandwidth)
{
this->bandWidth = bandwidth;
}
double SARSimulationTaskSetting::getBandWidth()
{
return this->bandWidth;
}
POLARTYPEENUM SARSimulationTaskSetting::getPolarType()
{
return this->polarType;
}
void SARSimulationTaskSetting::setPolarType(POLARTYPEENUM type)
{
this->polarType = type;
}
double SARSimulationTaskSetting::getCenterLookAngle()
{
return this->centerLookAngle;
}
void SARSimulationTaskSetting::setCenterLookAngle(double angle)
{
this->centerLookAngle = angle;
}
void SARSimulationTaskSetting::setPRF(double prf)
{
this->PRF = prf;
}
double SARSimulationTaskSetting::getPRF()
{
return this->PRF;
}
double SARSimulationTaskSetting::getFs()
{
return this->Fs;
}
void SARSimulationTaskSetting::setFs(double Fs)
{
this->Fs = Fs;
}
void SARSimulationTaskSetting::setTransformRadiationPattern(std::shared_ptr<AbstractRadiationPattern> radiationPanttern)
{
this->TransformRadiationPattern = radiationPanttern;
}
void SARSimulationTaskSetting::setReceiveRadiationPattern(std::shared_ptr<AbstractRadiationPattern> radiationPanttern)
{
this->ReceiveRadiationPattern = radiationPanttern;
}
std::shared_ptr<AbstractRadiationPattern> SARSimulationTaskSetting::getTransformRadiationPattern()
{
return this->TransformRadiationPattern;
}
std::shared_ptr<AbstractRadiationPattern> SARSimulationTaskSetting::getReceiveRadiationPattern()
{
return this->ReceiveRadiationPattern;
}
double SARSimulationTaskSetting::getPt()
{
return this->OribtModel->getPt();
}
double SARSimulationTaskSetting::getGri()
{
return this->OribtModel->getGri();
}
void SARSimulationTaskSetting::setPt(double Pt)
{
this->OribtModel->setPt(Pt);
}
void SARSimulationTaskSetting::setGri(double gri)
{
this->OribtModel->setGri(gri);
}
std::shared_ptr<AbstractSARSatelliteModel> ReadSimulationSettingsXML(QString xmlPath)
{
QDomDocument doc;
QFile file(xmlPath);
// 打开XML文件
if (!file.open(QIODevice::ReadOnly)) {
qWarning("Could not open XML file");
return nullptr;
}
// 解析XML内容
if (!doc.setContent(&file)) {
file.close();
qWarning("Failed to parse XML file");
return nullptr;
}
file.close();
// 获取根元素
QDomElement root = doc.documentElement();
// 提取信息
QDomElement satellite = root.firstChildElement("satellite");
QDomElement taskSensor = root.firstChildElement("TaskSensor");
if (satellite.isNull() || taskSensor.isNull()) {
qDebug() << QString::fromStdString(errorCode2errInfo(ErrorCode::XMLNOTFOUNDElEMENT));
return nullptr;
}
else {}
QDomElement imagingMode = taskSensor.firstChildElement("imagingMode");
QDomElement radarCenterFrequency = taskSensor.firstChildElement("RadarCenterFrequency");
QDomElement bandWidth = taskSensor.firstChildElement("bandWidth");
QDomElement centerLookAngle = taskSensor.firstChildElement("centerLookAngle");
QDomElement prf = taskSensor.firstChildElement("prf");
QDomElement fs = taskSensor.firstChildElement("fs");
QDomElement polar = taskSensor.firstChildElement("polar");
QDomElement nearRange = taskSensor.firstChildElement("nearRange");
QDomElement farRange = taskSensor.firstChildElement("farRange");
QDomElement lookDirection = taskSensor.firstChildElement("lookDirection");
if (imagingMode.isNull() || radarCenterFrequency.isNull() || bandWidth.isNull() || centerLookAngle.isNull() || prf.isNull() || fs.isNull() || polar.isNull() || nearRange.isNull() || farRange.isNull() )
{
qDebug() << QString::fromStdString(errorCode2errInfo(ErrorCode::XMLNOTFOUNDElEMENT));
return nullptr;
}
else {}
// 提取成像时间
QDomElement imagingTime = taskSensor.firstChildElement("imagingTime");
QDomElement startTime = imagingTime.firstChildElement("start");
QDomElement endTime = imagingTime.firstChildElement("end");
// 提取多普勒参数
//QDomElement dopplerParametersReferenceTime = taskSensor.firstChildElement("DopplerParametersReferenceTime");
if (imagingTime.isNull() || startTime.isNull() || endTime.isNull())
{
qDebug() << QString::fromStdString(errorCode2errInfo(ErrorCode::XMLNOTFOUNDElEMENT));
return nullptr;
}
else {}
std::shared_ptr<SARSimulationTaskSetting> taskSetting = std::make_shared<SARSimulationTaskSetting>();
//SARSimulationTaskSetting taskSetting;
double starttimestamp = convertToMilliseconds(startTime.text().trimmed().toStdString());
double endtimestamp = convertToMilliseconds(endTime.text().trimmed().toStdString());
if (polar.text().toLower().contains("hh")) {
taskSetting->setPolarType(POLARHH);
}
else if (polar.text().toLower().contains("hv")) {
taskSetting->setPolarType(POLARHV);
}
else if (polar.text().toLower().contains("vh")) {
taskSetting->setPolarType(POLARVH);
}
else if (polar.text().toLower().contains("vv")) {
taskSetting->setPolarType(POLARVV);
}
else {}
bool isR = false;
if (!lookDirection.isNull()) {
qDebug() <<"lookDirection" << lookDirection.text();
if (lookDirection.text().toUpper() == "R") {
isR = true;
}
}
taskSetting->setCenterLookAngle(centerLookAngle.text().toDouble());
taskSetting->setSARImageStartTime(starttimestamp); // 成像开始时间
taskSetting->setSARImageEndTime(endtimestamp); // 成像终止时间
taskSetting->setBandWidth(bandWidth.text().toDouble());
taskSetting->setCenterFreq(radarCenterFrequency.text().toDouble()); // 中心频率
taskSetting->setPRF(prf.text().toDouble()); // PRF
taskSetting->setFs(fs.text().toDouble()); //Fs
taskSetting->setNearRange(nearRange.text().toDouble()); // NearRange
taskSetting->setFarRange(farRange.text().toDouble()); // FarRange
taskSetting->setIsRightLook(isR);
return taskSetting;
}

View File

@ -0,0 +1,109 @@
#pragma once
/*****************************************************************//**
* \file SARSimulationTaskSetting.h
* \brief SAR仿
*
* \author 30453
* \date October 2024
*********************************************************************/
#include "BaseConstVariable.h"
#include "BaseTool.h"
#include "SARSatelliteSimulationAbstractCls.h"
#include "SatelliteOribtModel.h"
#include "LogInfoCls.h"
#include <QString>
#include <vector>
#include <memory>
class SARSimulationTaskSetting:public AbstractSARSatelliteModel
{
public: // 轨道模型
virtual SatelliteOribtNode getSatelliteOribtNode(double& timeFromStartTime, bool& antAzAngleFlag) override;// 设置轨道节点,
virtual ErrorCode getSatelliteOribtNode(double& timeFromStartTime, SatelliteOribtNode& node, bool& antAzAngleFlag) override; // 获取轨道节点
virtual void setSatelliteOribtModel( std::shared_ptr < AbstractSatelliteOribtModel> model) override; // 设置轨道模型
virtual ErrorCode getSatelliteAntDirectNormal(SatelliteOribtNode& Rs, Vector3D& Rt, SatelliteAntDirect& antNode); // 计算目标在天线方向图中的位置
private:
std::shared_ptr <AbstractSatelliteOribtModel> OribtModel; // 轨道模型
public:// 影像成像时间
virtual void setSARImageStartTime(long double imageStartTime) override;// 成像开始时间
virtual void setSARImageEndTime(long double imageEndTime) override; // 成像结束时间
virtual double getSARImageStartTime() override;
virtual double getSARImageEndTime() override;
virtual double getNearRange() override; // 近斜距 -- 快时间门
virtual void setNearRange(double NearRange) override;
virtual double getFarRange() override; // 最远斜距
virtual void setFarRange(double FarRange) override;
virtual bool getIsRightLook() override; // 是否右视
virtual void setIsRightLook(bool isR) override;
private:
double imageStartTime;
double imageEndTime;
double NearRange;
double FarRange;
bool isR;
public: // 成像参数
virtual void setCenterFreq(double Freq) override; // 中心频率
virtual double getCenterFreq() override;
virtual void setCenterLamda(double Lamda) override; // 波长
virtual double getCenterLamda() override;
virtual void setBandWidth(double bandwidth) override; // 带宽范围
virtual double getBandWidth() override;
virtual POLARTYPEENUM getPolarType();// 极化类型
virtual void setPolarType(POLARTYPEENUM type);
virtual double getCenterLookAngle() override;
virtual void setCenterLookAngle(double angle) override;
private:
double centerLookAngle;
double centerFreq;
double centerLamda;
double bandWidth;
POLARTYPEENUM polarType;
public: // 设置PRF、FS
virtual void setPRF(double prf) override; // 方位向采样频率
virtual double getPRF() override;
virtual double getFs() override; // 距离向采样频率
virtual void setFs(double Fs) override;
private:
double PRF;
double Fs;
public:// 天线方向图
virtual void setTransformRadiationPattern(std::shared_ptr<AbstractRadiationPattern> radiationPanttern); // 极化发射方向图
virtual void setReceiveRadiationPattern(std::shared_ptr<AbstractRadiationPattern> radiationPanttern); // V 极化接收方向图
virtual std::shared_ptr<AbstractRadiationPattern> getTransformRadiationPattern();// H 极化发射方向图
virtual std::shared_ptr<AbstractRadiationPattern> getReceiveRadiationPattern();// V 极化发射方向图
private: // 变量
std::shared_ptr<AbstractRadiationPattern> TransformRadiationPattern; // 极化发射方向图
std::shared_ptr<AbstractRadiationPattern> ReceiveRadiationPattern; // 极化接收方向图
public:
virtual double getPt() override;
virtual double getGri() override;
virtual void setPt(double Pt) override;
virtual void setGri(double gri) override;
};
std::shared_ptr<AbstractSARSatelliteModel> ReadSimulationSettingsXML(QString xmlPath);

View File

@ -0,0 +1,368 @@
#include "stdafx.h"
#include "SatelliteOribtModel.h"
#include "GeoOperator.h"
#include <boost/math/tools/polynomial.hpp> // 多项式
#include "BaseTool.h"
#include <QDebug>
PolyfitSatelliteOribtModel::PolyfitSatelliteOribtModel()
{
this->oribtStartTime = 0;
this->beamAngle = 0;
this->RightLook = true;
this->cycletime = 0;
this->minAzAngle = 0;
this->maxAzAngle = 0;
this->referenceAzAngle = 0;
this->referenceTimeFromStartTime = 0;
this->AntnnaAxisX = Point3{ 1,0,0 };
this->AntnnaAxisY = Point3{ 0,1,0 };
this->AntnnaAxisZ = Point3{ 0,0,1 };
this->Pxchisq = 0;
this->Pychisq = 0;
this->Pzchisq = 0;
this->Vxchisq = 0;
this->Vychisq = 0;
this->Vzchisq = 0;
this->Pt = 1;
this->Gri = 1;
}
PolyfitSatelliteOribtModel::~PolyfitSatelliteOribtModel()
{
//TODO: 析构函数
}
SatelliteOribtNode PolyfitSatelliteOribtModel::getSatelliteOribtNode(double& timeFromStartTime, bool& antAzAngleFlag)
{
// 位置、速度
SatelliteOribtNode node;
ErrorCode state = getSatelliteOribtNode(timeFromStartTime, node, antAzAngleFlag);
return node;
}
ErrorCode PolyfitSatelliteOribtModel::getSatelliteOribtNode(double& timeFromStartTime, SatelliteOribtNode& node, bool& antAzAngleFlag)
{
// 卫星坐标,速度方向
node.time = timeFromStartTime;
node.Px=0;
node.Py=0;
node.Pz=0;
node.Vx=0;
node.Vy=0;
node.Vz=0;
for (long i = 0; i < this->polyfitPx.size(); i++) { // 求解平方
node.Px += this->polyfitPx[i] * pow(timeFromStartTime, i);
node.Py += this->polyfitPy[i] * pow(timeFromStartTime, i);
node.Pz += this->polyfitPz[i] * pow(timeFromStartTime, i);
node.Vx += this->polyfitVx[i] * pow(timeFromStartTime, i);
node.Vy += this->polyfitVy[i] * pow(timeFromStartTime, i);
node.Vz += this->polyfitVz[i] * pow(timeFromStartTime, i);
}
node.beamAngle = this->beamAngle; // 波位角
ErrorCode Azstatecode=this->getAzAngleInCurrentTimeFromStartTime(timeFromStartTime, node.AzAngle); // 摆动角
if (Azstatecode != ErrorCode::SUCCESS) {
return Azstatecode;
} else {}
if (!antAzAngleFlag) {
return ErrorCode::SUCCESS;
} else {
}
// 计算卫星天线指向
ErrorCode state = getAntnnaDirection(node);
if (state != ErrorCode::SUCCESS) {
return state;
} else {}
return ErrorCode::SUCCESS;
}
ErrorCode PolyfitSatelliteOribtModel::getSatelliteAntDirectNormal(SatelliteOribtNode& Rs, Vector3D& Rt, SatelliteAntDirect& antNode)
{
//Vector3D Rts = Vector3D{Rt.x-Rs.Px,Rt.y- Rs.Py,Rt.z-Rs.Pz}; // Rts t-->s
antNode.Xst = (Rt.x - Rs.Px); // 卫星 --> 地面
antNode.Yst = (Rt.y - Rs.Py);
antNode.Zst = (Rt.z - Rs.Pz);
antNode.Vxs = Rs.Vx; // 卫星速度
antNode.Vys = Rs.Vy;
antNode.Vzs = Rs.Vz;
// 天线指向在天线坐标系下的值
antNode.Xant = (antNode.Xst * (Rs.AntYaxisY * Rs.AntZaxisZ - Rs.AntYaxisZ * Rs.AntZaxisY) + antNode.Xst * (Rs.AntXaxisZ * Rs.AntZaxisY - Rs.AntXaxisY * Rs.AntZaxisZ) + antNode.Xst * (Rs.AntXaxisY * Rs.AntYaxisZ - Rs.AntXaxisZ * Rs.AntYaxisY)) / (Rs.AntXaxisX * (Rs.AntYaxisY * Rs.AntZaxisZ - Rs.AntZaxisY * Rs.AntYaxisZ) - Rs.AntYaxisX * (Rs.AntXaxisY * Rs.AntZaxisZ - Rs.AntXaxisZ * Rs.AntZaxisY) + Rs.AntZaxisX * (Rs.AntXaxisY * Rs.AntYaxisZ - Rs.AntXaxisZ * Rs.AntYaxisY));
antNode.Yant = (antNode.Yst * (Rs.AntYaxisZ * Rs.AntZaxisX - Rs.AntYaxisX * Rs.AntZaxisZ) + antNode.Yst * (Rs.AntXaxisX * Rs.AntZaxisZ - Rs.AntXaxisZ * Rs.AntZaxisX) + antNode.Yst * (Rs.AntYaxisX * Rs.AntXaxisZ - Rs.AntXaxisX * Rs.AntYaxisZ)) / (Rs.AntXaxisX * (Rs.AntYaxisY * Rs.AntZaxisZ - Rs.AntZaxisY * Rs.AntYaxisZ) - Rs.AntYaxisX * (Rs.AntXaxisY * Rs.AntZaxisZ - Rs.AntXaxisZ * Rs.AntZaxisY) + Rs.AntZaxisX * (Rs.AntXaxisY * Rs.AntYaxisZ - Rs.AntXaxisZ * Rs.AntYaxisY));
antNode.Zant = (antNode.Zst * (Rs.AntYaxisX * Rs.AntZaxisY - Rs.AntYaxisY * Rs.AntZaxisX) + antNode.Zst * (Rs.AntXaxisY * Rs.AntZaxisX - Rs.AntXaxisX * Rs.AntZaxisY) + antNode.Zst * (Rs.AntXaxisX * Rs.AntYaxisY - Rs.AntYaxisX * Rs.AntXaxisY)) / (Rs.AntXaxisX * (Rs.AntYaxisY * Rs.AntZaxisZ - Rs.AntZaxisY * Rs.AntYaxisZ) - Rs.AntYaxisX * (Rs.AntXaxisY * Rs.AntZaxisZ - Rs.AntXaxisZ * Rs.AntZaxisY) + Rs.AntZaxisX * (Rs.AntXaxisY * Rs.AntYaxisZ - Rs.AntXaxisZ * Rs.AntYaxisY));
// 计算theta 与 phi
antNode.Norm = std::sqrt(antNode.Xant*antNode.Xant+antNode.Yant*antNode.Yant+antNode.Zant*antNode.Zant); // 计算 pho
antNode.ThetaAnt = std::acos(antNode.Zant / antNode.Norm); // theta 与 Z轴的夹角
antNode.PhiAnt = (antNode.Yant*std::sin(antNode.ThetaAnt)/std::abs(antNode.Yant*std::sin(antNode.ThetaAnt))) * std::acos(antNode.Xant/(antNode.Norm*std::sin(antNode.ThetaAnt)));
return ErrorCode::SUCCESS;
}
void PolyfitSatelliteOribtModel::setSatelliteOribtStartTime(long double oribtStartTime)
{
this->oribtStartTime = oribtStartTime;
}
long double PolyfitSatelliteOribtModel::getSatelliteOribtStartTime()
{
return this->oribtStartTime;
}
void PolyfitSatelliteOribtModel::setbeamAngle(double beamAngle, bool RightLook)
{
this->beamAngle = beamAngle;
this->RightLook = RightLook;
}
void PolyfitSatelliteOribtModel::setAzAngleRange(double cycletime, double minAzAngle, double maxAzAngle, double referenceAzAngle, double referenceTimeFromStartTime)
{
this->cycletime = cycletime;
this->minAzAngle = minAzAngle;
this->maxAzAngle = maxAzAngle;
this->referenceAzAngle = referenceAzAngle;
this->referenceTimeFromStartTime = referenceTimeFromStartTime;
}
double PolyfitSatelliteOribtModel::getAzAngleInCurrentTimeFromStartTime(double& currentTime)
{
// 计算角度
double Azangle = 0;
ErrorCode state = getAzAngleInCurrentTimeFromStartTime(currentTime, Azangle);
return Azangle;
}
///
/// X=Y x Z 摆动角(- 摆动角(+
/// Z Z Z
/// ^ \ /
/// | \ /
/// y<--X--- y<--X--- y<--X---
/// | |\ /|
/// | \ /
///
ErrorCode PolyfitSatelliteOribtModel::getAzAngleInCurrentTimeFromStartTime(double& currentTime, double& AzAngle)
{
if (std::abs(this->maxAzAngle - this->minAzAngle) < 1e-7||std::abs(this->cycletime)<1e-7) {
AzAngle=this->referenceAzAngle;
return ErrorCode::SUCCESS;
}
else {
AzAngle = this->referenceAzAngle + (currentTime - this->referenceTimeFromStartTime) / this->cycletime * (this->maxAzAngle - this->minAzAngle);
return ErrorCode::SUCCESS;
}
}
void PolyfitSatelliteOribtModel::setAntnnaAxisX(double X, double Y, double Z)
{
this->AntnnaAxisX = Point3{ X, Y, Z };
}
void PolyfitSatelliteOribtModel::setAntnnaAxisY(double X, double Y, double Z)
{
this->AntnnaAxisY = Point3{ X, Y, Z };
}
void PolyfitSatelliteOribtModel::setAntnnaAxisZ(double X, double Y, double Z)
{
this->AntnnaAxisZ = Point3{ X, Y, Z };
}
/// 左视(+ 右视(-
/// Z Z Z
/// ^ \ /
/// | \ /
/// x<--O--- x<--O--- x<--O---
/// | |\ /|
/// \ /
///
ErrorCode PolyfitSatelliteOribtModel::getAntnnaDirection(SatelliteOribtNode& node)
{
// 1. 计算天线指向
Eigen::Vector3d axisZ0 = { -1*node.Px ,-1 * node.Py,-1 * node.Pz}; // z 轴 --波位角为0时天线指向的反方向
Eigen::Vector3d axisX0 = { node.Vx ,node.Vy,node.Vz }; // x 轴 --飞行方向
Eigen::Vector3d axisY0 = axisZ0.cross(axisX0); // y 轴 --右手定则 -- 初始坐标系
double rotateAngle = this->RightLook ? -this->beamAngle : this->beamAngle; // 旋转角度 左逆时针theta , 右(顺时针): -theta
// 1.2. 根据波位角确定卫星绕X轴-飞行轴
Eigen::Matrix3d rotateMatrixBeam = rotationMatrix(axisX0, rotateAngle*d2r); // 旋转矩阵
axisZ0=rotateMatrixBeam*axisZ0; // 旋转矩阵
axisY0=rotateMatrixBeam*axisY0;
axisX0=rotateMatrixBeam*axisX0;
// 1.3. 根据方位角确定卫星绕Y轴旋转
double azangle = node.AzAngle;
Eigen::Matrix3d rotateMatrixAzAngle = rotationMatrix(axisY0, rotateAngle * d2r); // 旋转矩阵
axisZ0 = rotateMatrixAzAngle * axisZ0; // 旋转矩阵
axisY0 = rotateMatrixAzAngle * axisY0;
axisX0 = rotateMatrixAzAngle * axisX0;
// 1.4. 计算实际指向
node.AntDirecX = axisZ0[0];
node.AntDirecY = axisZ0[1];
node.AntDirecZ = axisZ0[2];
// 2. 计算天线坐标系,方便计算天线方向图
node.AntXaxisX =axisX0[0]; // 实际天线坐标系 在 WGS84 坐标系
node.AntXaxisY =axisX0[1];
node.AntXaxisZ =axisX0[2];
node.AntYaxisX =axisY0[0];
node.AntYaxisY =axisY0[1];
node.AntYaxisZ =axisY0[2];
node.AntZaxisX =axisZ0[0];
node.AntZaxisY =axisZ0[1];
node.AntZaxisZ =axisZ0[2];
return ErrorCode::SUCCESS;
}
void PolyfitSatelliteOribtModel::addOribtNode(SatelliteOribtNode node)
{
this->oribtNodes.push_back(node);
}
ErrorCode polynomial_fit(const std::vector<double>& x, const std::vector<double>& y, int degree, std::vector<double>& out_factor, double& out_chisq) {
int xyLength = x.size();
double* xdata = new double[xyLength];
double* ydata = new double[xyLength];
for (long i = 0; i < xyLength; i++) {
xdata[i] = x[i];
ydata[i] = y[i];
}
ErrorCode state= polyfit(xdata, ydata,xyLength, degree, out_factor, out_chisq);
delete[] xdata;
delete[] ydata; // 释放内存
return state;
}
ErrorCode PolyfitSatelliteOribtModel::polyFit(int polynum/*=3*/, bool input_timeFromReferenceTime)
{
if (polynum > this->oribtNodes.size() - 1) {
return ErrorCode::OrbitNodeNotEnough;
}
else {}
this->polyfitPx=std::vector<double>(polynum+1,0);
this->polyfitPy=std::vector<double>(polynum+1,0);
this->polyfitPz=std::vector<double>(polynum+1,0);
this->polyfitVx=std::vector<double>(polynum+1,0);
this->polyfitVy=std::vector<double>(polynum+1,0);
this->polyfitVz=std::vector<double>(polynum+1,0);
std::vector<double> timeArr = std::vector<double>(this->oribtNodes.size(), 0);
std::vector<double> PxArr = std::vector<double>(this->oribtNodes.size(), 0);
std::vector<double> PyArr = std::vector<double>(this->oribtNodes.size(), 0);
std::vector<double> PzArr = std::vector<double>(this->oribtNodes.size(), 0);
std::vector<double> VxArr = std::vector<double>(this->oribtNodes.size(), 0);
std::vector<double> VyArr = std::vector<double>(this->oribtNodes.size(), 0);
std::vector<double> VzArr = std::vector<double>(this->oribtNodes.size(), 0);
// 数据准备
for (long i = 0; i < this->oribtNodes.size(); i++) {
if (input_timeFromReferenceTime) {
timeArr[i] = this->oribtNodes[i].time;
}
else {
timeArr[i] = this->oribtNodes[i].time - this->oribtStartTime; // 以参考时间为基准
qDebug() << this->oribtNodes[i].time << "\t--->\t"<< timeArr[i];
}
PxArr[i] = this->oribtNodes[i].Px;
PyArr[i] = this->oribtNodes[i].Py;
PzArr[i] = this->oribtNodes[i].Pz;
VxArr[i] = this->oribtNodes[i].Vx;
VyArr[i] = this->oribtNodes[i].Vy;
VzArr[i] = this->oribtNodes[i].Vz;
}
// 拟合Px Py Pz Vx Vy Vz
ErrorCode codePx = polynomial_fit(timeArr, PxArr, polynum, this->polyfitPx, this->Pxchisq);
ErrorCode codePy = polynomial_fit(timeArr, PyArr, polynum, this->polyfitPy, this->Pychisq);
ErrorCode codePz = polynomial_fit(timeArr, PzArr, polynum, this->polyfitPz, this->Pzchisq);
ErrorCode codeVx = polynomial_fit(timeArr, VxArr, polynum, this->polyfitVx, this->Vxchisq);
ErrorCode codeVy = polynomial_fit(timeArr, VyArr, polynum, this->polyfitVy, this->Vychisq);
ErrorCode codeVz = polynomial_fit(timeArr, VzArr, polynum, this->polyfitVz, this->Vzchisq);
// 打印 this->polyfitPx
qDebug() << "polyfit value:";
qDebug() << "Px" << "\t" << "Py" << "\t" << "Pz" << "\t" << "Vx" << "\t" << "Vy" << "\t" << "Vz";
for (long i = 0; i < this->polyfitPx.size(); i++) { // 求解平方
qDebug() << this->polyfitPx[i] << "\t" << this->polyfitPy[i] << "\t" << this->polyfitPz[i] << "\t" << this->polyfitVx[i] << "\t" << this->polyfitVy[i] << "\t" << this->polyfitVz[i];
}
// 评价拟合情况
double starttime = this->oribtStartTime;
qDebug() << "oribt refrence time: " << starttime;
qDebug() << "time" << "\t" << "dPx" << "\t" << "dPy" << "\t" << "dPz" << "\t" << "dVx" << "\t" << "dVy" << "\t" << "dVz";
for (long i = 0; i < timeArr.size(); i++) {
double time_temp = timeArr[i];
bool flag = false;
SatelliteOribtNode tempnode;
this->getSatelliteOribtNode(time_temp, tempnode, flag);
qDebug() << timeArr[i] << "\t" << PxArr[i] - tempnode.Px << "\t" << PyArr[i] - tempnode.Py << "\t" << PzArr[i] - tempnode.Pz << "\t" << VxArr[i] - tempnode.Vx << "\t" << VyArr[i] - tempnode.Vy << "\t" << VzArr[i] - tempnode.Vz;
}
return ErrorCode::SUCCESS;
}
double PolyfitSatelliteOribtModel::getPt()
{
return this->Pt;
}
double PolyfitSatelliteOribtModel::getGri()
{
return this->Gri;
}
void PolyfitSatelliteOribtModel::setPt(double pt)
{
this->Pt = pt;
}
void PolyfitSatelliteOribtModel::setGri(double gri)
{
this->Gri = gri;
}
std::shared_ptr<AbstractSatelliteOribtModel> CreataPolyfitSatelliteOribtModel(std::vector<SatelliteOribtNode>& nodes, long double startTime, int polynum)
{
qDebug() << "CreataPolyfitSatelliteOribtModel \t" << (double)startTime<<"\t" << polynum;
std::shared_ptr<PolyfitSatelliteOribtModel> ployfitOribtModel= std::make_shared< PolyfitSatelliteOribtModel>();
for (long i = 0; i < nodes.size(); i++) {
ployfitOribtModel->addOribtNode(nodes[i]);
}
ployfitOribtModel->setSatelliteOribtStartTime(startTime);
ErrorCode stateCode = ployfitOribtModel->polyFit(polynum,false);
if (stateCode != ErrorCode::SUCCESS) {
qDebug() <<QString::fromStdString( errorCode2errInfo(stateCode));
return nullptr;
}
else {
return ployfitOribtModel;
}
return ployfitOribtModel;
}

View File

@ -0,0 +1,112 @@
#pragma once
/*****************************************************************//**
* \file SatelliteOribtModel.h
* \brief
*
* \author
* \date October 2024
*********************************************************************/
#include "LogInfoCls.h"
#include "BaseConstVariable.h"
#include "SARSatelliteSimulationAbstractCls.h"
#include <vector>
#include <memory>
/// <summary>
/// 多项式轨道模型
/// </summary>
class PolyfitSatelliteOribtModel:public AbstractSatelliteOribtModel
{
public:
PolyfitSatelliteOribtModel();
~PolyfitSatelliteOribtModel() override;
public: // 卫星轨道节点
virtual SatelliteOribtNode getSatelliteOribtNode(double& timeFromStartTime, bool& antAzAngleFlag) override; // 获取轨道节点
virtual ErrorCode getSatelliteOribtNode(double& timeFromStartTime, SatelliteOribtNode& node, bool& antAzAngleFlag) override; // 获取轨道节点
virtual ErrorCode getSatelliteAntDirectNormal(SatelliteOribtNode& Rs, Vector3D& Rt, SatelliteAntDirect& antNode); // 计算目标在天线方向图中的位置
public: // 卫星轨道模型的参考时间节点
virtual void setSatelliteOribtStartTime(long double oribtStartTime) override;// 设置卫星模型参考时间
virtual long double getSatelliteOribtStartTime() override;// 获取卫星模型参考时间
public: // 入射角相关参数
virtual void setbeamAngle(double beamAngle, bool RightLook) override;// 设置波位角
public: // 天线摆动角相关参数
virtual void setAzAngleRange(double cycletime, double minAzAngle, double maxAzAngle, double referenceAzAngle, double referenceTimeFromStartTime) override;//方位角变换循环时间 ;方位角变换范围; 特定时间的方位角,用于计算方位角变化情况
virtual double getAzAngleInCurrentTimeFromStartTime(double& currentTime) override;// 获取当前时间的 天线摆动角
virtual ErrorCode getAzAngleInCurrentTimeFromStartTime(double& currentTime, double& AzAngle);// 获取当前时间的 天线摆动角
public: // 定义在原始天线坐标下的天线坐标系的调整,其中仍然定义-Z 轴为 天线指向方向
virtual void setAntnnaAxisX(double X, double Y, double Z) override; // 设置天线X轴指向
virtual void setAntnnaAxisY(double X, double Y, double Z) override; // 设置天线X轴指向
virtual void setAntnnaAxisZ(double X, double Y, double Z) override; // 设置天线X轴指向
virtual ErrorCode getAntnnaDirection(SatelliteOribtNode& node) override; // 获取天线指向方向
private: // 变量
long double oribtStartTime; // 卫星模型参考时间
double beamAngle; // 波位角
bool RightLook; // 左右视
double cycletime; // 方位角变换循环时间
double minAzAngle; // 方位角变换范围
double maxAzAngle; // 方位角变换范围
double referenceAzAngle; // 特定时间的方位角,用于计算方位角变化情况
double referenceTimeFromStartTime; // 特定时间的方位角,用于计算方位角变化情况
Point3 AntnnaAxisX; // 天线X轴指向
Point3 AntnnaAxisY; // 天线Y轴指向
Point3 AntnnaAxisZ; // 天线Z轴指向
public: // 增加节点
void addOribtNode(SatelliteOribtNode node);
ErrorCode polyFit(int polynum = 3, bool input_timeFromReferenceTime = false);
private: // 轨道节点
std::vector<SatelliteOribtNode> oribtNodes;
std::vector<double> polyfitPx; // 空间坐标
std::vector<double> polyfitPy;
std::vector<double> polyfitPz;
std::vector<double> polyfitVx; // 速度拟合参数
std::vector<double> polyfitVy;
std::vector<double> polyfitVz;
double Pxchisq; // 拟合误差 X2
double Pychisq;
double Pzchisq;
double Vxchisq;
double Vychisq;
double Vzchisq;
public:
virtual double getPt() override;
virtual double getGri() override;
virtual void setPt(double Pt) override;
virtual void setGri(double gri) override;
//virtual double getPt();
//virtual double getGri();
//virtual void setPt(double Pt);
//virtual void setGri(double gri);
private:
double Pt; // 发射电压
double Gri;// 系统增益
};
ErrorCode polynomial_fit(const std::vector<double>& x, const std::vector<double>& y, int degree, std::vector<double>& out_factor, double& out_chisq);
std::shared_ptr<AbstractSatelliteOribtModel> CreataPolyfitSatelliteOribtModel(std::vector<SatelliteOribtNode> &nodes, long double startTime,int polynum=3);

View File

@ -0,0 +1,143 @@
#include "stdafx.h"
#include "SigmaDatabase.h"
#include <set>
#include <map>
#include "BaseConstVariable.h"
double getSigma(double& theta, SigmaParam& param) {
return param.p1 + param.p2 * exp(-param.p3 * theta) + param.p4 * cos(param.p5 * theta + param.p6);
}
SigmaDatabase::SigmaDatabase()
{
this->HH_sigmaParam = std::map<long, SigmaParam>();
this->HV_sigmaParam = std::map<long, SigmaParam>();
this->VH_sigmaParam = std::map<long, SigmaParam>();
this->VV_sigmaParam = std::map<long, SigmaParam>();
this->HH_sigmaParam.clear();
this->HV_sigmaParam.clear();
this->VH_sigmaParam.clear();
this->VV_sigmaParam.clear();
//12
this->HH_sigmaParam.insert(std::pair<long, SigmaParam>(12, SigmaParam{ -21.1019701821713, 9.00621457243906, 6.52932182540331, - 1.11157376729893, - 15.8022895411007, 11.4690828129602 }));
this->HV_sigmaParam.insert(std::pair<long, SigmaParam>(12, SigmaParam{ -30.0103645753547, 27.1700862271921, 11.8007376386356, - 0.933835390422269, - 16.4640776105300, 11.8318838032267 }));
this->VH_sigmaParam.insert(std::pair<long, SigmaParam>(12, SigmaParam{ -30.0103645753547, 27.1700862271921, 11.8007376386356, -0.933835390422269, -16.4640776105300, 11.8318838032267 }));
this->VV_sigmaParam.insert(std::pair<long, SigmaParam>(12, SigmaParam{ -21.1019701821713, 9.00621457243906, 6.52932182540331, -1.11157376729893, -15.8022895411007, 11.4690828129602 }));
//22
this->HH_sigmaParam.insert(std::pair<long, SigmaParam>(22, SigmaParam{ -43.6677042155964, 32.0245140457417, 0.511060658303930, - 2.68482232690106, 6.29783274559538, 1.96648609622833 }));
this->HV_sigmaParam.insert(std::pair<long, SigmaParam>(22, SigmaParam{ -36.3971634075803, 13.1296247093899, 1.12707368693158, - 1.88195857790977, 6.57450737122974, 2.11755051297951 }));
this->VH_sigmaParam.insert(std::pair<long, SigmaParam>(22, SigmaParam{ -36.3971634075803, 13.1296247093899, 1.12707368693158, -1.88195857790977, 6.57450737122974, 2.11755051297951 }));
this->VV_sigmaParam.insert(std::pair<long, SigmaParam>(22, SigmaParam{ -43.6677042155964, 32.0245140457417, 0.511060658303930, -2.68482232690106, 6.29783274559538, 1.96648609622833 }));
//30
this->HH_sigmaParam.insert(std::pair<long, SigmaParam>(30, SigmaParam{ -59.1080014669385, 47.6710707363975, 0.300193452564135, - 3.93463636916976, 5.99799798331127, - 10.3772604045974 }));
this->HV_sigmaParam.insert(std::pair<long, SigmaParam>(30, SigmaParam{ -55.1864353240982, 32.2453149408716, 0.333758208816865, - 3.38774208141056, 6.12774897769798, - 10.1192846531823 }));
this->VH_sigmaParam.insert(std::pair<long, SigmaParam>(30, SigmaParam{ -55.1864353240982, 32.2453149408716, 0.333758208816865, - 3.38774208141056, 6.12774897769798, - 10.1192846531823 }));
this->VV_sigmaParam.insert(std::pair<long, SigmaParam>(30, SigmaParam{ -59.1080014669385, 47.6710707363975, 0.300193452564135, -3.93463636916976, 5.99799798331127, -10.3772604045974 }));
//50
this->HH_sigmaParam.insert(std::pair<long, SigmaParam>(50, SigmaParam{ -22.9105602882378, 8170.54100628307, 15.4916054293135, - 0.970580847008280, 28.9025325818511, - 21.4319176514170 }));
this->HV_sigmaParam.insert(std::pair<long, SigmaParam>(50, SigmaParam{ -39.7459019584805, 151.391039247574, 5.17117231380975, - 4.10303899418773, 8.04893424718507, - 3.17171678851531 }));
this->VH_sigmaParam.insert(std::pair<long, SigmaParam>(50, SigmaParam{ -39.7459019584805, 151.391039247574, 5.17117231380975, -4.10303899418773, 8.04893424718507, -3.17171678851531 }));
this->VV_sigmaParam.insert(std::pair<long, SigmaParam>(50, SigmaParam{ -22.9105602882378, 8170.54100628307, 15.4916054293135, -0.970580847008280, 28.9025325818511, -21.4319176514170 }));
//61
this->HH_sigmaParam.insert(std::pair<long, SigmaParam>(61, SigmaParam{ 27.2590864500905, 95.6840751800642, 3.98975084647232, 50.3262749621072, 3.09962879546370, - 5.10400310274333 }));
this->HV_sigmaParam.insert(std::pair<long, SigmaParam>(61, SigmaParam{ -65.9799383836613, 106.831320929437, 1.53821651203361, 0.704332523237733, 36.3654715437260, - 13.7449876973719 }));
this->VH_sigmaParam.insert(std::pair<long, SigmaParam>(61, SigmaParam{ -65.9799383836613, 106.831320929437, 1.53821651203361, 0.704332523237733, 36.3654715437260, -13.7449876973719 }));
this->VV_sigmaParam.insert(std::pair<long, SigmaParam>(61, SigmaParam{ 27.2590864500905, 95.6840751800642, 3.98975084647232, 50.3262749621072, 3.09962879546370, -5.10400310274333 }));
//62
this->HH_sigmaParam.insert(std::pair<long, SigmaParam>(62, SigmaParam{ -34.3961764495281, 21.7503968763591, 1.15914650010176, - 2.83950292185421, 10.3519995095232, 2.75293811408200 }));
this->HV_sigmaParam.insert(std::pair<long, SigmaParam>(62, SigmaParam{ -34.0710914034599, 14.1778732014224, 3.47049853590805, - 1.73813229616801, 10.9627971440838, 2.19731364578002 }));
this->VH_sigmaParam.insert(std::pair<long, SigmaParam>(62, SigmaParam{ -34.0710914034599, 14.1778732014224, 3.47049853590805, -1.73813229616801, 10.9627971440838, 2.19731364578002 }));
this->VV_sigmaParam.insert(std::pair<long, SigmaParam>(62, SigmaParam{ -34.3961764495281, 21.7503968763591, 1.15914650010176, -2.83950292185421, 10.3519995095232, 2.75293811408200 }));
//80
this->HH_sigmaParam.insert(std::pair<long, SigmaParam>(80, SigmaParam{ -5.76486750987210, - 7.80014668607246, 0.0880097904597720, - 5.44564720816575, - 0.530358195545799, 1.04332202699956 }));
this->HV_sigmaParam.insert(std::pair<long, SigmaParam>(80, SigmaParam{ 484.928701445606, - 0.992170190244375, - 1.98914783519718, - 507.127544388772, 0.195180814149377, 6.21339949756719 }));
this->VH_sigmaParam.insert(std::pair<long, SigmaParam>(80, SigmaParam{ 484.928701445606, -0.992170190244375, -1.98914783519718, -507.127544388772, 0.195180814149377, 6.21339949756719 }));
this->VV_sigmaParam.insert(std::pair<long, SigmaParam>(80, SigmaParam{ -5.76486750987210, -7.80014668607246, 0.0880097904597720, -5.44564720816575, -0.530358195545799, 1.04332202699956 }));
//90
this->HH_sigmaParam.insert(std::pair<long, SigmaParam>(90, SigmaParam{ -20.1761798059391, 13.2752519275021, 2.74667225608397, 3.63052241744923, 8.99932188120922, 34.8246533269446 }));
this->HV_sigmaParam.insert(std::pair<long, SigmaParam>(90, SigmaParam{ -26.8776515733889, 10.4251866500052, 8.43273666535992, 4.33165922141213, 8.68204389555939, - 2.51718779582920 }));
this->VH_sigmaParam.insert(std::pair<long, SigmaParam>(90, SigmaParam{ -26.8776515733889, 10.4251866500052, 8.43273666535992, 4.33165922141213, 8.68204389555939, - 2.51718779582920 }));
this->VV_sigmaParam.insert(std::pair<long, SigmaParam>(90, SigmaParam{ -20.1761798059391, 13.2752519275021, 2.74667225608397, 3.63052241744923, 8.99932188120922, 34.8246533269446 }));
}
SigmaDatabase::~SigmaDatabase()
{
this->HH_sigmaParam.clear();
this->HV_sigmaParam.clear();
this->VH_sigmaParam.clear();
this->VV_sigmaParam.clear();
}
double SigmaDatabase::getAmpHH(long cls, double angle)
{
if (this->HH_sigmaParam.find(cls) == this->HH_sigmaParam.end()) {
return 0;
}
else {
return std::pow(10, getSigma(angle, this->HH_sigmaParam[cls]) / 10.0);
}
}
double SigmaDatabase::getAmpHV(long cls, double angle)
{
if (this->HV_sigmaParam.find(cls) == this->HV_sigmaParam.end()) {
return 0;
}
else {
return std::pow(10, getSigma(angle, this->HV_sigmaParam[cls]) / 10.0);
}
}
double SigmaDatabase::getAmpVH(long cls, double angle)
{
if (this->VH_sigmaParam.find(cls) == this->VH_sigmaParam.end()) {
return 0;
}
else {
return std::pow(10, getSigma(angle, this->VH_sigmaParam[cls]) / 10.0);
}
}
double SigmaDatabase::getAmpVV(long cls, double angle)
{
if (this->VV_sigmaParam.find(cls) == this->VV_sigmaParam.end()) {
return 0;
}
else {
return std::pow(10, getSigma(angle, this->VV_sigmaParam[cls]) / 10.0);
}
}
double SigmaDatabase::getAmp(long cls, double angle, POLARTYPEENUM polartype)
{
switch (polartype)
{
case(POLARHH): { return this->getAmpHH(cls, angle); }
case(POLARHV): { return this->getAmpHV(cls, angle); }
case(POLARVH): { return this->getAmpVH(cls, angle); }
case(POLARVV): { return this->getAmpVV(cls, angle); }
default:
return 1;
}
}

View File

@ -0,0 +1,84 @@
#pragma once
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <time.h>
#include <string>
#include <omp.h>
#include <gdal.h>
#include <gdal_priv.h>
#include <gdalwarper.h>
#include <ogrsf_frmts.h>
#include <fstream>
#include <vector>
#include <string>
#include <QString>
#include <QStringList>
#include <set>
#include <map>
#include "BaseConstVariable.h"
#include "LogInfoCls.h"
struct SigmaParam {
double p1;
double p2;
double p3;
double p4;
double p5;
double p6;
};
double getSigma(double& theta, SigmaParam& param);
class SigmaDatabase
{
public:
SigmaDatabase();
~SigmaDatabase();
public:
/// <summary>
///
/// </summary>
/// <param name="cls"></param>
/// <param name="angle">說僅硉</param>
/// <returns></returns>
double getAmpHH(long cls, double angle);
/// <summary>
///
/// </summary>
/// <param name="cls"></param>
/// <param name="angle">說僅硉</param>
/// <returns></returns>
double getAmpHV(long cls, double angle);
/// <summary>
///
/// </summary>
/// <param name="cls"></param>
/// <param name="angle">說僅硉</param>
/// <returns></returns>
double getAmpVH(long cls, double angle);
/// <summary>
///
/// </summary>
/// <param name="cls"></param>
/// <param name="angle">說僅硉</param>
/// <returns></returns>
double getAmpVV(long cls, double angle);
double getAmp(long cls, double angle, POLARTYPEENUM polartype);
private:
std::map<long, SigmaParam> HH_sigmaParam;
std::map<long, SigmaParam> HV_sigmaParam;
std::map<long, SigmaParam> VH_sigmaParam;
std::map<long, SigmaParam> VV_sigmaParam;
};

View File

@ -4,8 +4,7 @@
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
RasterProcessTool w;
RasterProcessTool w;// Ö÷½çÃæ
w.show();
return a.exec();
}