From d2ee22b0f196c47616df64a48f6d856647cdee3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=A2=9E=E8=BE=89?= <3045316072@qq.com> Date: Fri, 18 Apr 2025 03:30:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E8=A1=A5=E9=AB=98=E5=88=86=E4=B8=89?= =?UTF-8?q?=E5=8F=B7=E6=96=87=E4=BB=B6=E8=AF=BB=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BaseCommonLibrary/BaseTool/BaseTool.cpp | 73 +++++- BaseCommonLibrary/BaseTool/BaseTool.h | 18 +- BaseCommonLibrary/BaseTool/FileOperator.cpp | 3 +- BaseCommonLibrary/BaseTool/GeoOperator.cpp | 54 ++++- BaseCommonLibrary/BaseTool/GeoOperator.h | 20 ++ .../BaseTool/ImageOperatorBase.h | 2 +- .../BaseTool/SARSimulationImageL1.cpp | 110 ++++----- .../BaseTool/gdalImageOperator.cpp | 9 + BaseCommonLibrary/ImageOperatorFuntion.cpp | 10 +- .../GF3CalibrationAndGeocodingClass.cpp | 79 +++++-- .../BaseToolbox/BaseToolbox/GF3PSTNClass.cpp | 2 +- .../BaseToolbox/QComplex2AmpPhase.cpp | 11 +- .../BaseToolbox/QImportGF3StripL1ADataset.cpp | 7 +- .../BaseToolbox/QRDOrthProcessClass.cpp | 4 +- .../BaseToolbox/SatelliteGF3xmlParser.cpp | 217 ++++++++++-------- 15 files changed, 428 insertions(+), 191 deletions(-) diff --git a/BaseCommonLibrary/BaseTool/BaseTool.cpp b/BaseCommonLibrary/BaseTool/BaseTool.cpp index 64d6252..5ea4ed0 100644 --- a/BaseCommonLibrary/BaseTool/BaseTool.cpp +++ b/BaseCommonLibrary/BaseTool/BaseTool.cpp @@ -38,7 +38,10 @@ #include // 包含SSE指令集头文件 #include // 包含SSE2指令集头文件 #include // 包含OpenMP头文件 - +#include +#include +#include +#include QString longDoubleToQStringScientific(long double value) { std::ostringstream stream; @@ -702,3 +705,71 @@ Eigen::MatrixXd BASECONSTVARIABLEAPI dB2Amp(Eigen::MatrixXd& sigma0) } + +QDateTime parseCustomDateTime(const QString& dateTimeStr) { + // 手动解析日期时间字符串 + int year = dateTimeStr.left(4).toInt(); + int month = dateTimeStr.mid(5, 2).toInt(); + int day = dateTimeStr.mid(8, 2).toInt(); + int hour = dateTimeStr.mid(11, 2).toInt(); + int minute = dateTimeStr.mid(14, 2).toInt(); + int second = dateTimeStr.mid(17, 2).toInt(); + int msec = dateTimeStr.mid(20, 6).toInt(); // 只取毫秒的前三位,因为QDateTime支持到毫秒 + + // 创建 QDate 和 QTime 对象 + QDate date(year, month, day); + QTime time(hour, minute, second, msec ); // 转换为微秒,但QTime只支持毫秒精度 + + // 构造 QDateTime 对象 + QDateTime result(date, time); + + return result; +} + + +bool isLeapYear(int year) { + return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); +} + +int daysInMonth(int year, int month) { + if (month == 2) return isLeapYear(year) ? 29 : 28; + else if (month == 4 || month == 6 || month == 9 || month == 11) return 30; + else return 31; +} + + +TimestampMicroseconds parseAndConvert( std::string dateTimeStr) { + // 解析年、月、日、时、分、秒和微秒 + int year = std::stoi(dateTimeStr.substr(0, 4)); + int month = std::stoi(dateTimeStr.substr(5, 2)); + int day = std::stoi(dateTimeStr.substr(8, 2)); + int hour = std::stoi(dateTimeStr.substr(11, 2)); + int minute = std::stoi(dateTimeStr.substr(14, 2)); + int second = std::stoi(dateTimeStr.substr(17, 2)); + int microsec = std::stoi(dateTimeStr.substr(20, 6)); + + // 计算从1970年至目标年份前一年的总天数 + long long totalDays = 0; + for (int y = 1970; y < year; ++y) { + totalDays += isLeapYear(y) ? 366 : 365; + } + + // 加上目标年份从1月到上一个月的天数 + for (int m = 1; m < month; ++m) { + totalDays += daysInMonth(year, m); + } + + // 加上本月的天数 + totalDays += day - 1; + + // 转换为总秒数,再加上小时、分钟、秒 + long long totalSeconds = totalDays * 24 * 60 * 60 + hour * 60 * 60 + minute * 60 + second; + + // 转换为毫秒和微秒 + long long msecsSinceEpoch = totalSeconds * 1000 + microsec / 1000; + int microseconds = microsec % 1000; + + return { msecsSinceEpoch, microseconds }; +} + + diff --git a/BaseCommonLibrary/BaseTool/BaseTool.h b/BaseCommonLibrary/BaseTool/BaseTool.h index 9bc6296..6ad57ff 100644 --- a/BaseCommonLibrary/BaseTool/BaseTool.h +++ b/BaseCommonLibrary/BaseTool/BaseTool.h @@ -31,7 +31,8 @@ #include #include #include - +#include +#include ///////////////////////////////////// 基础数学函数 ///////////////////////////////////////////////////////////// @@ -101,7 +102,7 @@ Eigen::Matrix3d BASECONSTVARIABLEAPI rotationMatrix(const Eigen::Vector3d& axis long double BASECONSTVARIABLEAPI convertToMilliseconds(const std::string& dateTimeStr); - +QDateTime BASECONSTVARIABLEAPI parseCustomDateTime(const QString& dateTimeStr); /// /// list 应该是按照从小到大的顺序排好 /// @@ -132,6 +133,19 @@ void initializeMatrixWithSSE2(Eigen::MatrixXf& mat, const float* data, long rowc Eigen::MatrixXd BASECONSTVARIABLEAPI MuhlemanSigmaArray(Eigen::MatrixXd& eta_deg); Eigen::MatrixXd BASECONSTVARIABLEAPI dB2Amp(Eigen::MatrixXd& sigma0); + +struct TimestampMicroseconds { + boost::int64_t msecsSinceEpoch; // 自1970-01-01T00:00:00 UTC以来的毫秒数 + int microseconds; // 额外的微秒(精确到微秒) +}; + + +bool BASECONSTVARIABLEAPI isLeapYear(int year); +int BASECONSTVARIABLEAPI daysInMonth(int year, int month); + +TimestampMicroseconds BASECONSTVARIABLEAPI parseAndConvert( std::string dateTimeStr); + + /** 模板函数类 ***********************************************************************************************************/ inline double calculate_MuhlemanSigma(double eta_deg) { diff --git a/BaseCommonLibrary/BaseTool/FileOperator.cpp b/BaseCommonLibrary/BaseTool/FileOperator.cpp index d2b1343..6d6ba6c 100644 --- a/BaseCommonLibrary/BaseTool/FileOperator.cpp +++ b/BaseCommonLibrary/BaseTool/FileOperator.cpp @@ -93,7 +93,8 @@ QString getFileNameFromPath(const QString& path) QString getFileNameWidthoutExtend(QString path) { QFileInfo fileInfo(path); - QString fileNameWithoutExtension = fileInfo.baseName(); // 获取无后缀文件名 + QString fileNameWithoutExtension = fileInfo.completeBaseName(); // 获取无后缀文件名 + qDebug() << u8"File name without extension: " << fileNameWithoutExtension; return fileNameWithoutExtension; } diff --git a/BaseCommonLibrary/BaseTool/GeoOperator.cpp b/BaseCommonLibrary/BaseTool/GeoOperator.cpp index 5a1d12a..ce49a3e 100644 --- a/BaseCommonLibrary/BaseTool/GeoOperator.cpp +++ b/BaseCommonLibrary/BaseTool/GeoOperator.cpp @@ -18,7 +18,9 @@ #include #include #include "GeoOperator.h" - +#include // OGRSpatialReference ڿռοת +#include // GDALWarp +#include Landpoint operator +(const Landpoint& p1, const Landpoint& p2) @@ -446,3 +448,53 @@ double getlocalIncAngle(Vector3D& satepoint, Vector3D& landpoint, Vector3D& slop return angle; } } + +bool BASECONSTVARIABLEAPI ConvertResolutionToDegrees(int sourceEPSG, double resolutionMeters, double refLon, double refLat, double& degreePerPixelX, double& degreePerPixelY){ + // ʼԴϵƽͶӰĿϵWGS84 γȣ + OGRSpatialReference sourceSRS, targetSRS; + sourceSRS.importFromEPSG(sourceEPSG); // Դϵȷ EPSG + targetSRS.importFromEPSG(4326); // ĿΪ WGS84 γ + + // תγ -> ƽ + OGRCoordinateTransformation* toPlane = OGRCreateCoordinateTransformation(&targetSRS, &sourceSRS); + if (!toPlane) return false; + + // ο㾭γתΪƽ + double x = refLon, y = refLat; + if (!toPlane->Transform(1, &x, &y)) { + OGRCoordinateTransformation::DestroyCT(toPlane); + return false; + } + + // תƽ -> γ + OGRCoordinateTransformation* toGeo = OGRCreateCoordinateTransformation(&sourceSRS, &targetSRS); + if (!toGeo) { + OGRCoordinateTransformation::DestroyCT(toPlane); + return false; + } + + // 㶫ֱʣȱ仯 + double eastX = x + resolutionMeters, eastY = y; + double eastLon = eastX, eastLat = eastY; + if (!toGeo->Transform(1, &eastLon, &eastLat)) { + OGRCoordinateTransformation::DestroyCT(toPlane); + OGRCoordinateTransformation::DestroyCT(toGeo); + return false; + } + degreePerPixelX = (eastLon - refLon) / resolutionMeters; // ȷÿ׶Ӧ + + // 㱱ֱʣγȱ仯 + double northX = x, northY = y + resolutionMeters; + double northLon = northX, northLat = northY; + if (!toGeo->Transform(1, &northLon, &northLat)) { + OGRCoordinateTransformation::DestroyCT(toPlane); + OGRCoordinateTransformation::DestroyCT(toGeo); + return false; + } + degreePerPixelY = (northLat - refLat) / resolutionMeters; // γȷÿ׶Ӧ + + // ͷԴ + OGRCoordinateTransformation::DestroyCT(toPlane); + OGRCoordinateTransformation::DestroyCT(toGeo); + return true; +} diff --git a/BaseCommonLibrary/BaseTool/GeoOperator.h b/BaseCommonLibrary/BaseTool/GeoOperator.h index a2c42cc..66ce525 100644 --- a/BaseCommonLibrary/BaseTool/GeoOperator.h +++ b/BaseCommonLibrary/BaseTool/GeoOperator.h @@ -124,4 +124,24 @@ CartesianCoordinates BASECONSTVARIABLEAPI sphericalToCartesian(const Spheric double BASECONSTVARIABLEAPI getlocalIncAngle(Vector3D& satepoint, Vector3D& landpoint, Vector3D& slopeVector); + +/** + * @brief 将平面坐标分辨率(米)转换为经纬度分辨率(度) + * @param sourceEPSG 平面坐标系 EPSG 码(如 UTM Zone 50N 对应 32650) + * @param resolutionMeters 输入分辨率(单位:米) + * @param refLon 参考点经度(十进制度,用于计算局部转换系数) + * @param refLat 参考点纬度(十进制度,用于计算局部转换系数) + * @param[out] degreePerPixelX 经度方向分辨率(度/像素) + * @param[out] degreePerPixelY 纬度方向分辨率(度/像素) + * @return 是否转换成功 + */ +bool BASECONSTVARIABLEAPI ConvertResolutionToDegrees( + int sourceEPSG, + double resolutionMeters, + double refLon, + double refLat, + double& degreePerPixelX, + double& degreePerPixelY +); + #endif \ No newline at end of file diff --git a/BaseCommonLibrary/BaseTool/ImageOperatorBase.h b/BaseCommonLibrary/BaseTool/ImageOperatorBase.h index 633dd9e..9b52766 100644 --- a/BaseCommonLibrary/BaseTool/ImageOperatorBase.h +++ b/BaseCommonLibrary/BaseTool/ImageOperatorBase.h @@ -89,7 +89,7 @@ enum GDALREADARRCOPYMETHOD { /// \param long 经度 /// \param lat 纬度 /// \return 对应投影坐标系统的 EPSG编码,-1 表示计算错误 -long BASECONSTVARIABLEAPI getProjectEPSGCodeByLon_Lat(double long, double lat, ProjectStripDelta stripState); +long BASECONSTVARIABLEAPI getProjectEPSGCodeByLon_Lat(double lon, double lat, ProjectStripDelta stripState= ProjectStripDelta::Strip_6); long BASECONSTVARIABLEAPI getProjectEPSGCodeByLon_Lat_inStrip3(double lon, double lat); diff --git a/BaseCommonLibrary/BaseTool/SARSimulationImageL1.cpp b/BaseCommonLibrary/BaseTool/SARSimulationImageL1.cpp index 16134d2..8bc4245 100644 --- a/BaseCommonLibrary/BaseTool/SARSimulationImageL1.cpp +++ b/BaseCommonLibrary/BaseTool/SARSimulationImageL1.cpp @@ -106,7 +106,7 @@ ErrorCode SARSimulationImageL1Dataset::OpenOrNew(QString folder, QString filenam this->saveToXml(); } - if (this->Rasterlevel!=RasterL2||QFile(this->GPSPointFilePath).exists() == false) { + if (this->Rasterlevel==RasterL2||QFile(this->GPSPointFilePath).exists() == false) { // ļ omp_lock_t lock; omp_init_lock(&lock); @@ -122,7 +122,7 @@ ErrorCode SARSimulationImageL1Dataset::OpenOrNew(QString folder, QString filenam omp_destroy_lock(&lock); } - if (this->Rasterlevel == RasterLevel::RasterSLC || QFile(this->ImageRasterPath).exists() == false) { + else if (this->Rasterlevel == RasterLevel::RasterSLC || QFile(this->ImageRasterPath).exists() == false) { // ļ omp_lock_t lock; @@ -140,7 +140,7 @@ ErrorCode SARSimulationImageL1Dataset::OpenOrNew(QString folder, QString filenam } - if (this->Rasterlevel != RasterLevel::RasterSLC || QFile(this->ImageRasterPath).exists() == false) { + else if (this->Rasterlevel == RasterLevel::RasterL1B || QFile(this->ImageRasterPath).exists() == false) { // ļ omp_lock_t lock; @@ -150,11 +150,11 @@ ErrorCode SARSimulationImageL1Dataset::OpenOrNew(QString folder, QString filenam CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES"); GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("ENVI"); - std::shared_ptr poDstDS(poDriver->Create(this->ImageRasterPath.toUtf8().constData(), colCount, rowCount, 1, GDT_CFloat32, NULL)); + std::shared_ptr poDstDS(poDriver->Create(this->GPSPointFilePath.toUtf8().constData(), 19, rowCount, 1, GDT_Float64, NULL)); GDALFlushCache((GDALDatasetH)poDstDS.get()); poDstDS.reset(); - omp_unset_lock(&lock); // - omp_destroy_lock(&lock); // + omp_unset_lock(&lock); + omp_destroy_lock(&lock); } @@ -203,7 +203,7 @@ ErrorCode SARSimulationImageL1Dataset::Open(QString xmlPath) QFileInfo fileInfo(xmlPath); QString fileName = fileInfo.fileName(); // ȡļ QString fileSuffix = fileInfo.suffix(); // ȡ׺ - QString fileNameWithoutSuffix = fileInfo.baseName(); // ȡ׺ļ + QString fileNameWithoutSuffix = fileInfo.completeBaseName(); // ȡ׺ļ QString directoryPath = fileInfo.path(); // ȡļ· if (fileSuffix.toLower() == "xml" || fileSuffix.toLower() == ".xml") { return this->Open(directoryPath, fileNameWithoutSuffix); @@ -246,12 +246,12 @@ void SARSimulationImageL1Dataset::saveToXml() xmlWriter.writeTextElement("RowCount", QString::number(this->rowCount)); xmlWriter.writeTextElement("ColCount", QString::number(this->colCount)); - xmlWriter.writeTextElement("Rnear", QString::number(this->Rnear)); - xmlWriter.writeTextElement("Rfar", QString::number(this->Rfar)); - xmlWriter.writeTextElement("Rref", QString::number(this->Rref)); - xmlWriter.writeTextElement("CenterFreq", QString::number(this->centerFreq)); - xmlWriter.writeTextElement("Fs", QString::number(this->Fs)); - xmlWriter.writeTextElement("CenterAngle", QString::number(this->CenterAngle)); + xmlWriter.writeTextElement("Rnear", QString::number(this->Rnear, 'e', 18)); + xmlWriter.writeTextElement("Rfar", QString::number(this->Rfar, 'e', 18)); + xmlWriter.writeTextElement("Rref", QString::number(this->Rref, 'e', 18)); + xmlWriter.writeTextElement("CenterFreq", QString::number(this->centerFreq, 'e', 18)); + xmlWriter.writeTextElement("Fs", QString::number(this->Fs, 'e', 18)); + xmlWriter.writeTextElement("CenterAngle", QString::number(this->CenterAngle, 'e', 18)); xmlWriter.writeTextElement("LookSide", this->LookSide); // sateantpos @@ -259,60 +259,60 @@ void SARSimulationImageL1Dataset::saveToXml() for (long i = 0; i < this->sateposes.count(); i++) { xmlWriter.writeStartElement("AntPosParam"); - xmlWriter.writeTextElement("time", QString::number(this->sateposes[i].time)); // time - xmlWriter.writeTextElement("Px", QString::number(this->sateposes[i].Px)); // Px - xmlWriter.writeTextElement("Py", QString::number(this->sateposes[i].Py)); // Py - xmlWriter.writeTextElement("Pz", QString::number(this->sateposes[i].Pz)); // Pz - xmlWriter.writeTextElement("Vx", QString::number(this->sateposes[i].Vx)); // Vx - xmlWriter.writeTextElement("Vy", QString::number(this->sateposes[i].Vy)); // Vy - xmlWriter.writeTextElement("Vz", QString::number(this->sateposes[i].Vz)); // Vz - xmlWriter.writeTextElement("AntDirectX", QString::number(this->sateposes[i].AntDirectX)); // AntDirectX - xmlWriter.writeTextElement("AntDirectY", QString::number(this->sateposes[i].AntDirectY)); // AntDirectY - xmlWriter.writeTextElement("AntDirectZ", QString::number(this->sateposes[i].AntDirectZ)); // AntDirectZ - xmlWriter.writeTextElement("AVx", QString::number(this->sateposes[i].AVx)); // AVx - xmlWriter.writeTextElement("AVy", QString::number(this->sateposes[i].AVy)); // AVy - xmlWriter.writeTextElement("AVz", QString::number(this->sateposes[i].AVz)); // AVz - xmlWriter.writeTextElement("lon", QString::number(this->sateposes[i].lon)); // lon - xmlWriter.writeTextElement("lat", QString::number(this->sateposes[i].lat)); // lat - xmlWriter.writeTextElement("ati", QString::number(this->sateposes[i].ati)); // ati + xmlWriter.writeTextElement("time", QString::number(this->sateposes[i].time, 'e', 18)); // time + xmlWriter.writeTextElement("Px", QString::number(this->sateposes[i].Px, 'e', 18)); // Px + xmlWriter.writeTextElement("Py", QString::number(this->sateposes[i].Py, 'e', 18)); // Py + xmlWriter.writeTextElement("Pz", QString::number(this->sateposes[i].Pz, 'e', 18)); // Pz + xmlWriter.writeTextElement("Vx", QString::number(this->sateposes[i].Vx, 'e', 18)); // Vx + xmlWriter.writeTextElement("Vy", QString::number(this->sateposes[i].Vy, 'e', 18)); // Vy + xmlWriter.writeTextElement("Vz", QString::number(this->sateposes[i].Vz, 'e', 18)); // Vz + xmlWriter.writeTextElement("AntDirectX", QString::number(this->sateposes[i].AntDirectX, 'e', 18)); // AntDirectX + xmlWriter.writeTextElement("AntDirectY", QString::number(this->sateposes[i].AntDirectY, 'e', 18)); // AntDirectY + xmlWriter.writeTextElement("AntDirectZ", QString::number(this->sateposes[i].AntDirectZ, 'e', 18)); // AntDirectZ + xmlWriter.writeTextElement("AVx", QString::number(this->sateposes[i].AVx, 'e', 18)); // AVx + xmlWriter.writeTextElement("AVy", QString::number(this->sateposes[i].AVy, 'e', 18)); // AVy + xmlWriter.writeTextElement("AVz", QString::number(this->sateposes[i].AVz, 'e', 18)); // AVz + xmlWriter.writeTextElement("lon", QString::number(this->sateposes[i].lon, 'e', 18)); // lon + xmlWriter.writeTextElement("lat", QString::number(this->sateposes[i].lat, 'e', 18)); // lat + xmlWriter.writeTextElement("ati", QString::number(this->sateposes[i].ati, 'e', 18)); // ati xmlWriter.writeEndElement(); // } - xmlWriter.writeTextElement("ImageStartTime", QString::number(this->startImageTime)); - xmlWriter.writeTextElement("ImageEndTime", QString::number(this->EndImageTime)); + xmlWriter.writeTextElement("ImageStartTime", QString::number(this->startImageTime, 'e', 18)); + xmlWriter.writeTextElement("ImageEndTime", QString::number(this->EndImageTime, 'e', 18)); - xmlWriter.writeTextElement("incidenceAngleNearRange", QString::number(this->incidenceAngleNearRange)); - xmlWriter.writeTextElement("incidenceAngleFarRange", QString::number(this->incidenceAngleFarRange)); - xmlWriter.writeTextElement("TotalProcessedAzimuthBandWidth", QString::number(this->TotalProcessedAzimuthBandWidth)); - xmlWriter.writeTextElement("DopplerParametersReferenceTime", QString::number(this->DopplerParametersReferenceTime)); + xmlWriter.writeTextElement("incidenceAngleNearRange", QString::number(this->incidenceAngleNearRange, 'e', 18)); + xmlWriter.writeTextElement("incidenceAngleFarRange", QString::number(this->incidenceAngleFarRange, 'e', 18)); + xmlWriter.writeTextElement("TotalProcessedAzimuthBandWidth", QString::number(this->TotalProcessedAzimuthBandWidth, 'e', 18)); + xmlWriter.writeTextElement("DopplerParametersReferenceTime", QString::number(this->DopplerParametersReferenceTime, 'e', 18)); xmlWriter.writeStartElement("DopplerCentroidCoefficients"); - xmlWriter.writeTextElement("d0", QString::number(this->d0)); - xmlWriter.writeTextElement("d1", QString::number(this->d1)); - xmlWriter.writeTextElement("d2", QString::number(this->d2)); - xmlWriter.writeTextElement("d3", QString::number(this->d3)); - xmlWriter.writeTextElement("d4", QString::number(this->d4)); + xmlWriter.writeTextElement("d0", QString::number(this->d0, 'e', 18)); + xmlWriter.writeTextElement("d1", QString::number(this->d1, 'e', 18)); + xmlWriter.writeTextElement("d2", QString::number(this->d2, 'e', 18)); + xmlWriter.writeTextElement("d3", QString::number(this->d3, 'e', 18)); + xmlWriter.writeTextElement("d4", QString::number(this->d4, 'e', 18)); xmlWriter.writeEndElement(); // DopplerCentroidCoefficients xmlWriter.writeStartElement("DopplerRateValuesCoefficients"); - xmlWriter.writeTextElement("r0", QString::number(this->r0)); - xmlWriter.writeTextElement("r1", QString::number(this->r1)); - xmlWriter.writeTextElement("r2", QString::number(this->r2)); - xmlWriter.writeTextElement("r3", QString::number(this->r3)); - xmlWriter.writeTextElement("r4", QString::number(this->r4)); + xmlWriter.writeTextElement("r0", QString::number(this->r0, 'e', 18)); + xmlWriter.writeTextElement("r1", QString::number(this->r1, 'e', 18)); + xmlWriter.writeTextElement("r2", QString::number(this->r2, 'e', 18)); + xmlWriter.writeTextElement("r3", QString::number(this->r3, 'e', 18)); + xmlWriter.writeTextElement("r4", QString::number(this->r4, 'e', 18)); xmlWriter.writeEndElement(); // DopplerRateValuesCoefficients - xmlWriter.writeTextElement("latitude_center", QString::number(this->latitude_center)); - xmlWriter.writeTextElement("longitude_center", QString::number(this->longitude_center)); - xmlWriter.writeTextElement("latitude_topLeft", QString::number(this->latitude_topLeft)); - xmlWriter.writeTextElement("longitude_topLeft", QString::number(this->longitude_topLeft)); - xmlWriter.writeTextElement("latitude_topRight", QString::number(this->latitude_topRight)); - xmlWriter.writeTextElement("longitude_topRight", QString::number(this->longitude_topRight)); - xmlWriter.writeTextElement("latitude_bottomLeft", QString::number(this->latitude_bottomLeft)); - xmlWriter.writeTextElement("longitude_bottomLeft", QString::number(this->longitude_bottomLeft)); - xmlWriter.writeTextElement("latitude_bottomRight", QString::number(this->latitude_bottomRight)); - xmlWriter.writeTextElement("longitude_bottomRight", QString::number(this->longitude_bottomRight)); + xmlWriter.writeTextElement("latitude_center", QString::number(this->latitude_center, 'e', 18)); + xmlWriter.writeTextElement("longitude_center", QString::number(this->longitude_center, 'e', 18)); + xmlWriter.writeTextElement("latitude_topLeft", QString::number(this->latitude_topLeft, 'e', 18)); + xmlWriter.writeTextElement("longitude_topLeft", QString::number(this->longitude_topLeft, 'e', 18)); + xmlWriter.writeTextElement("latitude_topRight", QString::number(this->latitude_topRight, 'e', 18)); + xmlWriter.writeTextElement("longitude_topRight", QString::number(this->longitude_topRight, 'e', 18)); + xmlWriter.writeTextElement("latitude_bottomLeft", QString::number(this->latitude_bottomLeft, 'e', 18)); + xmlWriter.writeTextElement("longitude_bottomLeft", QString::number(this->longitude_bottomLeft, 'e', 18)); + xmlWriter.writeTextElement("latitude_bottomRight", QString::number(this->latitude_bottomRight, 'e', 18)); + xmlWriter.writeTextElement("longitude_bottomRight", QString::number(this->longitude_bottomRight, 'e', 18)); xmlWriter.writeEndElement(); // Parameters xmlWriter.writeEndDocument(); diff --git a/BaseCommonLibrary/BaseTool/gdalImageOperator.cpp b/BaseCommonLibrary/BaseTool/gdalImageOperator.cpp index c695822..9fe8bfd 100644 --- a/BaseCommonLibrary/BaseTool/gdalImageOperator.cpp +++ b/BaseCommonLibrary/BaseTool/gdalImageOperator.cpp @@ -1401,6 +1401,15 @@ gdalImage CreategdalImage(const QString& img_path, int height, int width, int ba GDALDataset* poDstDS = poDriver->Create(img_path.toUtf8().constData(), width, height, band_num, datetype, NULL); // ������ + + if (NULL == poDstDS) + { + qDebug() << "Create image failed!"; + throw "Create image failed!"; + exit(1); + } + + if (need_gt) { if (!projection.isEmpty()) { poDstDS->SetProjection(projection.toUtf8().constData()); diff --git a/BaseCommonLibrary/ImageOperatorFuntion.cpp b/BaseCommonLibrary/ImageOperatorFuntion.cpp index 5154807..ae75a14 100644 --- a/BaseCommonLibrary/ImageOperatorFuntion.cpp +++ b/BaseCommonLibrary/ImageOperatorFuntion.cpp @@ -209,6 +209,7 @@ int ENVI2TIFF(QString in_envi_path, QString out_tiff_path) void ConvertCoordinateSystem(QString inRasterPath, QString outRasterPath, long outepsgcode) { // 注册所有GDAL驱动 GDALAllRegister(); + CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES"); // 打开输入栅格文件 GDALDataset* srcDataset = (GDALDataset*)GDALOpen(inRasterPath.toUtf8().constData(), GA_ReadOnly); @@ -294,7 +295,7 @@ void ConvertCoordinateSystem(QString inRasterPath, QString outRasterPath, long o void ResampleByReferenceRasterB(QString pszSrcFile, QString RefrasterBPath, QString pszOutFile, GDALResampleAlg eResample) { GDALAllRegister(); CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES"); - CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO"); + GDALDataset* pDSrc = (GDALDataset*)GDALOpen(pszSrcFile.toLocal8Bit().constData(), GA_ReadOnly); if (pDSrc == NULL) { qDebug() << u8"do not open In Raster file: " << pszSrcFile; @@ -565,6 +566,7 @@ void ResampleByReferenceRasterB(QString InrasterAPath, QString RefrasterBPath, Q void cropRasterByLatLon(const char* inputFile, const char* outputFile, double minLon, double maxLon, double minLat, double maxLat) { // 初始化 GDAL 库 GDALAllRegister(); + CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES"); // 打开栅格数据集 GDALDataset* poDataset = (GDALDataset*)GDALOpen(inputFile, GA_ReadOnly); @@ -762,7 +764,7 @@ void resampleRaster(const char* inputRaster, const char* outputRaster, double ta // 计算目标栅格的尺寸 double targetXSize = (adfGeoTransform[1] * nXSize) / targetPixelSizeX; - double targetYSize = (adfGeoTransform[5] * nYSize) / targetPixelSizeY; + double targetYSize = std::abs((adfGeoTransform[5] * nYSize) / targetPixelSizeY); // 创建目标数据集(输出栅格) GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("GTiff"); @@ -967,14 +969,16 @@ long GetEPSGFromRasterFile(QString filepath) -long getProjectEPSGCodeByLon_Lat(double long, double lat, ProjectStripDelta stripState) +long getProjectEPSGCodeByLon_Lat(double lon, double lat, ProjectStripDelta stripState) { long EPSGCode = 0; switch (stripState) { case ProjectStripDelta::Strip_3: { + EPSGCode = getProjectEPSGCodeByLon_Lat_inStrip3(lon, lat); break; }; case ProjectStripDelta::Strip_6: { + EPSGCode = getProjectEPSGCodeByLon_Lat_inStrip6(lon, lat); break; } default: { diff --git a/Toolbox/BaseToolbox/BaseToolbox/GF3CalibrationAndGeocodingClass.cpp b/Toolbox/BaseToolbox/BaseToolbox/GF3CalibrationAndGeocodingClass.cpp index 1e5fdcd..dc3c8f9 100644 --- a/Toolbox/BaseToolbox/BaseToolbox/GF3CalibrationAndGeocodingClass.cpp +++ b/Toolbox/BaseToolbox/BaseToolbox/GF3CalibrationAndGeocodingClass.cpp @@ -26,7 +26,7 @@ ErrorCode GF3CalibrationRaster(QString inRasterPath, QString outRasterPath, doub double quayCoff = Qualifyvalue * 1.0 / 32767; double caliCoff = std::pow(10.0, (calibrationConst * 1.0 / 20)); - qDebug() << "ϵ:\t" << quayCoff / caliCoff; + qDebug() << u8"ϵ:\t" << quayCoff / caliCoff; long startrow = 0; for (startrow = 0; startrow < imgraster.height; startrow = startrow + blocklines) { @@ -37,7 +37,7 @@ ErrorCode GF3CalibrationRaster(QString inRasterPath, QString outRasterPath, doub imgArr.imag() = imgArrb2.array() * quayCoff / caliCoff; outraster.saveImage(imgArr, startrow, 0, 1); } - qDebug() << "Ӱд뵽" << outRasterPath; + qDebug() << u8"Ӱд뵽" << outRasterPath; return ErrorCode::SUCCESS; } @@ -80,29 +80,29 @@ ErrorCode ImportGF3L1ARasterToWorkspace(QString inMetaxmlPath, QString inRasterP QString outRasterpath = l1dataset.getImageRasterPath(); ErrorCode errorcode = ErrorCode::SUCCESS; - qDebug() << ":\t" << inRasterPath; + qDebug() << u8":\t" << inRasterPath; switch (polsartype) { case POLARHH: - qDebug() << "HH"; + qDebug() << u8"HH"; errorcode = GF3CalibrationRaster(inRasterPath, outRasterpath, gf3xml.HH_QualifyValue, gf3xml.HH_CalibrationConst); break; case POLARHV: - qDebug() << "HH"; + qDebug() << u8"HH"; errorcode = GF3CalibrationRaster(inRasterPath, outRasterpath, gf3xml.HV_QualifyValue, gf3xml.HV_CalibrationConst); break; case POLARVH: - qDebug() << "VH"; + qDebug() << u8"VH"; errorcode = GF3CalibrationRaster(inRasterPath, outRasterpath, gf3xml.VH_QualifyValue, gf3xml.VH_CalibrationConst); break; case POLARVV: - qDebug() << "VV"; + qDebug() << u8"VV"; errorcode = GF3CalibrationRaster(inRasterPath, outRasterpath, gf3xml.VV_QualifyValue, gf3xml.VV_CalibrationConst); break; default: break; } - qDebug() << "״̬\t" << QString::fromStdString(errorCode2errInfo(errorcode)); + qDebug() << u8"״̬\t" << QString::fromStdString(errorCode2errInfo(errorcode)); return errorcode; } @@ -115,7 +115,7 @@ QVector SearchGF3DataTiff(QString inMetaxmlPath) // ȡ·ڵĿ¼ QDir directory(absPath); if (!directory.exists()) { - qDebug() << "Directory does not exist:" << directory.absolutePath(); + qDebug() << u8"Directory does not exist:" << directory.absolutePath(); return QVector(0); } @@ -124,7 +124,7 @@ QVector SearchGF3DataTiff(QString inMetaxmlPath) filters << "*.tif" << "*.TIF" << "*.tiff" << "*.TIFF"; QStringList files = directory.entryList(filters, QDir::Files); - qDebug() << "TIFF Files in the directory" << directory.absolutePath() << ":"; + qDebug() << u8"TIFF Files in the directory" << directory.absolutePath() << ":"; QVector filepath(0); for (long i = 0; i < files.count(); i++) { @@ -144,7 +144,7 @@ POLARTYPEENUM getDatasetGF3FilePolsarType(QString fileName) if (match.hasMatch()) { polarization = match.captured(1); polarization = polarization.toLower().replace("_", ""); - qDebug() << "Polarization extracted:" << polarization; + qDebug() << u8"Polarization extracted:" << polarization; if (polarization == "hh") { return POLARTYPEENUM::POLARHH; } @@ -162,7 +162,7 @@ POLARTYPEENUM getDatasetGF3FilePolsarType(QString fileName) } } else { - qDebug() << "No polarization found in the path."; + qDebug() << u8"No polarization found in the path."; return POLARTYPEENUM::POLARUNKOWN; } @@ -199,7 +199,7 @@ ErrorCode ImportGF3L1AProcess(QString inMetaxmlPath, QString outWorkDirPath) break; } if (errorcode == ErrorCode::SUCCESS) { - return errorcode; + continue; } else { QMessageBox::warning(nullptr, u8"", u8"ݵ"); @@ -305,18 +305,18 @@ ErrorCode GF3RDCreateLookTable(QString inxmlPath, QString indemPath, QString out polyfitmodel.polyFit(3, false); qDebug() << "-----------------------------------"; - qDebug() << "satellite polyfit model params:\n"; + qDebug() << u8"satellite polyfit model params:\n"; qDebug() << polyfitmodel.getSatelliteOribtModelParamsString(); qDebug() << "-----------------------------------"; // ʼұ //1.ֿ long cpucore_num = std::thread::hardware_concurrency(); - long blockline = Memory1MB * 500 / 8 / cpucore_num / 4 / l1dataset.getcolCount(); - blockline = blockline < 50 ? 50 : blockline; + long blocklineinit = Memory1MB / 8 / cpucore_num / 4 / l1dataset.getcolCount() * 4000; + blocklineinit = blocklineinit < 50 ? 50 : blocklineinit; //2. - long colcount = l1dataset.getcolCount(); - long rowcount = l1dataset.getrowCount(); + long colcount = rasterRC.width;//l1dataset.getcolCount(); + long rowcount = rasterRC.height;//l1dataset.getrowCount(); long startRId = 0; long processNumber = 0; @@ -334,7 +334,11 @@ ErrorCode GF3RDCreateLookTable(QString inxmlPath, QString indemPath, QString out #pragma omp parallel for num_threads(cpucore_num-1) - for (startRId = 0; startRId < rowcount; startRId = startRId + blockline) { + for (startRId = 0; startRId < rowcount; startRId = startRId + blocklineinit) { + long blockline = blocklineinit; + if (startRId + blockline > rowcount) { + blockline = rowcount - startRId; + } Eigen::MatrixXd sar_r = rasterRC.getData(startRId, 0, blockline, colcount, 1); Eigen::MatrixXd sar_c = rasterRC.getData(startRId, 0, blockline, colcount, 2); Eigen::MatrixXd dem_x = demxyz.getData(startRId, 0, blockline, colcount, 1); @@ -409,7 +413,7 @@ ErrorCode GF3RDCreateLookTable(QString inxmlPath, QString indemPath, QString out } else {} processNumber = processNumber + blockrows; - qDebug() << "\rprocess bar:\t" << processNumber * 100.0 / rowcount << " % " << "\t\t\t"; + qDebug() << u8"\rprocess bar:\t" << processNumber * 100.0 / rowcount << " % " << "\t\t\t"; if (progressDialog.maximum() <= processNumber) { processNumber = progressDialog.maximum() - 1; } @@ -430,7 +434,7 @@ ErrorCode GF3OrthSLC( QString inRasterPath, QString inlooktablePath, QString out gdalImage outRaster(outRasterPath);// if (outRaster.height != looktableRaster.height || outRaster.width != looktableRaster.width) { - qDebug() << "look table size is not same as outRaster size"<< looktableRaster.height <<"!="<polyfitVz[i], 'e', 6) + "\n"; } result += "------------------------------------------------------\n"; - + printf("%s\n", result.toUtf8().constData()); return result; } diff --git a/Toolbox/BaseToolbox/BaseToolbox/QComplex2AmpPhase.cpp b/Toolbox/BaseToolbox/BaseToolbox/QComplex2AmpPhase.cpp index af2d5a6..ea9936f 100644 --- a/Toolbox/BaseToolbox/BaseToolbox/QComplex2AmpPhase.cpp +++ b/Toolbox/BaseToolbox/BaseToolbox/QComplex2AmpPhase.cpp @@ -16,7 +16,8 @@ QComplex2AmpPhase::QComplex2AmpPhase(QWidget *parent) 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))); - QObject::connect(ui.buttonBox, SIGNAL(accept()), this, SLOT(onaccept())); + QObject::connect(ui.pushButtonWorkSpace, SIGNAL(clicked(bool)), this, SLOT(onpushButtonWorkSpaceClicked(bool))); + QObject::connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(onaccept())); QObject::connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(onreject())); //toggled(bool ) } @@ -47,19 +48,19 @@ void QComplex2AmpPhase::onaccept() slcl1.Open(folderpath, filename); QString l2bfilename = filename + ui.lineEditHZ->text(); SARSimulationImageL1Dataset l1B(RasterLevel::RasterL1B); - slcl1.OpenOrNew(outworkdir, l2bfilename,slcl1.getrowCount(),slcl1.getcolCount()); + l1B.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()); + Complex2AmpRaster(imgfilepath, l1B.getImageRasterPath()); } else if (ui.radioButtonPhase->isChecked()) { - Complex2PhaseRaster(imgfilepath, slcl1.getImageRasterPath()); + Complex2PhaseRaster(imgfilepath, l1B.getImageRasterPath()); } else if (ui.radioButtonSigma0->isChecked()) { - Complex2dBRaster(imgfilepath, slcl1.getImageRasterPath()); + Complex2dBRaster(imgfilepath, l1B.getImageRasterPath()); } progressDialog.setValue(i); } diff --git a/Toolbox/BaseToolbox/BaseToolbox/QImportGF3StripL1ADataset.cpp b/Toolbox/BaseToolbox/BaseToolbox/QImportGF3StripL1ADataset.cpp index 12793e3..e6146f0 100644 --- a/Toolbox/BaseToolbox/BaseToolbox/QImportGF3StripL1ADataset.cpp +++ b/Toolbox/BaseToolbox/BaseToolbox/QImportGF3StripL1ADataset.cpp @@ -7,10 +7,9 @@ QImportGF3StripL1ADataset::QImportGF3StripL1ADataset(QWidget *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))); + QObject::connect(ui.pushButtonAdd,SIGNAL(clicked(bool)),this,SLOT(onpushButtonAddClicked(bool))); + QObject::connect(ui.pushButtonRemove, SIGNAL(clicked(bool)), this, SLOT(onpushButtonRemoveClicked(bool))); + QObject::connect(ui.pushButtonWorkSpace, SIGNAL(clicked(bool)), this, SLOT(onpushButtonWorkSpaceClicked(bool))); QObject::connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(onreject())); QObject::connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(onaccept())); diff --git a/Toolbox/BaseToolbox/BaseToolbox/QRDOrthProcessClass.cpp b/Toolbox/BaseToolbox/BaseToolbox/QRDOrthProcessClass.cpp index 2ad3480..c9ec7cc 100644 --- a/Toolbox/BaseToolbox/BaseToolbox/QRDOrthProcessClass.cpp +++ b/Toolbox/BaseToolbox/BaseToolbox/QRDOrthProcessClass.cpp @@ -10,8 +10,8 @@ QRDOrthProcessClass::QRDOrthProcessClass(QWidget *parent) connect(ui.pushButtonAdd,SIGNAL(clicked(bool)),this,SLOT(onpushButtonAddClicked(bool))); connect(ui.pushButtonRemove,SIGNAL(clicked(bool)),this,SLOT(onpushButtonRemoveClicked(bool))); - connect(ui.pushButtonDEMSelect,SIGNAL(clicked(bool)),this,SLOT(onpushButtonWorkSpaceClicked(bool))); - connect(ui.pushButtonWorkSpace, SIGNAL(clicked(bool)), this, SLOT(pushButtonDEMSelectClicked(bool))); + connect(ui.pushButtonWorkSpace,SIGNAL(clicked(bool)),this,SLOT(onpushButtonWorkSpaceClicked(bool))); + connect(ui.pushButtonDEMSelect, SIGNAL(clicked(bool)), this, SLOT(pushButtonDEMSelectClicked(bool))); QObject::connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(onreject())); QObject::connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(onaccept())); // QDialogButtonBox* buttonBox; diff --git a/Toolbox/BaseToolbox/BaseToolbox/SatelliteGF3xmlParser.cpp b/Toolbox/BaseToolbox/BaseToolbox/SatelliteGF3xmlParser.cpp index 4cae6ee..5c8ae39 100644 --- a/Toolbox/BaseToolbox/BaseToolbox/SatelliteGF3xmlParser.cpp +++ b/Toolbox/BaseToolbox/BaseToolbox/SatelliteGF3xmlParser.cpp @@ -5,24 +5,41 @@ bool SatelliteGF3xmlParser::loadFile(const QString& filename) { QFile file(filename); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - qWarning() << "Cannot open file:" << filename; + qWarning() << u8"Cannot open file:" << filename; return false; } QDomDocument doc; if (!doc.setContent(&file)) { file.close(); - qWarning() << "Failed to parse the file into a DOM tree."; + qWarning() << u8"Failed to parse the file into a DOM tree."; return false; } file.close(); xml = doc; + + this->parseAdditionalData(); + this->parseImageInfo(); + this->parsePlatform(); + this->parseGPS(); + + //ʱ + double tempreftime = start + (end - start) / 2; + for (long i = 0;i < antposs.size();i++) + { + antposs[i].time = antposs[i].time - tempreftime; + } + + start = start- tempreftime; + end = end- tempreftime; + + return true; } void SatelliteGF3xmlParser::parsePlatform() { - QDomElement platform = xml.firstChildElement("root").firstChildElement("platform"); + QDomElement platform = xml.firstChildElement("product").firstChildElement("platform"); if (!platform.isNull()) { CenterTime = platform.firstChildElement("CenterTime").text(); Rs = platform.firstChildElement("Rs").text().toDouble(); @@ -37,24 +54,24 @@ void SatelliteGF3xmlParser::parsePlatform() { 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; + qDebug() << u8"Platform Data:"; + qDebug() << u8"CenterTime:" << CenterTime; + qDebug() << u8"Rs:" << Rs; + qDebug() << u8"satVelocity:" << satVelocity; + qDebug() << u8"RollAngle:" << RollAngle; + qDebug() << u8"PitchAngle:" << PitchAngle; + qDebug() << u8"YawAngle:" << YawAngle; + qDebug() << u8"Xs:" << Xs; + qDebug() << u8"Ys:" << Ys; + qDebug() << u8"Zs:" << Zs; + qDebug() << u8"Vxs:" << Vxs; + qDebug() << u8"Vys:" << Vys; + qDebug() << u8"Vzs:" << Vzs; } } void SatelliteGF3xmlParser::parseGPS() { - QDomElement GPS = xml.firstChildElement("root").firstChildElement("GPS"); + QDomElement GPS = xml.firstChildElement("product").firstChildElement("GPS"); if (!GPS.isNull()) { QDomNodeList GPSParams = GPS.elementsByTagName("GPSParam"); for (int i = 0; i < GPSParams.count(); ++i) { @@ -69,37 +86,52 @@ void SatelliteGF3xmlParser::parseGPS() { 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(); + + TimestampMicroseconds dateTime = parseAndConvert(TimeStamp.toStdString()); + satepos.time = dateTime.msecsSinceEpoch / 1000.0 + dateTime.microseconds / 100000.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; + qDebug() << u8"\nGPS Param Data:"; + qDebug() << u8"TimeStamp:" << TimeStamp; + qDebug() << u8"xPosition:" << xPosition; + qDebug() << u8"yPosition:" << yPosition; + qDebug() << u8"zPosition:" << zPosition; + qDebug() << u8"xVelocity:" << xVelocity; + qDebug() << u8"yVelocity:" << yVelocity; + qDebug() << u8"zVelocity:" << zVelocity; } } } void SatelliteGF3xmlParser::parseImageInfo() { - QDomElement imageinfo = xml.firstChildElement("root").firstChildElement("imageinfo"); + QDomElement imageinfo = xml.firstChildElement("product").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; - + + QString starttimestr = imagingTime.firstChildElement("start").text().trimmed(); + QString endtimestr = imagingTime.firstChildElement("end").text().trimmed(); + + TimestampMicroseconds starttime = parseAndConvert(starttimestr.toStdString()); + TimestampMicroseconds endtime = parseAndConvert(endtimestr.toStdString()); + + start = starttime.msecsSinceEpoch / 1000.0 + starttime.microseconds / 100000.0; + end = endtime.msecsSinceEpoch / 1000.0 + endtime.microseconds / 100000.0; + + // ӡstarttime,endtime + qDebug() << u8"ʼʱ(parse)" << starttime.msecsSinceEpoch << "\t" << starttime.microseconds; + qDebug() << u8"ʱ(parse)" << endtime.msecsSinceEpoch << "\t" << endtime.microseconds; + + qDebug() << u8"ʼʱ䣺" << start <<"\t"<< starttimestr; + qDebug() << u8"ʱ䣺" << end << "\t" << endtimestr; + + nearRange = imageinfo.firstChildElement("nearRange").text().toDouble(); refRange = imageinfo.firstChildElement("refRange").text().toDouble(); eqvFs = imageinfo.firstChildElement("eqvFs").text().toDouble(); @@ -154,35 +186,36 @@ void SatelliteGF3xmlParser::parseImageInfo() { 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; + qDebug() << u8"\nImage Info Data:"; + qDebug() << u8"Start:" << start; + qDebug() << u8"End:" << end; + qDebug() << u8"Near Range:" << nearRange; + qDebug() << u8"Ref Range:" << refRange; + qDebug() << u8"Eqv Fs:" << eqvFs; + qDebug() << u8"Eqv PRF:" << eqvPRF; + qDebug() << u8"Center Latitude:" << latitude_center << ", Longitude:" << longitude_center; + qDebug() << u8"Top Left Corner Latitude:" << latitude_topLeft << ", Longitude:" << longitude_topLeft; + qDebug() << u8"Top Right Corner Latitude:" << latitude_topRight << ", Longitude:" << longitude_topRight; + qDebug() << u8"Bottom Left Corner Latitude:" << latitude_bottomLeft << ", Longitude:" << longitude_bottomLeft; + qDebug() << u8"Bottom Right Corner Latitude:" << latitude_bottomRight << ", Longitude:" << longitude_bottomRight; + qDebug() << u8"Width:" << width; + qDebug() << u8"Height:" << height; + qDebug() << u8"Width Space:" << widthspace; + qDebug() << u8"Height Space:" << heightspace; + qDebug() << u8"Scene Shift:" << sceneShift; + qDebug() << u8"Image Bit:" << imagebit; + qDebug() << u8"HH Qualify Value:" << HH_QualifyValue; + qDebug() << u8"HV Qualify Value:" << HV_QualifyValue; + qDebug() << u8"HH Echo Saturation:" << HH_echoSaturation; + qDebug() << u8"HV Echo Saturation:" << HV_echoSaturation; + qDebug() << u8"incidenceAngleNearRange:" << incidenceAngleNearRange; + qDebug() << u8"incidenceAngleFarRange:" << incidenceAngleFarRange; } } void SatelliteGF3xmlParser::parseAdditionalData() { - QDomElement calibrationConst = xml.firstChildElement("root").firstChildElement("CalibrationConst"); + QDomElement processinfo = xml.firstChildElement("product").firstChildElement("processinfo"); + QDomElement calibrationConst = processinfo.firstChildElement("CalibrationConst"); if (!calibrationConst.isNull()) { bool HH_CalibrationConstISNULL=false; @@ -201,50 +234,50 @@ void SatelliteGF3xmlParser::parseAdditionalData() { - 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; + qDebug() << u8"\nCalibration Const Data:"; + qDebug() << u8"HH Calibration Const:" << HH_CalibrationConst; + qDebug() << u8"HV Calibration Const:" << HV_CalibrationConst; + qDebug() << u8"VH Calibration Const:" << VH_CalibrationConst; + qDebug() << u8"VV Calibration Const:" << VV_CalibrationConst; } - AzFdc0 = xml.firstChildElement("root").firstChildElement("AzFdc0").text().toDouble(); - AzFdc1 = xml.firstChildElement("root").firstChildElement("AzFdc1").text().toDouble(); + AzFdc0 = processinfo.firstChildElement("AzFdc0").text().toDouble(); + AzFdc1 = processinfo.firstChildElement("AzFdc1").text().toDouble(); + QDomElement sensorNode = xml.firstChildElement("product").firstChildElement("sensor"); + sensorID = sensorNode.firstChildElement("sensorID").text(); + imagingMode = sensorNode.firstChildElement("imagingMode").text(); + lamda = sensorNode.firstChildElement("lamda").text().toDouble(); + RadarCenterFrequency = sensorNode.firstChildElement("RadarCenterFrequency").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 = processinfo.firstChildElement("TotalProcessedAzimuthBandWidth").text().toDouble(); + DopplerParametersReferenceTime = processinfo.firstChildElement("DopplerParametersReferenceTime").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"); + QDomElement dopplerCentroidCoefficients = processinfo.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"); + QDomElement dopplerRateValuesCoefficients = processinfo.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(); + DEM = processinfo.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; + qDebug() << u8"\nAdditional Data:"; + qDebug() << u8"AzFdc0:" << AzFdc0; + qDebug() << u8"AzFdc1:" << AzFdc1; + qDebug() << u8"Sensor ID:" << sensorID; + qDebug() << u8"Imaging Mode:" << imagingMode; + qDebug() << u8"Lambda:" << lamda; + qDebug() << u8"Radar Center Frequency:" << RadarCenterFrequency; + qDebug() << u8"Total Processed Azimuth Band Width:" << TotalProcessedAzimuthBandWidth; + qDebug() << u8"Doppler Parameters Reference Time:" << DopplerParametersReferenceTime; + qDebug() << u8"Doppler Centroid Coefficients: d0=" << d0 << ", d1=" << d1 << ", d2=" << d2 << ", d3=" << d3 << ", d4=" << d4; + qDebug() << u8"Doppler Rate Values Coefficients: r0=" << r0 << ", r1=" << r1 << ", r2=" << r2 << ", r3=" << r3 << ", r4=" << r4; + qDebug() << u8"DEM:" << DEM; }