RasterProcessTool/Toolbox/SimulationSARTool/SimulationSAR/SARSimulationTaskSetting.cpp

386 lines
11 KiB
C++
Raw Normal View History

#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;
}
2025-01-06 11:56:45 +00:00
void SARSimulationTaskSetting::setRefphaseRange(double refRange)
{
this->refPhaseRange = refRange;
}
double SARSimulationTaskSetting::getRefphaseRange()
{
return this->refPhaseRange;
}
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()
{
2025-01-06 11:56:45 +00:00
return this->pt;
}
double SARSimulationTaskSetting::getGri()
{
2025-01-06 11:56:45 +00:00
return this->Gri;
}
2025-01-06 11:56:45 +00:00
void SARSimulationTaskSetting::setPt(double InPt)
{
2025-01-06 11:56:45 +00:00
this->pt = InPt;
}
2025-01-06 11:56:45 +00:00
void SARSimulationTaskSetting::setGri(double Ingri)
{
2025-01-06 11:56:45 +00:00
this->Gri = Ingri;
}
2025-02-17 09:13:18 +00:00
double SARSimulationTaskSetting::getDopplerParametersReferenceTime()
{
return this->DopplerParametersReferenceTime;
}
void SARSimulationTaskSetting::setDopplerParametersReferenceTime(double time)
{
this->DopplerParametersReferenceTime = time;
}
std::vector<double> SARSimulationTaskSetting::getDopplerCentroidCoefficients()
{
return this->DopplerCentroidCoefficients;
}
void SARSimulationTaskSetting::setDopplerCentroidCoefficients(std::vector<double> DopplerCentroids)
{
this->DopplerCentroidCoefficients = DopplerCentroids;
}
std::vector<double> SARSimulationTaskSetting::getDopplerRateValuesCoefficients()
{
return this->DopplerRateValuesCoefficients;
}
void SARSimulationTaskSetting::setDopplerRateValuesCoefficients(std::vector<double> DopplerRateValues)
{
this->DopplerRateValuesCoefficients = DopplerRateValues;
}
std::shared_ptr<AbstractSARSatelliteModel> ReadSimulationSettingsXML(QString xmlPath)
{
QDomDocument doc;
QFile file(xmlPath);
// <20><><EFBFBD><EFBFBD>XML<4D>ļ<EFBFBD>
if (!file.open(QIODevice::ReadOnly)) {
qWarning("Could not open XML file");
return nullptr;
}
// <20><><EFBFBD><EFBFBD>XML<4D><4C><EFBFBD><EFBFBD>
if (!doc.setContent(&file)) {
file.close();
qWarning("Failed to parse XML file");
return nullptr;
}
file.close();
// <20><>ȡ<EFBFBD><C8A1>Ԫ<EFBFBD><D4AA>
QDomElement root = doc.documentElement();
// <20><>ȡ<EFBFBD><C8A1>Ϣ
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");
2025-01-06 11:56:45 +00:00
QDomElement refphaseRange = taskSensor.firstChildElement("refPhaseRange");
QDomElement polar = taskSensor.firstChildElement("polar");
QDomElement nearRange = taskSensor.firstChildElement("nearRange");
QDomElement farRange = taskSensor.firstChildElement("farRange");
QDomElement lookDirection = taskSensor.firstChildElement("lookDirection");
2025-01-06 11:56:45 +00:00
QDomElement ptitem = taskSensor.firstChildElement("Pt");
QDomElement griitem = taskSensor.firstChildElement("Gri");
2025-02-17 09:13:18 +00:00
2025-01-06 11:56:45 +00:00
if (imagingMode.isNull() || radarCenterFrequency.isNull() || bandWidth.isNull()
|| centerLookAngle.isNull() || prf.isNull() || polar.isNull()
2025-01-06 11:56:45 +00:00
|| nearRange.isNull() || farRange.isNull()|| refphaseRange.isNull()
|| ptitem.isNull()
|| griitem.isNull())
{
qDebug() << QString::fromStdString(errorCode2errInfo(ErrorCode::XMLNOTFOUNDElEMENT));
return nullptr;
}
else {}
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
QDomElement imagingTime = taskSensor.firstChildElement("imagingTime");
QDomElement startTime = imagingTime.firstChildElement("start");
QDomElement endTime = imagingTime.firstChildElement("end");
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD>
//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>();
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;
}
}
2025-02-17 09:13:18 +00:00
// <20><><EFBFBD><EFBFBD>Dopper<65><72><EFBFBD><EFBFBD> DopplerParametersReferenceTime
QDomElement DopplerParametersReferenceTimeItem = taskSensor.firstChildElement("DopplerParametersReferenceTime");
QDomElement DopplerCentroidCoefficientItem = taskSensor.firstChildElement("DopplerCentroidCoefficients");
QDomElement DopplerRateValuesCoefficientItem = taskSensor.firstChildElement("DopplerRateValuesCoefficients");
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD>ȡ
double dopplerRefrenceTime = DopplerParametersReferenceTimeItem.text().toDouble();
std::vector<double> DopplerCentroidCoefficients(5);
std::vector<double> DopplerRateValuesCoefficient(5);
DopplerCentroidCoefficients[0]= DopplerCentroidCoefficientItem.firstChildElement("d0").text().toDouble();
DopplerCentroidCoefficients[1]= DopplerCentroidCoefficientItem.firstChildElement("d1").text().toDouble();
DopplerCentroidCoefficients[2]= DopplerCentroidCoefficientItem.firstChildElement("d2").text().toDouble();
DopplerCentroidCoefficients[3]= DopplerCentroidCoefficientItem.firstChildElement("d3").text().toDouble();
DopplerCentroidCoefficients[4]= DopplerCentroidCoefficientItem.firstChildElement("d4").text().toDouble();
DopplerRateValuesCoefficient[0] = DopplerRateValuesCoefficientItem.firstChildElement("r0").text().toDouble();
DopplerRateValuesCoefficient[1] = DopplerRateValuesCoefficientItem.firstChildElement("r1").text().toDouble();
DopplerRateValuesCoefficient[2] = DopplerRateValuesCoefficientItem.firstChildElement("r2").text().toDouble();
DopplerRateValuesCoefficient[3] = DopplerRateValuesCoefficientItem.firstChildElement("r3").text().toDouble();
DopplerRateValuesCoefficient[4] = DopplerRateValuesCoefficientItem.firstChildElement("r4").text().toDouble();
2025-01-06 11:56:45 +00:00
taskSetting->setRefphaseRange(refphaseRange.text().toDouble());
taskSetting->setCenterLookAngle(centerLookAngle.text().toDouble());
taskSetting->setSARImageStartTime(starttimestamp); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼʱ<CABC><CAB1>
taskSetting->setSARImageEndTime(endtimestamp); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹʱ<D6B9><CAB1>
taskSetting->setBandWidth(bandWidth.text().toDouble());
taskSetting->setCenterFreq(radarCenterFrequency.text().toDouble()); // <20><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>
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);
2025-01-06 11:56:45 +00:00
taskSetting->setPt(ptitem.text().toDouble());
taskSetting->setGri(griitem.text().toDouble());
2025-02-17 09:13:18 +00:00
taskSetting->setDopplerParametersReferenceTime(dopplerRefrenceTime);
taskSetting->setDopplerCentroidCoefficients(DopplerCentroidCoefficients);
taskSetting->setDopplerRateValuesCoefficients(DopplerRateValuesCoefficient);
return taskSetting;
}