diff --git a/BaseCommonLibrary/BaseCommonLibrary.vcxproj b/BaseCommonLibrary/BaseCommonLibrary.vcxproj
index d7c78f9..002db1e 100644
--- a/BaseCommonLibrary/BaseCommonLibrary.vcxproj
+++ b/BaseCommonLibrary/BaseCommonLibrary.vcxproj
@@ -220,11 +220,13 @@
pch.h
true
true
- NotSet
+ NoExtensions
true
stdcpp14
stdc11
true
+ false
+ MaxSpeed
Windows
diff --git a/BaseCommonLibrary/BaseTool/BaseConstVariable.h b/BaseCommonLibrary/BaseTool/BaseConstVariable.h
index f16210d..67114db 100644
--- a/BaseCommonLibrary/BaseTool/BaseConstVariable.h
+++ b/BaseCommonLibrary/BaseTool/BaseConstVariable.h
@@ -15,6 +15,9 @@
+/** 定义常见文件格式*********/
+#define ENVI_FILE_FORMAT_FILTER u8"ALL File(*.*);;ENVI Bin(*.bin);;ENVI Data(*.dat);;ENVI Data(*.data);;tiff影像(*.tif);;tiff影像(*.tiff)"
+#define XML_FILE_FORMAT_FILTER u8"ALL File(*.*);;XML File(*.xml);;tiff影像(*.tiff)"
//
@@ -136,6 +139,14 @@ struct Point3 {
void setZ(double iz) { z = iz; }
};
+struct Point_3d {
+ double x;
+ double y;
+ double z;
+};
+
+
+
struct DemBox {
double min_lon;
double max_lon;
@@ -154,7 +165,7 @@ struct Vector3_single {
/*********************************************** FEKO仿真参数 ********************************************************************/
-struct SatellitePos {
+extern "C" struct SatellitePos {
double time;
double Px ;
double Py ;
@@ -165,7 +176,7 @@ struct SatellitePos {
};
-struct SatelliteAntPos {
+extern "C" struct SatelliteAntPos {
double time; // 0
double Px;
double Py;
@@ -188,7 +199,7 @@ struct SatelliteAntPos {
};
-struct PatternImageDesc {
+extern "C" struct PatternImageDesc {
long phinum;
long thetanum;
double startTheta;
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/FileOperator.h b/BaseCommonLibrary/BaseTool/FileOperator.h
index 72d542a..b016ede 100644
--- a/BaseCommonLibrary/BaseTool/FileOperator.h
+++ b/BaseCommonLibrary/BaseTool/FileOperator.h
@@ -16,7 +16,7 @@
#include
#include
#include
-
+
bool BASECONSTVARIABLEAPI isDirectory(const QString& path);
bool BASECONSTVARIABLEAPI isExists(const QString& path);
@@ -29,7 +29,7 @@ unsigned long BASECONSTVARIABLEAPI convertToULong(const QString& input);
///
///
///
-std::vector BASECONSTVARIABLEAPI getFilelist(const QString& folderpath, const QString& FilenameExtension = ".*",int (*logfun)(QString logtext,int value)=nullptr);
+std::vector BASECONSTVARIABLEAPI getFilelist(const QString& folderpath, const QString& FilenameExtension = ".*", int (*logfun)(QString logtext, int value) = nullptr);
QString BASECONSTVARIABLEAPI getParantFolderNameFromPath(const QString& path);
@@ -41,11 +41,11 @@ QString BASECONSTVARIABLEAPI getFileExtension(QString path);
int BASECONSTVARIABLEAPI write_binfile(char* filepath, char* data, size_t data_len);
-char* read_textfile(char* text_path, int* length);
+char* read_textfile(char* text_path, int* length);
-bool BASECONSTVARIABLEAPI exists_test(const QString& name);
+bool BASECONSTVARIABLEAPI exists_test(const QString& name);
-size_t BASECONSTVARIABLEAPI fsize(FILE* fp);
+size_t BASECONSTVARIABLEAPI fsize(FILE* fp);
QString BASECONSTVARIABLEAPI getParantFromPath(const QString& path);
void BASECONSTVARIABLEAPI copyFile(const QString& sourcePath, const QString& destinationPath);
diff --git a/BaseCommonLibrary/BaseTool/GeoOperator.cpp b/BaseCommonLibrary/BaseTool/GeoOperator.cpp
index 9784c3a..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)
@@ -135,6 +137,44 @@ Landpoint XYZ2LLA(const Landpoint& XYZ) {
+void XYZ2BLH_FixedHeight(double x, double y, double z,double ati, Landpoint& point) {
+ const double a = 6378137.0; // WGS84
+ const double f = 1.0 / 298.257223563;
+ const double e2 = 2 * f - f * f; // һƫƽ
+
+ // 㾭L ()
+ const double L_rad = std::atan2(y, x);
+ point.lon = L_rad * 180.0 / M_PI; // תΪ
+
+ const double p = std::sqrt(x * x + y * y);
+ const double H = ati; // ʹ֪߶
+
+ // ʼγȹ㣨֪߶H
+ double B_rad = std::atan2(z, p * (1 - e2 * (a / (a + H))));
+
+ // γB̶H
+ for (int i = 0; i < 10; ++i) { // ֪Hʱ
+ const double sin_B = std::sin(B_rad);
+ const double N = a / std::sqrt(1 - e2 * sin_B * sin_B);
+ const double delta = e2 * N / (N + H); // ߶ȹ̶ʱ
+
+ const double B_new = std::atan2(z, p * (1 - delta));
+
+ if (std::abs(B_new - B_rad) < 1e-9) {
+ B_rad = B_new;
+ break;
+ }
+ B_rad = B_new;
+ }
+
+ point.lat = B_rad * 180.0 / M_PI; // ת
+
+ // ȷΧ [-180, 180]
+ point.lon = std::fmod(point.lon + 360.0, 360.0);
+ if (point.lon > 180.0) point.lon -= 360.0;
+ point.ati = ati;
+}
+
double getAngle(const Landpoint& a, const Landpoint& b)
{
@@ -408,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 6d4eb8a..66ce525 100644
--- a/BaseCommonLibrary/BaseTool/GeoOperator.h
+++ b/BaseCommonLibrary/BaseTool/GeoOperator.h
@@ -30,6 +30,7 @@ Eigen::MatrixXd BASECONSTVARIABLEAPI LLA2XYZ(Eigen::MatrixXd landpoint);
/// 经纬度--degree
Landpoint BASECONSTVARIABLEAPI XYZ2LLA(const Landpoint& XYZ);
+void BASECONSTVARIABLEAPI XYZ2BLH_FixedHeight(double x, double y, double z, double ati, Landpoint& point);
Landpoint BASECONSTVARIABLEAPI operator +(const Landpoint& p1, const Landpoint& p2);
@@ -123,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 060df9a..b16127d 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);
@@ -135,10 +135,10 @@ GDALDataType BASECONSTVARIABLEAPI getGDALDataType(QString fileptah);
struct RasterExtend {
- double min_x; //纬度
- double min_y;//经度
- double max_x;//纬度
- double max_y;//经度
+ double min_x;
+ double min_y;
+ double max_x;
+ double max_y;
};
@@ -174,8 +174,6 @@ public: // 方法
virtual void saveImage(std::shared_ptr, int start_row, int start_col, int rowcount, int colcount, int band_ids);
virtual void saveImage(std::shared_ptr, int start_row, int start_col, int rowcount, int colcount, int band_ids);
-
-
virtual void saveImage();
virtual void setNoDataValue(double nodatavalue, int band_ids);
virtual void setNoDataValuei(int nodatavalue, int band_ids);
@@ -197,6 +195,10 @@ public: // 方法
virtual RasterExtend getExtend();
+
+
+
+
public:
QString img_path; // 图像文件
int height; // 高
@@ -236,6 +238,10 @@ public:
Eigen::MatrixXcd data;
};
+
+bool BASECONSTVARIABLEAPI CopyProjectTransformMatrixFromRasterAToRasterB(QString RasterAPath, QString RasterBPath);
+
+
// 创建影像
gdalImage BASECONSTVARIABLEAPI CreategdalImageDouble(QString& img_path, int height, int width, int band_num, bool overwrite = false, bool isEnvi = false);
gdalImage BASECONSTVARIABLEAPI CreategdalImageFloat(QString& img_path, int height, int width, int band_num, bool overwrite = false, bool isEnvi = false);
@@ -310,6 +316,24 @@ void BASECONSTVARIABLEAPI testOutDataArr(QString filename, long* data, long row
void BASECONSTVARIABLEAPI CreateSARIntensityByLookTable(QString IntensityRasterPath, QString LookTableRasterPath, QString SARIntensityPath, long min_rid, long max_rid, long min_cid, long max_cid, std::function processBarShow = {});
+bool BASECONSTVARIABLEAPI ConvertVrtToEnvi(QString vrtPath, QString outPath);
+
+
+
+
+void BASECONSTVARIABLEAPI MultiLookRaster(QString inRasterPath, QString outRasterPath, long looklineNumrow, long looklineNumCol);
+ErrorCode BASECONSTVARIABLEAPI Complex2PhaseRaster(QString inComplexPath, QString outRasterPath);
+ErrorCode BASECONSTVARIABLEAPI Complex2dBRaster(QString inComplexPath, QString outRasterPath);
+ErrorCode BASECONSTVARIABLEAPI Complex2AmpRaster(QString inComplexPath, QString outRasterPath);
+ErrorCode BASECONSTVARIABLEAPI amp2dBRaster(QString inPath, QString outRasterPath);
+
+
+ErrorCode BASECONSTVARIABLEAPI ResampleDEM(QString indemPath, QString outdemPath, double gridx, double gridy);
+
+
+void BASECONSTVARIABLEAPI CloseAllGDALRaster();
+
+
//--------------------- 图像文件读写 ------------------------------
diff --git a/BaseCommonLibrary/BaseTool/RasterToolBase.cpp b/BaseCommonLibrary/BaseTool/RasterToolBase.cpp
index 32711fb..5debe6f 100644
--- a/BaseCommonLibrary/BaseTool/RasterToolBase.cpp
+++ b/BaseCommonLibrary/BaseTool/RasterToolBase.cpp
@@ -15,6 +15,8 @@
#include
#include
#include
+#include "SARSimulationImageL1.h"
+#include
namespace RasterToolBase {
long getProjectEPSGCodeByLon_Lat(double lon, double lat, ProjectStripDelta stripState)
@@ -268,4 +270,7 @@ namespace RasterToolBase {
return CoordinateSystemType::UNKNOW;
}
}
-} // namespace RasterToolBase
\ No newline at end of file
+}; // namespace RasterToolBase
+
+
+
diff --git a/BaseCommonLibrary/BaseTool/RasterToolBase.h b/BaseCommonLibrary/BaseTool/RasterToolBase.h
index bc6842f..254d4bb 100644
--- a/BaseCommonLibrary/BaseTool/RasterToolBase.h
+++ b/BaseCommonLibrary/BaseTool/RasterToolBase.h
@@ -12,40 +12,42 @@
#include "BaseConstVariable.h"
#include "gdal_priv.h"
#include
+#include "LogInfoCls.h"
+
namespace RasterToolBase {
- static bool GDALAllRegisterEnable=false;
+ static bool GDALAllRegisterEnable = false;
- enum ProjectStripDelta{
+ enum ProjectStripDelta {
Strip_6, // 6度带
Strip_3
};
- enum CoordinateSystemType{ // 坐标系类型
+ enum CoordinateSystemType { // 坐标系类型
GeoCoordinateSystem,
ProjectCoordinateSystem,
UNKNOW
};
- struct PointRaster{ // 影像坐标点
+ struct PointRaster { // 影像坐标点
double x;
double y;
double z;
};
- struct PointXYZ{
- double x,y,z;
+ struct PointXYZ {
+ double x, y, z;
};
- struct PointGeo{
- double lon,lat,ati;
+ struct PointGeo {
+ double lon, lat, ati;
};
- struct PointImage{
- double pixel_x,pixel_y;
+ struct PointImage {
+ double pixel_x, pixel_y;
};
/// 根据经纬度获取
@@ -56,14 +58,14 @@ namespace RasterToolBase {
/// \param lat 纬度
/// \return 对应投影坐标系统的 EPSG编码,-1 表示计算错误
long BASECONSTVARIABLEAPI getProjectEPSGCodeByLon_Lat(double long, double lat,
- ProjectStripDelta stripState = ProjectStripDelta::Strip_3);
+ ProjectStripDelta stripState = ProjectStripDelta::Strip_3);
long BASECONSTVARIABLEAPI getProjectEPSGCodeByLon_Lat_inStrip3(double lon, double lat);
long BASECONSTVARIABLEAPI getProjectEPSGCodeByLon_Lat_inStrip6(double lon, double lat);
- QString BASECONSTVARIABLEAPI GetProjectionNameFromEPSG(long epsgCode) ;
+ QString BASECONSTVARIABLEAPI GetProjectionNameFromEPSG(long epsgCode);
long BASECONSTVARIABLEAPI GetEPSGFromRasterFile(QString filepath);
@@ -72,9 +74,23 @@ namespace RasterToolBase {
CoordinateSystemType BASECONSTVARIABLEAPI getCoordinateSystemTypeByEPSGCode(long EPSGCODE);
+};// namespace RasterProjectConvertor
+
+
+
+
+// 遥感类常用数据
+
+
+
+
+
+
+
+
+
-} // namespace RasterProjectConvertor
#endif // LAMPCAE_RASTERTOOLBASE_H
diff --git a/BaseCommonLibrary/BaseTool/SARSimulationImageL1.cpp b/BaseCommonLibrary/BaseTool/SARSimulationImageL1.cpp
index 16134d2..2fbfbb8 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,13 @@ 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("PRF", QString::number(this->prf, 'e', 18));
+ xmlWriter.writeTextElement("CenterAngle", QString::number(this->CenterAngle, 'e', 18));
xmlWriter.writeTextElement("LookSide", this->LookSide);
// sateantpos
@@ -259,60 +260,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();
@@ -371,6 +372,9 @@ ErrorCode SARSimulationImageL1Dataset::loadFromXml()
else if (xmlReader.name() == "Fs") {
this->Fs = xmlReader.readElementText().toDouble();
}
+ else if (xmlReader.name() == "PRF") {
+ this->prf = xmlReader.readElementText().toDouble();
+ }
else if(xmlReader.name() == "ImageStartTime"){
this->startImageTime = xmlReader.readElementText().toDouble();
}
@@ -873,6 +877,7 @@ QVector SARSimulationImageL1Dataset::getDopplerParams()
result[2] = d2;
result[3] = d3;
result[4] = d4;
+
return result;
}
@@ -888,11 +893,13 @@ void SARSimulationImageL1Dataset::setDopplerParams(double id0, double id1, doubl
QVector SARSimulationImageL1Dataset::getDopplerCenterCoff()
{
QVector result(5);
- result[0]=r0;
- result[1]=r1;
- result[2]=r2;
- result[3]=r3;
- result[4]=r4;
+ result[0] = r0;
+ result[1] = r1;
+ result[2] = r2;
+ result[3] = r3;
+ result[4] = r4;
+
+
return result;
}
diff --git a/BaseCommonLibrary/BaseTool/SARSimulationImageL1.h b/BaseCommonLibrary/BaseTool/SARSimulationImageL1.h
index c2abecf..6d8325a 100644
--- a/BaseCommonLibrary/BaseTool/SARSimulationImageL1.h
+++ b/BaseCommonLibrary/BaseTool/SARSimulationImageL1.h
@@ -143,9 +143,11 @@ public:
double getDopplerParametersReferenceTime();
void setDopplerParametersReferenceTime(double v);
+ // ղ
QVector getDopplerParams();
void setDopplerParams(double d0, double d1, double d2, double d3, double d4);
+ // ϵ
QVector getDopplerCenterCoff();
void setDopplerCenterCoff(double r0, double r1, double r2, double r3, double r4);
@@ -208,3 +210,9 @@ private:
};
+
+
+
+
+
+
diff --git a/BaseCommonLibrary/BaseTool/gdalImageComplexOperator.cpp b/BaseCommonLibrary/BaseTool/gdalImageComplexOperator.cpp
index bc8a0a9..7d0df86 100644
--- a/BaseCommonLibrary/BaseTool/gdalImageComplexOperator.cpp
+++ b/BaseCommonLibrary/BaseTool/gdalImageComplexOperator.cpp
@@ -121,20 +121,48 @@ void gdalImageComplex::saveImage(Eigen::MatrixXcd data, int start_row, int start
int datarows = data.rows();
int datacols = data.cols();
- double* databuffer = new double[data.size() * 2];
- for (int i = 0; i < data.rows(); i++) {
- for (int j = 0; j < data.cols(); j++) {
- databuffer[i * data.cols() * 2 + j * 2] = data(i, j).real();
- databuffer[i * data.cols() * 2 + j * 2 + 1] = data(i, j).imag();
+ if (this->getDataType() == GDT_CFloat64)
+ {
+
+ double* databuffer = new double[data.size() * 2];
+ for (int i = 0; i < data.rows(); i++) {
+ for (int j = 0; j < data.cols(); j++) {
+ databuffer[i * data.cols() * 2 + j * 2] = data(i, j).real();
+ databuffer[i * data.cols() * 2 + j * 2 + 1] = data(i, j).imag();
+ }
}
+
+ // poDstDS->RasterIO(GF_Write,start_col, start_row, datacols, datarows, databuffer, datacols,
+ // datarows, GDT_Float32,band_ids, num,0,0,0);
+ poDstDS->GetRasterBand(band_ids)->RasterIO(GF_Write, start_col, start_row, datacols, datarows,
+ databuffer, datacols, datarows, GDT_CFloat64, 0, 0);
+ GDALFlushCache(poDstDS);
+ delete databuffer;
+
+ }
+ else if (this->getDataType() == GDT_CFloat32) {
+
+ float* databuffer = new float[data.size() * 2];
+ for (int i = 0; i < data.rows(); i++) {
+ for (int j = 0; j < data.cols(); j++) {
+ databuffer[i * data.cols() * 2 + j * 2] = float(data(i, j).real());
+ databuffer[i * data.cols() * 2 + j * 2 + 1] =float( data(i, j).imag());
+ }
+ }
+
+ // poDstDS->RasterIO(GF_Write,start_col, start_row, datacols, datarows, databuffer, datacols,
+ // datarows, GDT_Float32,band_ids, num,0,0,0);
+ poDstDS->GetRasterBand(band_ids)->RasterIO(GF_Write, start_col, start_row, datacols, datarows,
+ databuffer, datacols, datarows, GDT_CFloat32, 0, 0);
+ GDALFlushCache(poDstDS);
+ delete databuffer;
+ }
+ else {
+ throw std::exception("gdalImageComplex::saveImage: data type error");
}
- // poDstDS->RasterIO(GF_Write,start_col, start_row, datacols, datarows, databuffer, datacols,
- // datarows, GDT_Float32,band_ids, num,0,0,0);
- poDstDS->GetRasterBand(band_ids)->RasterIO(GF_Write, start_col, start_row, datacols, datarows,
- databuffer, datacols, datarows, GDT_CFloat64, 0, 0);
- GDALFlushCache(poDstDS);
- delete databuffer;
+
+
GDALClose((GDALDatasetH)poDstDS);
GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
omp_unset_lock(&lock); //
@@ -265,24 +293,46 @@ Eigen::MatrixXcd gdalImageComplex::getDataComplex(int start_row, int start_col,
// ȡݼĵһ
GDALRasterBand* poBand;
poBand = poDataset->GetRasterBand(1);
-
+ rows_count = start_row + rows_count <= this->height ? rows_count : this->height - start_row;
+ cols_count = start_col + cols_count <= this->width ? cols_count : this->width - start_col;
// ȡϢǸ
int nXSize = cols_count; poBand->GetXSize();
int nYSize = rows_count; poBand->GetYSize();
-
- double* databuffer = new double[nXSize * nYSize * 2];
- poBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, databuffer, cols_count,
- rows_count, GDT_CFloat64, 0, 0);
- GDALClose((GDALDatasetH)poDataset);
Eigen::MatrixXcd rasterData(nYSize, nXSize); // ʹEigenMatrixXcd
- for (size_t i = 0; i < nYSize; i++) {
- for (size_t j = 0; j < nXSize; j++) {
- rasterData(i, j) = std::complex(databuffer[i * nXSize * 2 + j * 2],
- databuffer[i * nXSize * 2 + j * 2 + 1]);
+ if (this->getDataType() == GDT_CFloat64)
+ {
+ long long pixelCount =long long( nXSize) *long long( nYSize);
+ double* databuffer = new double[pixelCount * 2];
+ poBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, databuffer, cols_count, rows_count, GDT_CFloat64, 0, 0);
+ GDALClose((GDALDatasetH)poDataset);
+
+ for (long long i = 0; i < nYSize; i++) {
+ for (long long j = 0; j < nXSize; j++) {
+ rasterData(i, j) = std::complex(databuffer[i * nXSize * 2 + j * 2],
+ databuffer[i * nXSize * 2 + j * 2 + 1]);
+ }
}
+
+ delete[] databuffer;
+ }
+ else if(this->getDataType()==GDT_CFloat32)
+ {
+ long long pixelCount = long long(nXSize) * long long(nYSize);
+ float* databuffer = new float[pixelCount * 2];
+ poBand->RasterIO(GF_Read, start_col, start_row, cols_count, rows_count, databuffer, cols_count, rows_count, GDT_CFloat32, 0, 0);
+ GDALClose((GDALDatasetH)poDataset);
+
+ for (long long i = 0; i < nYSize; i++) {
+ for (long long j = 0; j < nXSize; j++) {
+ rasterData(i, j) = std::complex(databuffer[i * nXSize * 2 + j * 2],
+ databuffer[i * nXSize * 2 + j * 2 + 1]);
+ }
+ }
+
+ delete[] databuffer;
}
- delete[] databuffer;
+
return rasterData;
}
diff --git a/BaseCommonLibrary/BaseTool/gdalImageOperator.cpp b/BaseCommonLibrary/BaseTool/gdalImageOperator.cpp
index bce0668..9fe8bfd 100644
--- a/BaseCommonLibrary/BaseTool/gdalImageOperator.cpp
+++ b/BaseCommonLibrary/BaseTool/gdalImageOperator.cpp
@@ -1228,8 +1228,8 @@ RasterExtend gdalImage::getExtend()
double x1 = this->gt(0, 0);
double y1 = this->gt(1, 0);
- double x2 = this->gt(0, 0) + (this->width - 1) * gt(0, 1) + (0) * gt(0, 2);
- double y2 = this->gt(1, 0) + (this->width - 1) * gt(1, 1) + (0) * gt(1, 2);
+ double x2 = this->gt(0, 0) + (this->width - 1) * gt(0, 1) + (0) * gt(0, 2); //
+ double y2 = this->gt(1, 0) + (this->width - 1) * gt(1, 1) + (0) * gt(1, 2); // γ
double x3 = this->gt(0, 0) + (0) * gt(0, 1) + (this->height - 1) * gt(0, 2);
double y3 = this->gt(1, 0) + (0) * gt(1, 1) + (this->height - 1) * gt(1, 2);
@@ -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());
@@ -1470,6 +1479,51 @@ gdalImage CreategdalImage(const QString& img_path, int height, int width, int ba
}
+bool CopyProjectTransformMatrixFromRasterAToRasterB(QString RasterAPath, QString RasterBPath) {
+ // עGDAL
+ GDALAllRegister();
+
+ // ӰAֻģʽ
+ GDALDataset* ds_a = (GDALDataset*)GDALOpen(RasterAPath.toUtf8().constData(), GA_ReadOnly);
+ if (ds_a == nullptr) {
+ std::cerr << "ӰA" << std::endl;
+ return false;
+ }
+
+ // ȡAķͶӰϢ
+ double geotransform[6];
+ ds_a->GetGeoTransform(geotransform); // 任
+ const char* projection = ds_a->GetProjectionRef(); // WKTʽͶӰ
+
+ // ӰBģʽ
+ GDALDataset* ds_b = (GDALDataset*)GDALOpen(RasterBPath.toUtf8().constData(), GA_Update);
+ if (ds_b == nullptr) {
+ std::cerr << "ӰB" << std::endl;
+ GDALClose(ds_a);
+ return false;
+ }
+
+ // ÷
+ if (ds_b->SetGeoTransform(geotransform) != CE_None) {
+ std::cerr << "÷ʧ" << std::endl;
+ }
+
+ // ͶӰϵ
+ if (ds_b->SetProjection(projection) != CE_None) {
+ std::cerr << "ͶӰʧ" << std::endl;
+ }
+
+ // ͷԴ
+ GDALClose(ds_a);
+ GDALClose(ds_b);
+
+ return true;
+
+
+
+
+
+}
diff --git a/BaseCommonLibrary/ImageOperatorFuntion.cpp b/BaseCommonLibrary/ImageOperatorFuntion.cpp
index 67c620a..ee94390 100644
--- a/BaseCommonLibrary/ImageOperatorFuntion.cpp
+++ b/BaseCommonLibrary/ImageOperatorFuntion.cpp
@@ -1,4 +1,4 @@
-#include "stdafx.h"
+#include "stdafx.h"
#include "ImageOperatorBase.h"
#include "BaseTool.h"
#include "GeoOperator.h"
@@ -25,8 +25,12 @@
#include
#include
#include
-#include // OGRSpatialReference ڿռοת
-#include // GDALWarp
+#include // OGRSpatialReference 用于空间参考转换
+#include // 用于 GDALWarp 操作
+
+#include "gdal_priv.h"
+#include "cpl_conv.h"
+#include
std::shared_ptr OpenDataset(const QString& in_path, GDALAccess rwmode)
@@ -105,13 +109,13 @@ GDALDataType getGDALDataType(QString fileptah)
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
GDALDataset* rasterDataset = (GDALDataset*)(GDALOpen(
- fileptah.toUtf8().constData(), GA_ReadOnly)); // ��ֻ�ʽ��ȡ�Ӱ��
+ fileptah.toUtf8().constData(), GA_ReadOnly)); // 锟斤拷只斤拷式锟斤拷取斤拷影锟斤拷
GDALDataType gdal_datatype = rasterDataset->GetRasterBand(1)->GetRasterDataType();
GDALClose((GDALDatasetH)rasterDataset);
- omp_unset_lock(&lock); // �ͷŻ��
- omp_destroy_lock(&lock); // ٻ��
+ omp_unset_lock(&lock); // 锟酵放伙拷斤拷
+ omp_destroy_lock(&lock); // 劫伙拷斤拷
return gdal_datatype;
}
@@ -124,14 +128,14 @@ GDALDataType getGDALDataType(QString fileptah)
int block_num_pre_memory(int block_width, int height, GDALDataType gdal_datatype, double memey_size)
{
- // С
+ // 计算大小
int size_meta = 0;
if (gdal_datatype == GDT_Byte) {
size_meta = 1;
}
else if (gdal_datatype == GDT_UInt16) {
- size_meta = 2; // ֻ˫ܹͨ
+ size_meta = 2; // 只有双通道才能构建 复数矩阵
}
else if (gdal_datatype == GDT_UInt16) {
size_meta = 2;
@@ -172,7 +176,7 @@ int block_num_pre_memory(int block_width, int height, GDALDataType gdal_datatype
else {
}
int block_num = int(memey_size / (size_meta * block_width));
- block_num = block_num > height ? height : block_num; //
+ block_num = block_num > height ? height : block_num; // 行数
block_num = block_num < 1 ? 1 : block_num;
return block_num;
}
@@ -203,84 +207,85 @@ int ENVI2TIFF(QString in_envi_path, QString out_tiff_path)
void ConvertCoordinateSystem(QString inRasterPath, QString outRasterPath, long outepsgcode) {
- // עGDAL
+ // 注册所有GDAL驱动
GDALAllRegister();
+ CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
- // դļ
+ // 打开输入栅格文件
GDALDataset* srcDataset = (GDALDataset*)GDALOpen(inRasterPath.toUtf8().constData(), GA_ReadOnly);
if (!srcDataset) {
- // ļʧ
- // qDebug() << "ļ" << inRasterPath;
+ // 错误处理:输出文件打开失败
+ // qDebug() << "无法打开输入文件:" << inRasterPath;
return;
}
- // Ŀϵ
+ // 创建目标坐标系
OGRSpatialReference targetSRS;
if (targetSRS.importFromEPSG(outepsgcode) != OGRERR_NONE) {
GDALClose(srcDataset);
- // qDebug() << "ЧEPSG룺" << outepsgcode;
+ // qDebug() << "无效的EPSG代码:" << outepsgcode;
return;
}
GDALDataType datetype = srcDataset->GetRasterBand(1)->GetRasterDataType();
- // ȡĿϵWKTʾ
+ // 获取目标坐标系的WKT表示
char* targetSRSWkt = nullptr;
targetSRS.exportToWkt(&targetSRSWkt);
bool flag = (datetype == GDT_Byte || datetype == GDT_Int8 || datetype == GDT_Int16 || datetype == GDT_UInt16 || datetype == GDT_Int32 || datetype == GDT_UInt32 || datetype == GDT_Int64 || datetype == GDT_UInt64);
- // ͶӰݼWarped VRT
+ // 创建重投影后的虚拟数据集(Warped VRT)
GDALDataset* warpedVRT = flag ? (GDALDataset*)GDALAutoCreateWarpedVRT(
srcDataset,
- nullptr, // ϵĬʹԴݣ
- targetSRSWkt, // Ŀϵ
- GRA_NearestNeighbour, // ز˫Բֵ
- 0.0, // 0ʾԶ㣩
- nullptr // ѡ
+ nullptr, // 输入坐标系(默认使用源数据)
+ targetSRSWkt, // 目标坐标系
+ GRA_NearestNeighbour, // 重采样方法:双线性插值
+ 0.0, // 最大误差(0表示自动计算)
+ nullptr // 其他选项
) : (GDALDataset*)GDALAutoCreateWarpedVRT(
srcDataset,
- nullptr, // ϵĬʹԴݣ
- targetSRSWkt, // Ŀϵ
- GRA_Bilinear, // ز˫Բֵ
- 0.0, // 0ʾԶ㣩
- nullptr // ѡ
+ nullptr, // 输入坐标系(默认使用源数据)
+ targetSRSWkt, // 目标坐标系
+ GRA_Bilinear, // 重采样方法:双线性插值
+ 0.0, // 最大误差(0表示自动计算)
+ nullptr // 其他选项
);
- CPLFree(targetSRSWkt); // ͷWKTڴ
+ CPLFree(targetSRSWkt); // 释放WKT内存
if (!warpedVRT) {
GDALClose(srcDataset);
- qDebug() << u8"ͶӰתVRTʧ";
+ qDebug() << u8"创建投影转换VRT失败";
return;
}
- // ȡGeoTIFFʽ
+ // 获取输出驱动(GeoTIFF格式)
QString filesuffer = getFileExtension(outRasterPath).toLower();
bool isTiff = filesuffer.contains("tif");
GDALDriver* driver = isTiff ? GetGDALDriverManager()->GetDriverByName("GTiff") : GetGDALDriverManager()->GetDriverByName("ENVI");
if (!driver) {
GDALClose(warpedVRT);
GDALClose(srcDataset);
- // qDebug() << "ȡGeoTIFF";
+ // qDebug() << "无法获取GeoTIFF驱动";
return;
}
- // դļ
+ // 创建输出栅格文件
GDALDataset* dstDataset = driver->CreateCopy(
- outRasterPath.toUtf8().constData(), // ļ·
- warpedVRT, // ݼVRT
- false, // Ƿϸ
- nullptr, // ѡ
- nullptr, // Ȼص
- nullptr // ص
+ outRasterPath.toUtf8().constData(), // 输出文件路径
+ warpedVRT, // 输入数据集(VRT)
+ false, // 是否严格复制
+ nullptr, // 创建选项
+ nullptr, // 进度回调
+ nullptr // 回调参数
);
if (!dstDataset) {
- // qDebug() << "ļʧܣ" << outRasterPath;
+ // qDebug() << "创建输出文件失败:" << outRasterPath;
GDALClose(warpedVRT);
GDALClose(srcDataset);
return;
}
- // ͷԴ
+ // 释放资源
GDALClose(dstDataset);
GDALClose(warpedVRT);
GDALClose(srcDataset);
@@ -290,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;
@@ -320,11 +325,11 @@ void ResampleByReferenceRasterB(QString pszSrcFile, QString RefrasterBPath, QStr
char* pszSrcWKT = NULL;
pszSrcWKT = const_cast(pDSrc->GetProjectionRef());
- // ���û��ͶӰ����?���һ�?1?7
+ // 锟斤拷锟矫伙拷锟酵队帮拷锟斤拷锟轿?拷锟斤拷锟揭伙拷锟?1锟?7
if (strlen(pszSrcWKT) <= 0) {
OGRSpatialReference oSRS;
oSRS.importFromEPSG(4326);
- // oSRS.SetUTM(50, true); //������ ����120��
+ // oSRS.SetUTM(50, true); //锟斤拷锟斤拷锟斤拷 锟斤拷锟斤拷120锟斤拷
// oSRS.SetWellKnownGeogCS("WGS84");
oSRS.exportToWkt(&pszSrcWKT);
}
@@ -332,12 +337,12 @@ void ResampleByReferenceRasterB(QString pszSrcFile, QString RefrasterBPath, QStr
char* pdstSrcWKT = NULL;
pdstSrcWKT = const_cast(pDRef->GetProjectionRef());
- // ���û��ͶӰ����?���һ�?1?7
+ // 锟斤拷锟矫伙拷锟酵队帮拷锟斤拷锟轿?拷锟斤拷锟揭伙拷锟?1锟?7
if (strlen(pdstSrcWKT) <= 0)
{
OGRSpatialReference oSRS;
oSRS.importFromEPSG(4326);
- // oSRS.SetUTM(50, true); //������ ����120��
+ // oSRS.SetUTM(50, true); //锟斤拷锟斤拷锟斤拷 锟斤拷锟斤拷120锟斤拷
// oSRS.SetWellKnownGeogCS("WGS84");
oSRS.exportToWkt(&pdstSrcWKT);
}
@@ -369,7 +374,7 @@ void ResampleByReferenceRasterB(QString pszSrcFile, QString RefrasterBPath, QStr
hTransformArg = GDALCreateGenImgProjTransformer((GDALDatasetH)pDSrc, pszSrcWKT, NULL, pszSrcWKT,
FALSE, 0.0, 1);
qDebug() << "no proj ";
- //(û��ͶӰ��Ӱ��������߲�??1?7)
+ //(没锟斤拷投影锟斤拷影锟斤拷锟斤拷锟斤拷锟斤拷卟锟酵?拷锟?1锟?7)
if (hTransformArg == NULL) {
qDebug() << "hTransformArg create failure";
GDALClose((GDALDatasetH)(GDALDatasetH)pDSrc);
@@ -392,8 +397,8 @@ void ResampleByReferenceRasterB(QString pszSrcFile, QString RefrasterBPath, QStr
GDALWarpOptions* psWo = GDALCreateWarpOptions();
- CPLSetConfigOption("GDAL_NUM_THREADS", "ALL_CPUS"); // ʹпõCPU
- CPLSetConfigOption("GDAL_CACHEMAX", "16000"); // ûСΪ500MB
+ CPLSetConfigOption("GDAL_NUM_THREADS", "ALL_CPUS"); // 使用所有可用的CPU核心
+ CPLSetConfigOption("GDAL_CACHEMAX", "16000"); // 设置缓存大小为500MB
// psWo->papszWarpOptions = CSLDuplicate(NULL);
psWo->eWorkingDataType = dataType;
@@ -440,20 +445,20 @@ void ResampleByReferenceRasterB(QString pszSrcFile, QString RefrasterBPath, QStr
void ResampleByReferenceRasterB(QString InrasterAPath, QString RefrasterBPath, QString OutrasterCPath) {
- // עGDAL
+ // 注册所有GDAL驱动
GDALAllRegister();
- // οդB
+ // 打开参考栅格B
GDALDataset* refDS = (GDALDataset*)GDALOpen(RefrasterBPath.toUtf8().constData(), GA_ReadOnly);
if (!refDS) {
- qDebug() << "οդB" << RefrasterBPath;
+ qDebug() << "无法打开参考栅格B:" << RefrasterBPath;
return;
}
- // ȡοդĵ任ͶӰͳߴ
+ // 获取参考栅格的地理变换、投影和尺寸
double geotransform[6];
if (refDS->GetGeoTransform(geotransform) != CE_None) {
- qDebug() << "ȡοդĵ任ʧܡ";
+ qDebug() << "获取参考栅格的地理变换失败。";
GDALClose(refDS);
return;
}
@@ -461,28 +466,28 @@ void ResampleByReferenceRasterB(QString InrasterAPath, QString RefrasterBPath, Q
const char* proj = refDS->GetProjectionRef();
int cols = refDS->GetRasterXSize();
int rows = refDS->GetRasterYSize();
- GDALClose(refDS); // ȡϢرղοդ
+ GDALClose(refDS); // 获取信息后关闭参考栅格
- // դA
+ // 打开输入栅格A
GDALDataset* srcDS = (GDALDataset*)GDALOpen(InrasterAPath.toUtf8().constData(), GA_ReadOnly);
if (!srcDS) {
- qDebug() << "դA" << InrasterAPath;
+ qDebug() << "无法打开输入栅格A:" << InrasterAPath;
return;
}
- // ȡդIJ
+ // 获取输入栅格的波段数和数据类型
int nBands = srcDS->GetRasterCount();
if (nBands == 0) {
- qDebug() << "դûвݡ";
+ qDebug() << "输入栅格没有波段数据。";
GDALClose(srcDS);
return;
}
GDALDataType dataType = srcDS->GetRasterBand(1)->GetRasterDataType();
- // դC
+ // 创建输出栅格C
GDALDriver* driver = GetGDALDriverManager()->GetDriverByName("GTiff");
if (!driver) {
- qDebug() << "ȡGeoTIFF";
+ qDebug() << "无法获取GeoTIFF驱动。";
GDALClose(srcDS);
return;
}
@@ -496,16 +501,16 @@ void ResampleByReferenceRasterB(QString InrasterAPath, QString RefrasterBPath, Q
nullptr
);
if (!dstDS) {
- qDebug() << "դ" << OutrasterCPath;
+ qDebug() << "无法创建输出栅格:" << OutrasterCPath;
GDALClose(srcDS);
return;
}
- // դĵ任ͶӰ
+ // 设置输出栅格的地理变换和投影
dstDS->SetGeoTransform(geotransform);
dstDS->SetProjection(proj);
- // GDAL Warpѡ
+ // 配置GDAL Warp选项
GDALWarpOptions* psWO = GDALCreateWarpOptions();
psWO->hSrcDS = srcDS;
psWO->hDstDS = dstDS;
@@ -516,9 +521,9 @@ void ResampleByReferenceRasterB(QString InrasterAPath, QString RefrasterBPath, Q
psWO->panSrcBands[i] = i + 1;
psWO->panDstBands[i] = i + 1;
}
- psWO->eResampleAlg = GRA_NearestNeighbour; // ʹز
+ psWO->eResampleAlg = GRA_NearestNeighbour; // 使用最近邻重采样
- // ʼת
+ // 初始化坐标转换器
psWO->pfnTransformer = GDALGenImgProjTransform;
psWO->pTransformerArg = GDALCreateGenImgProjTransformer(
srcDS, GDALGetProjectionRef(srcDS),
@@ -526,17 +531,17 @@ void ResampleByReferenceRasterB(QString InrasterAPath, QString RefrasterBPath, Q
FALSE, 0.0, 1
);
if (!psWO->pTransformerArg) {
- qDebug() << "תʧܡ";
+ qDebug() << "创建坐标转换器失败。";
GDALDestroyWarpOptions(psWO);
GDALClose(srcDS);
GDALClose(dstDS);
return;
}
- // ִWarp
+ // 执行Warp操作
GDALWarpOperation oWarp;
if (oWarp.Initialize(psWO) != CE_None) {
- qDebug() << "ʼWarpʧܡ";
+ qDebug() << "初始化Warp操作失败。";
GDALDestroyGenImgProjTransformer(psWO->pTransformerArg);
GDALDestroyWarpOptions(psWO);
GDALClose(srcDS);
@@ -546,79 +551,80 @@ void ResampleByReferenceRasterB(QString InrasterAPath, QString RefrasterBPath, Q
CPLErr eErr = oWarp.ChunkAndWarpImage(0, 0, cols, rows);
if (eErr != CE_None) {
- qDebug() << "ִWarpʧܡ";
+ qDebug() << "执行Warp操作失败。";
}
- // Դ
+ // 清理资源
GDALDestroyGenImgProjTransformer(psWO->pTransformerArg);
GDALDestroyWarpOptions(psWO);
GDALClose(srcDS);
GDALClose(dstDS);
- qDebug() << "زɣѱ" << OutrasterCPath;
+ qDebug() << "重采样完成,结果已保存至:" << OutrasterCPath;
}
void cropRasterByLatLon(const char* inputFile, const char* outputFile, double minLon, double maxLon, double minLat, double maxLat) {
- // ʼ GDAL
+ // 初始化 GDAL 库
GDALAllRegister();
+ CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
- // դݼ
+ // 打开栅格数据集
GDALDataset* poDataset = (GDALDataset*)GDALOpen(inputFile, GA_ReadOnly);
if (poDataset == nullptr) {
- std::cerr << "Failed to open input raster." << std::endl;
+ qDebug() << "Failed to open input raster." ;
return;
}
- // ȡդݵĵοϢ
+ // 获取栅格数据的地理参考信息
double adfGeoTransform[6];
if (poDataset->GetGeoTransform(adfGeoTransform) != CE_None) {
- std::cerr << "Failed to get geotransform." << std::endl;
+ qDebug() << "Failed to get geotransform." ;
GDALClose(poDataset);
return;
}
- // ȡӰͶӰϢ
+ // 获取输入影像的投影信息
const char* projection = poDataset->GetProjectionRef();
- // ݾγȼüӦդ
+ // 根据经纬度计算出裁剪区域对应的栅格像素坐标
int xMin = (int)((minLon - adfGeoTransform[0]) / adfGeoTransform[1]);
int xMax = (int)((maxLon - adfGeoTransform[0]) / adfGeoTransform[1]);
int yMin = (int)((maxLat - adfGeoTransform[3]) / adfGeoTransform[5]);
int yMax = (int)((minLat - adfGeoTransform[3]) / adfGeoTransform[5]);
- // üĿդݼ
+ // 创建裁剪区域的目标栅格数据集
GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
if (poDriver == nullptr) {
- std::cerr << "Failed to get GTiff driver." << std::endl;
+ qDebug() << "Failed to get GTiff driver." ;
GDALClose(poDataset);
return;
}
- // դݼָߴ
+ // 创建输出栅格数据集,指定尺寸
int width = xMax - xMin;
int height = yMax - yMin;
GDALDataset* poOutDataset = poDriver->Create(outputFile, width, height, poDataset->GetRasterCount(), GDT_Float32, nullptr);
if (poOutDataset == nullptr) {
- std::cerr << "Failed to create output raster." << std::endl;
+ qDebug() << "Failed to create output raster." ;
GDALClose(poDataset);
return;
}
- // դͶӰϢ͵任
+ // 设置输出栅格的投影信息和地理变换
poOutDataset->SetProjection(projection);
double newGeoTransform[6] = { adfGeoTransform[0] + xMin * adfGeoTransform[1], adfGeoTransform[1], 0.0, adfGeoTransform[3] + yMin * adfGeoTransform[5], 0.0, adfGeoTransform[5] };
poOutDataset->SetGeoTransform(newGeoTransform);
- // ѭȡԴݲдĿݼ
+ // 循环读取源数据并写入目标数据集
for (int i = 0; i < poDataset->GetRasterCount(); ++i) {
GDALRasterBand* poBand = poDataset->GetRasterBand(i + 1);
GDALRasterBand* poOutBand = poOutDataset->GetRasterBand(i + 1);
- // ȡԴ
+ // 读取源数据
int* pData = new int[width * height];
poBand->RasterIO(GF_Read, xMin, yMin, width, height, pData, width, height, GDT_Int32, 0, 0);
- // дĿ
+ // 写入目标数据
poOutBand->RasterIO(GF_Write, 0, 0, width, height, pData, width, height, GDT_Int32, 0, 0);
delete[] pData;
@@ -626,28 +632,30 @@ void cropRasterByLatLon(const char* inputFile, const char* outputFile, double mi
qDebug() << "Raster cropped and saved to: " << outputFile;
- //
- GDALClose(poDataset);
- GDALClose(poOutDataset);
+ // 清理
+
+ GDALClose((GDALDatasetH)(GDALDatasetH)poDataset);
+ GDALClose((GDALDatasetH)(GDALDatasetH)poOutDataset);
+ GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
}
ErrorCode transformCoordinate(double x, double y, int sourceEPSG, int targetEPSG, Point2& p) {
- // Դϵԭʼϵ
+ // 创建源坐标系(原始坐标系)
OGRSpatialReference sourceSRS;
- sourceSRS.importFromEPSG(sourceEPSG); // ʹ EPSG ָϵ
+ sourceSRS.importFromEPSG(sourceEPSG); // 使用 EPSG 编码来指定坐标系
- // ĿϵĿϵ
+ // 创建目标坐标系(目标坐标系)
OGRSpatialReference targetSRS;
- targetSRS.importFromEPSG(targetEPSG); // WGS84 ϵ EPSG:4326
+ targetSRS.importFromEPSG(targetEPSG); // WGS84 坐标系 EPSG:4326
- // 任
+ // 创建坐标变换对象
OGRCoordinateTransformation* transform = OGRCreateCoordinateTransformation(&sourceSRS, &targetSRS);
if (transform == nullptr) {
qDebug() << "Failed to create coordinate transformation.";
return ErrorCode::FAIL;
}
- // ת
+ // 转换坐标
double transformedX = x;
double transformedY = y;
if (transform->Transform(1, &transformedX, &transformedY)) {
@@ -658,7 +666,7 @@ ErrorCode transformCoordinate(double x, double y, int sourceEPSG, int targetEPSG
qDebug() << "Coordinate transformation failed.";
}
- //
+ // 清理
delete transform;
p.x = transformedX;
p.y = transformedY;
@@ -668,23 +676,23 @@ ErrorCode transformCoordinate(double x, double y, int sourceEPSG, int targetEPSG
void transformRaster(const char* inputFile, const char* outputFile, int sourceEPSG, int targetEPSG) {
- // ʼ GDAL
+ // 初始化 GDAL 库
GDALAllRegister();
- // Դդļ
+ // 打开源栅格文件
GDALDataset* poSrcDS = (GDALDataset*)GDALOpen(inputFile, GA_ReadOnly);
if (poSrcDS == nullptr) {
qDebug() << "Failed to open input file:" << inputFile;
return;
}
- // ȡԴդĻϢ
+ // 获取源栅格的基本信息
int nXSize = poSrcDS->GetRasterXSize();
int nYSize = poSrcDS->GetRasterYSize();
int nBands = poSrcDS->GetRasterCount();
GDALDataType eDT = poSrcDS->GetRasterBand(1)->GetRasterDataType();
- // Ŀդļ
+ // 创建目标栅格文件
GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
if (poDriver == nullptr) {
qDebug() << "GTiff driver not available.";
@@ -699,7 +707,7 @@ void transformRaster(const char* inputFile, const char* outputFile, int sourceEP
return;
}
- // ĿդĿռοϵͳ
+ // 设置目标栅格的空间参考系统
OGRSpatialReference oSRS;
oSRS.importFromEPSG(targetEPSG);
@@ -708,10 +716,10 @@ void transformRaster(const char* inputFile, const char* outputFile, int sourceEP
poDstDS->SetProjection(pszWKT);
CPLFree(pszWKT);
- // Ԫ
+ // 复制元数据
poDstDS->SetMetadata(poSrcDS->GetMetadata());
- // ÿε
+ // 复制每个波段的数据
for (int i = 1; i <= nBands; ++i) {
GDALRasterBand* poSrcBand = poSrcDS->GetRasterBand(i);
GDALRasterBand* poDstBand = poDstDS->GetRasterBand(i);
@@ -726,7 +734,7 @@ void transformRaster(const char* inputFile, const char* outputFile, int sourceEP
CPLFree(pafScanline);
}
- // رݼ
+ // 关闭数据集
GDALClose(poSrcDS);
GDALClose(poDstDS);
@@ -735,81 +743,56 @@ void transformRaster(const char* inputFile, const char* outputFile, int sourceEP
void resampleRaster(const char* inputRaster, const char* outputRaster, double targetPixelSizeX, double targetPixelSizeY) {
- // ʼGDAL
+ // 初始化GDAL
GDALAllRegister();
- // դļ
+ // 打开输入栅格文件
GDALDataset* poDataset = (GDALDataset*)GDALOpen(inputRaster, GA_ReadOnly);
if (poDataset == nullptr) {
- std::cerr << "Failed to open raster file." << std::endl;
+ qDebug() << "Failed to open raster file." ;
return;
}
- // ȡԭʼդĿռο
+ // 获取原始栅格的空间参考
double adfGeoTransform[6];
if (poDataset->GetGeoTransform(adfGeoTransform) != CE_None) {
- std::cerr << "Failed to get geotransform." << std::endl;
+ qDebug() << "Failed to get geotransform." ;
GDALClose(poDataset);
return;
}
- // ȡԭʼդijߴ
+ // 获取原始栅格的尺寸
int nXSize = poDataset->GetRasterXSize();
int nYSize = poDataset->GetRasterYSize();
- // Ŀդijߴ
- double targetXSize = (adfGeoTransform[1] * nXSize) / targetPixelSizeX;
- double targetYSize = (adfGeoTransform[5] * nYSize) / targetPixelSizeY;
+ // 计算目标栅格的尺寸
+ double targetXSize = ceil((adfGeoTransform[1] * nXSize) / targetPixelSizeX);
+ double targetYSize = ceil(std::abs((adfGeoTransform[5] * nYSize) / targetPixelSizeY));
- // Ŀݼդ
+ // 创建目标数据集(输出栅格)
GDALDriver* poDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
if (poDriver == nullptr) {
- std::cerr << "Failed to get GTiff driver." << std::endl;
+ qDebug() << "Failed to get GTiff driver." ;
GDALClose(poDataset);
return;
}
- // ݼ
- GDALDataset* poOutDataset = poDriver->Create(outputRaster, (int)targetXSize, (int)targetYSize, poDataset->GetRasterCount(), GDT_Float32, nullptr);
- if (poOutDataset == nullptr) {
- std::cerr << "Failed to create output raster." << std::endl;
- GDALClose(poDataset);
- return;
- }
-
- // ݼĵ任ϵ
+ // 设置输出数据集的地理变换(坐标系)
double targetGeoTransform[6] = {
adfGeoTransform[0], targetPixelSizeX, 0, adfGeoTransform[3], 0, -targetPixelSizeY
};
- poOutDataset->SetGeoTransform(targetGeoTransform);
-
- // ݼͶӰϢ
- poOutDataset->SetProjection(poDataset->GetProjectionRef());
-
- // ز
- for (int i = 0; i < poDataset->GetRasterCount(); i++) {
- GDALRasterBand* poBand = poDataset->GetRasterBand(i + 1);
- GDALRasterBand* poOutBand = poOutDataset->GetRasterBand(i + 1);
-
- // ʹGDALزѡһʵزʽ
- poOutBand->RasterIO(GF_Write, 0, 0, (int)targetXSize, (int)targetYSize,
- nullptr, (int)targetXSize, (int)targetYSize,
- poBand->GetRasterDataType(), 0, 0, nullptr);
- }
-
- // رݼ
- GDALClose(poDataset);
- GDALClose(poOutDataset);
-
+ GDALClose((GDALDatasetH)(GDALDatasetH)poDataset);
+ GDALDestroy(); // or, DllMain at DLL_PROCESS_DETACH
+ ResampleGDAL(inputRaster, outputRaster, targetGeoTransform, targetXSize, targetYSize,GRA_Bilinear);
qDebug() << "Resampling completed.";
}
std::shared_ptr GetCenterPointInRaster(QString filepath)
{
qDebug() << "============= GetCenterPointInRaster ======================";
- // QTextCodec* codec = QTextCodec::codecForLocale(); // ȡϵͳĬϱı
- // QByteArray byteArray = codec->fromUnicode(filepath); // QStringתΪQByteArray
- //,ӦûԶͷ const char* charArray = byteArray.constData(); //
- // ȡQByteArrayconst char*ָ
+ // QTextCodec* codec = QTextCodec::codecForLocale(); // 获取系统默认编码的文本编解码器
+ // QByteArray byteArray = codec->fromUnicode(filepath); // 将QString转换为QByteArray
+ //,这个应该会自动释放 const char* charArray = byteArray.constData(); //
+ // 获取QByteArray的const char*指针
GDALAllRegister();
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
@@ -817,7 +800,7 @@ std::shared_ptr GetCenterPointInRaster(QString filepath)
GDALDataset* poDataset = (GDALDataset*)GDALOpen(filepath.toUtf8().data(), GA_ReadOnly);
if (nullptr == poDataset || NULL == poDataset) {
qDebug() << "Could not open dataset";
- return nullptr; // ʾȡʧ
+ return nullptr; // 表示读取失败
}
double x, y, z;
@@ -834,7 +817,7 @@ std::shared_ptr GetCenterPointInRaster(QString filepath)
double dfWidth = poDataset->GetRasterXSize();
double dfHeight = poDataset->GetRasterYSize();
- // ĵ꣨꣩
+ // 计算中心点坐标(像素坐标)
double dfCenterX = adfGeoTransform[0] + dfWidth * adfGeoTransform[1] / 2.0
+ dfHeight * adfGeoTransform[2] / 2.0;
double dfCenterY = adfGeoTransform[3] + dfWidth * adfGeoTransform[4] / 2.0
@@ -851,7 +834,7 @@ std::shared_ptr GetCenterPointInRaster(QString filepath)
y = dfCenterY;
}
else {
- // ǵϵתWGS84
+ // 如果不是地理坐标系,转换到WGS84
OGRSpatialReference oSRS_WGS84;
oSRS_WGS84.SetWellKnownGeogCS("WGS84");
@@ -899,10 +882,10 @@ std::shared_ptr GetCenterPointInRaster(QString filepath)
long GetEPSGFromRasterFile(QString filepath)
{
qDebug() << "============= GetEPSGFromRasterFile ======================";
- // QTextCodec* codec = QTextCodec::codecForLocale(); // ȡϵͳĬϱı
- // QByteArray byteArray = codec->fromUnicode(filepath); // QStringתΪQByteArray
- //,ӦûԶͷ const char* charArray = byteArray.constData(); //
- // ȡQByteArrayconst char*ָ
+ // QTextCodec* codec = QTextCodec::codecForLocale(); // 获取系统默认编码的文本编解码器
+ // QByteArray byteArray = codec->fromUnicode(filepath); // 将QString转换为QByteArray
+ //,这个应该会自动释放 const char* charArray = byteArray.constData(); //
+ // 获取QByteArray的const char*指针
{
if (QFile(filepath).exists()) {
@@ -913,9 +896,9 @@ long GetEPSGFromRasterFile(QString filepath)
}
GDALAllRegister();
- CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES"); // עGDAL
+ CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES"); // 注册GDAL驱动
// qDebug()<GetProjectionRef();
qDebug() << QString::fromUtf8(pszProjection);
- // SpatialReference
+ // 创建SpatialReference对象
OGRSpatialReference oSRS;
if (oSRS.importFromWkt((char**)&pszProjection) != OGRERR_NONE) {
qDebug() << ("Error: Unable to import projection information.\n");
@@ -945,7 +928,7 @@ long GetEPSGFromRasterFile(QString filepath)
return -1;
}
- long epsgCode = atoi(epscodestr); // ȡEPSG
+ long epsgCode = atoi(epscodestr); // 获取EPSG代码
if (epsgCode != 0) {
GDALClose(poDataset);
@@ -963,14 +946,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: {
@@ -983,16 +968,16 @@ long getProjectEPSGCodeByLon_Lat(double long, double lat, ProjectStripDelta stri
}
long getProjectEPSGCodeByLon_Lat_inStrip3(double lon, double lat)
{
- // EPSG 4534 ~ 4554 3 ȴ
- // жǷ йΧ
- // ľȷΧ 75E ~ 135E ʵʷΧ 73.5E ~ 136.5E,
- // γȷΧ 3N ~ 54Nſ 0N~ 60N
- if (73.5 <= lon && lon <= 136.5 && 0 <= lat && lat <= 60) { // й
+ // EPSG 4534 ~ 4554 3 度带
+ // 首先判断是否是在 中国带宽范围
+ // 中心经度范围 :75E ~ 135E 实际范围 73.5E ~ 136.5E,
+ // 纬度范围 3N ~ 54N,放宽到 0N~ 60N
+ if (73.5 <= lon && lon <= 136.5 && 0 <= lat && lat <= 60) { // 中国境内
long code = trunc((lon - 73.5) / 3) + 4534;
return code;
}
- else { // й ʹ ˹
- bool isSouth = lat < 0; // жϱΪʾʵӦÿҪϸµ
+ else { // 非中国境内 使用 高斯克吕格
+ bool isSouth = lat < 0; // 简单判断南北半球,这里仅为示例,实际应用可能需要更细致的逻辑
long prefix = isSouth ? 327000 : 326000;
// std::string prefix = isSouth ? "327" : "326";
lon = fmod(lon + 360.0, 360.0);
@@ -1004,18 +989,18 @@ long getProjectEPSGCodeByLon_Lat_inStrip3(double lon, double lat)
}
long getProjectEPSGCodeByLon_Lat_inStrip6(double lon, double lat)
{
- // EPSG 4502 ~ 4512 6ȴ
- // жǷ йΧ
- // ľȷΧ 75E ~ 135E ʵʷΧ 72.0E ~ 138E,
- // γȷΧ 3N ~ 54Nſ 0N~ 60N
- if (73.5 <= lon && lon <= 136.5 && 0 <= lat && lat <= 60) { // й
+ // EPSG 4502 ~ 4512 6度带
+ // 首先判断是否是在 中国带宽范围
+ // 中心经度范围 :75E ~ 135E 实际范围 72.0E ~ 138E,
+ // 纬度范围 3N ~ 54N,放宽到 0N~ 60N
+ if (73.5 <= lon && lon <= 136.5 && 0 <= lat && lat <= 60) { // 中国境内
long code = trunc((lon - 72.0) / 6) + 4502;
return code;
}
- else { // й ʹ UTM// ȷţ6ȴ1ʼ60ÿ6һ
+ else { // 非中国境内 使用 UTM// 确定带号,6度带从1开始到60,每6度一个带
int zone = static_cast((lon + 180.0) / 6.0) + 1;
- bool isSouth = lon < 0; // жǷϰ
- long epsgCodeBase = isSouth ? 32700 : 32600; // EPSG
+ bool isSouth = lon < 0; // 判断是否在南半球
+ long epsgCodeBase = isSouth ? 32700 : 32600; // 计算EPSG代码
long prefix = static_cast(epsgCodeBase + zone);
return prefix;
}
@@ -1027,13 +1012,13 @@ QString GetProjectionNameFromEPSG(long epsgCode)
qDebug() << "============= GetProjectionNameFromEPSG ======================";
OGRSpatialReference oSRS;
- // EPSG
+ // 设置EPSG代码
if (oSRS.importFromEPSG(epsgCode) != OGRERR_NONE) {
qDebug() << "epsgcode not recognition";
return "";
}
- // ȡϵƣ
+ // 获取并输出坐标系的描述(名称)
const char* pszName = oSRS.GetAttrValue("GEOGCS");
if (pszName) {
qDebug() << "Coordinate system name for EPSG " + QString::number(epsgCode)
@@ -1046,19 +1031,19 @@ QString GetProjectionNameFromEPSG(long epsgCode)
}
// char* wkt = NULL;
- // // תΪWKTʽ
+ // // 转换为WKT格式
// oSRS.exportToWkt(&wkt);
//
// qDebug() << wkt;
//
- // // WKTнͶӰƣʵʿҪӵȷȡ
+ // // 从WKT中解析投影名称,这里简化处理,实际可能需要更复杂的逻辑来准确提取名称
// std::string wktStr(wkt);
- // long start = wktStr.find("PROJCS[\"") + 8; // ҵ"PROJCS["ĵһ˫λ
- // // startλÿʼһ˫ţ֮ݼΪͶӰ
+ // long start = wktStr.find("PROJCS[\"") + 8; // 找到"PROJCS["后的第一个双引号位置
+ // // 从start位置开始找下一个双引号,这之间的内容即为投影名称
// int end = wktStr.find('\"', start);
// QString projName = QString::fromStdString(wktStr.substr(start, end - start));
//
- // // ͷWKTַڴ
+ // // 释放WKT字符串内存
// CPLFree(wkt);
// return projName;
@@ -1111,11 +1096,11 @@ int ResampleGDAL(const char* pszSrcFile, const char* pszOutFile, double* gt, int
char* pszSrcWKT = NULL;
pszSrcWKT = const_cast(pDSrc->GetProjectionRef());
- // ���û��ͶӰ����?���һ�?1?7
+ // 锟斤拷锟矫伙拷锟酵队帮拷锟斤拷锟轿?拷锟斤拷锟揭伙拷锟?1锟?7
if (strlen(pszSrcWKT) <= 0) {
OGRSpatialReference oSRS;
oSRS.importFromEPSG(4326);
- // oSRS.SetUTM(50, true); //������ ����120��
+ // oSRS.SetUTM(50, true); //锟斤拷锟斤拷锟斤拷 锟斤拷锟斤拷120锟斤拷
// oSRS.SetWellKnownGeogCS("WGS84");
oSRS.exportToWkt(&pszSrcWKT);
}
@@ -1124,7 +1109,7 @@ int ResampleGDAL(const char* pszSrcFile, const char* pszOutFile, double* gt, int
hTransformArg = GDALCreateGenImgProjTransformer((GDALDatasetH)pDSrc, pszSrcWKT, NULL, pszSrcWKT,
FALSE, 0.0, 1);
qDebug() << "no proj " << Qt::endl;
- //(û��ͶӰ��Ӱ��������߲�??1?7)
+ //(没锟斤拷投影锟斤拷影锟斤拷锟斤拷锟斤拷锟斤拷卟锟酵?拷锟?1锟?7)
if (hTransformArg == NULL) {
GDALClose((GDALDatasetH)(GDALDatasetH)pDSrc);
return -3;
@@ -1152,8 +1137,8 @@ int ResampleGDAL(const char* pszSrcFile, const char* pszOutFile, double* gt, int
pDDst->SetGeoTransform(gt);
GDALWarpOptions* psWo = GDALCreateWarpOptions();
- CPLSetConfigOption("GDAL_NUM_THREADS", "ALL_CPUS"); // ʹпõCPU
- CPLSetConfigOption("GDAL_CACHEMAX", "4000"); // ûСΪ500MB
+ CPLSetConfigOption("GDAL_NUM_THREADS", "ALL_CPUS"); // 使用所有可用的CPU核心
+ CPLSetConfigOption("GDAL_CACHEMAX", "4000"); // 设置缓存大小为500MB
// psWo->papszWarpOptions = CSLDuplicate(NULL);
psWo->eWorkingDataType = dataType;
psWo->eResampleAlg = eResample;
@@ -1361,7 +1346,7 @@ int alignRaster(QString inputPath, QString referencePath, QString outputPath, GD
-/** 2025.03.25 ĺ Eigenʹ****************************/
+/** 2025.03.25 下面的函数存在 Eigen使用****************************/
@@ -1392,8 +1377,8 @@ int saveMatrixXcd2TiFF(Eigen::MatrixXcd data, QString out_tiff_path)
Eigen::MatrixXd gt = Eigen::MatrixXd::Zero(2, 3);
gdalImage image_tiff =
- CreategdalImage(out_tiff_path, rows, cols, 2, gt, "", false, true); // עﱣ
- // ļ
+ CreategdalImage(out_tiff_path, rows, cols, 2, gt, "", false, true); // 注意这里保留仿真结果
+ // 保存二进制文件
Eigen::MatrixXd real_img = data.array().real();
Eigen::MatrixXd imag_img = data.array().imag();
image_tiff.saveImage(real_img, 0, 0, 1);
@@ -1430,23 +1415,30 @@ void clipRaster(QString inRasterPath, QString outRasterPath, long minRow, long m
ErrorCode DEM2XYZRasterAndSlopRaster(QString dempath, QString demxyzpath, QString demsloperPath)
{
- gdalImage demds(dempath);
- gdalImage demxyz = CreategdalImage(demxyzpath, demds.height, demds.width, 3, demds.gt, demds.projection, true, true);// X,Y,Z
+ QString DEMPath = dempath;
+ QString XYZPath = demxyzpath;
+ QString SLOPERPath = demsloperPath;
- // ֿ㲢תΪXYZ
+
+
+ gdalImage demds(DEMPath);
+ gdalImage demxyz = CreategdalImageDouble(XYZPath, demds.height, demds.width, 3, demds.gt, demds.projection, true, true, false);// X,Y,Z
+
+ // 分块计算并转换为XYZ
+
+ //Eigen::MatrixXd demArr = demds.getData(0, 0, demds.height, demds.width, 1);
+ //Eigen::MatrixXd demR = demArr;
- 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;
+ long line_invert = Memory1MB / 8.0 / demds.width * 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) {
+ qDebug() << "dem -> XYZ [" << max_rows_ids*100.0/ demds.height << "] %" ;
+
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;
@@ -1455,12 +1447,17 @@ ErrorCode DEM2XYZRasterAndSlopRaster(QString dempath, QString demxyzpath, QStri
int datarows = demdata.rows();
int datacols = demdata.cols();
+#pragma omp parallel for
for (int i = 0; i < datarows; i++) {
+ Landpoint LandP{ 0,0,0 };
+ Point3 GERpoint{ 0,0,0 };
+ double rowidx = 0;
+ double colidx = 0;
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); // γתΪϵ
+ 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;
@@ -1469,35 +1466,39 @@ ErrorCode DEM2XYZRasterAndSlopRaster(QString dempath, QString demxyzpath, QStri
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);
+
}
- //
- gdalImage demsloperxyz = CreategdalImage(demsloperPath, demds.height, demds.width, 4, demds.gt, demds.projection, true, true);// X,Y,Z,cosangle
+ // 计算坡向角
+
+
+
+ gdalImage demsloperxyz = CreategdalImageDouble(SLOPERPath, demds.height, demds.width, 4, demds.gt, demds.projection, true, true, false);// X,Y,Z,cosangle
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 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);
- Landpoint p0, p1, p2, p3, p4, pslopeVector, pp;
- Vector3D slopeVector;
-
- dem_rows = demsloper_y.rows();
- dem_cols = demsloper_y.cols();
- double sloperAngle = 0;
- Vector3D Zaxis = { 0,0,1 };
-
- double rowidx = 0, colidx = 0;
+ dem_rows = demsloper_x.rows();
+ dem_cols = demsloper_x.cols();
+#pragma omp parallel for
for (long i = 1; i < dem_rows - 1; i++) {
+ Landpoint p0, p1, p2, p3, p4, pslopeVector, pp;
+ Vector3D slopeVector;
+ double sloperAngle = 0;
+ Vector3D Zaxis = { 0,0,1 };
+
+ double rowidx = 0, colidx = 0;
for (long j = 1; j < dem_cols - 1; j++) {
rowidx = i + startlineid;
colidx = j;
@@ -1507,27 +1508,31 @@ ErrorCode DEM2XYZRasterAndSlopRaster(QString dempath, QString demxyzpath, QStri
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); // ʸ
+ 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); //
+ 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;
+
}
}
+
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;
}
@@ -1549,7 +1554,7 @@ void CreateSARIntensityByLookTable(QString IntensityRasterPath,
Eigen::MatrixXd SARData = SARIntensity.getData(0, 0, SARIntensity.height, SARIntensity.width, 1);
SARData = SARData.array() * 0;
- // ֿ鴦
+ // 分块处理
for (int yOff = 0; yOff < looktableds.height; yOff += blockYSize)
{
processBarShow(yOff, looktableds.height);
@@ -1575,9 +1580,293 @@ void CreateSARIntensityByLookTable(QString IntensityRasterPath,
}
-/* ĺᵼ±Eigen bugأŲ飬̫ʱ䣬ҲһŲ
+
+
+
+
+
+
+/**
+* @brief 将VRT文件转换为ENVI格式(生成.dat和.hdr文件)
+* @param inputVrtPath 输入VRT文件路径
+* @param outputEnviPath 输出ENVI数据文件路径(不含扩展名,自动生成.dat和.hdr)
+* @param papszOptions GDAL创建选项(如压缩参数、存储顺序等,默认NULL)
+* @return 成功返回true,失败返回false
+*/
+bool ConvertVrtToEnvi(QString vrtPath, QString outPath) {
+
+ GDALAllRegister();
+ CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES"); // 注绞斤拷斤拷锟?1锟?7
+ CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
+
+ const char* inputVrtPath = vrtPath.toUtf8().constData();
+ const char* outputEnviPath = outPath.toUtf8().constData();
+
+ // 注册所有GDAL驱动[7](@ref)
+ GDALAllRegister();
+
+ // 打开输入VRT文件[1,3](@ref)
+ GDALDataset* poVRTDataset = (GDALDataset*)GDALOpen(inputVrtPath, GA_ReadOnly);
+ if (!poVRTDataset) {
+ qDebug() << "错误:无法打开VRT文件 " << inputVrtPath ;
+ return false;
+ }
+
+ // 获取ENVI驱动[4,7](@ref)
+ GDALDriver* poENVIDriver = GetGDALDriverManager()->GetDriverByName("ENVI");
+ if (!poENVIDriver) {
+ qDebug() << "错误:ENVI驱动未加载" ;
+ GDALClose(poVRTDataset);
+ return false;
+ }
+
+ // 构造输出文件名(强制添加.dat后缀)[4](@ref)
+ std::string outputPath = std::string(outputEnviPath) + ".dat";
+
+ // 执行格式转换(自动生成.hdr头文件)[4,7](@ref)
+ GDALDataset* poENVIDataset = poENVIDriver->CreateCopy(
+ outputPath.c_str(), // 输出路径
+ poVRTDataset, // 输入数据集
+ FALSE, // 非严格模式(允许格式调整)
+ nullptr, // 用户自定义选项(如压缩参数)
+ nullptr, nullptr // 进度条和参数(暂不启用)
+ );
+
+ // 检查转换结果
+ bool success = (poENVIDataset != nullptr);
+ if (!success) {
+ qDebug() << "错误:ENVI文件创建失败" ;
+ }
+ else {
+ GDALClose(poENVIDataset);
+ }
+
+ // 关闭输入数据集
+ GDALClose(poVRTDataset);
+ return 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;
+ }
+}
+
+void BASECONSTVARIABLEAPI CloseAllGDALRaster()
+{
+ GDALDestroyDriverManager();
+ return ;
+}
+
+
+
+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;
+
+ long startrow = 0;
+ for (startrow = 0; startrow < inimg.height; startrow = startrow + blocklines) {
+
+ Eigen::MatrixXd imgArrb1 = ampimg.getData(startrow, 0, blocklines, inimg.width, 1);
+ Eigen::MatrixXcd imgArr = inimg.getDataComplex(startrow, 0, blocklines, inimg.width, 1);
+ imgArrb1 = imgArr.array().abs();
+ ampimg.saveImage(imgArrb1, startrow, 0, 1);
+ }
+ qDebug() << u8"影像写入到:" << 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, 1);
+ 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, 1);
+ imgArrb1 = imgArr.array().abs().log10() * 20.0;
+ ampimg.saveImage(imgArrb1, startrow, 0, 1);
+ }
+ qDebug() << "影像写入到:" << outRasterPath;
+ return ErrorCode::SUCCESS;
+}
+
+
+
+ErrorCode BASECONSTVARIABLEAPI amp2dBRaster(QString inPath, QString outRasterPath)
+{
+ gdalImage inimg(inPath);
+ gdalImage dBimg = 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 imgArrdB = Eigen::MatrixXd::Zero(blocklines, dBimg.width);
+ Eigen::MatrixXd imgArr = Eigen::MatrixXd::Zero(blocklines, inimg.width);
+
+ long startrow = 0;
+ for (startrow = 0; startrow < inimg.height; startrow = startrow + blocklines) {
+
+ imgArrdB = dBimg.getData(startrow, 0, blocklines, inimg.width, 1);
+ imgArr = inimg.getData(startrow, 0, blocklines, inimg.width, 1);
+ imgArrdB = imgArr.array().log10() * 20.0;
+ dBimg.saveImage(imgArrdB, startrow, 0, 1);
+ }
+ qDebug() << "影像写入到:" << outRasterPath;
+ return ErrorCode::SUCCESS;
+}
+
+
+
+void MultiLookRaster(QString inRasterPath, QString outRasterPath, long looklineNumrow, long looklineNumCol)
+{
+ gdalImage inRaster(inRasterPath);
+
+ int outRows = inRaster.height / looklineNumrow;
+ int outCols = inRaster.width / looklineNumCol;
+ int bandnum = 1;
+ QString project = inRaster.projection;
+ Eigen::MatrixXd inRasterGt = inRaster.gt;
+ GDALDataType datetype = inRaster.getDataType();
+
+ gdalImage outRaster = CreategdalImage(outRasterPath, outRows, outCols, 1, inRasterGt, project, true, true, true, datetype);
+
+ Eigen::MatrixXd inRasterArr = inRaster.getData(0, 0, inRaster.height, inRaster.width, 1);
+ Eigen::MatrixXd outRasterArr = outRaster.getData(0, 0, outRows, outCols, 1);
+
+
+ // 多视处理
+#pragma omp parallel for collapse(2)
+ for (int row = 0; row < outRows; ++row) {
+ for (int col = 0; col < outCols; ++col) {
+ // 计算输入矩阵的窗口位置[2,3](@ref)
+ const int inputRow = row * looklineNumrow;
+ const int inputCol = col * looklineNumCol;
+
+ // 动态计算实际窗口大小(处理边界情况)[3](@ref)
+ const int actualRows = (row == outRows - 1) ?
+ (inRaster.height - inputRow) : looklineNumrow;
+ const int actualCols = (col == outCols - 1) ?
+ (inRaster.width - inputCol) : looklineNumCol;
+
+ // 提取当前窗口数据块[7](@ref)
+ Eigen::MatrixXd window = inRasterArr.block(inputRow, inputCol, actualRows, actualCols);
+
+ // 计算多视平均值(自动处理数据类型转换)[2,7](@ref)
+ double sum = 0.0;
+ if constexpr (std::is_integral_v) {
+ sum = window.cast().sum(); // 整型数据转换为双精度计算
+ }
+ else {
+ sum = window.sum();
+ }
+ outRasterArr(row, col) = sum / (actualRows * actualCols);
+ }
+ }
+
+ // 可选:处理残留边界(当输入尺寸不是整数倍时)
+ if ((inRaster.height % looklineNumrow != 0) || (inRaster.width % looklineNumCol != 0)) {
+ // 底部边界处理[3](@ref)
+ const int residualRowStart = outRows * looklineNumrow;
+ const int residualRowSize = inRaster.height - residualRowStart;
+ if (residualRowSize > 0) {
+#pragma omp parallel for
+ for (int col = 0; col < outCols; ++col) {
+ const int inputCol = col * looklineNumCol;
+ const int actualCols = (col == outCols - 1) ?
+ (inRaster.width - inputCol) : looklineNumCol;
+
+ Eigen::MatrixXd window = inRasterArr.block(residualRowStart, inputCol,
+ residualRowSize, actualCols);
+ outRasterArr(outRows - 1, col) = window.mean();
+ }
+ }
+
+ // 右侧边界处理[3](@ref)
+ const int residualColStart = outCols * looklineNumCol;
+ const int residualColSize = inRaster.width - residualColStart;
+ if (residualColSize > 0) {
+#pragma omp parallel for
+ for (int row = 0; row < outRows; ++row) {
+ const int inputRow = row * looklineNumrow;
+ const int actualRows = (row == outRows - 1) ?
+ (inRaster.height - inputRow) : looklineNumrow;
+
+ Eigen::MatrixXd window = inRasterArr.block(inputRow, residualColStart,
+ actualRows, residualColSize);
+ outRasterArr(row, outCols - 1) = window.mean();
+ }
+ }
+ }
+
+ // 保存结果
+ outRaster.saveImage(outRasterArr, 0, 0, 1);
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* 启动下面的函数,会导致编译器错误,可能与Eigen 库 本身的bug相关,不建议排查,太费时间,而且不一定能排查出来
*
-***
+***
Eigen::Matrix ReadComplexMatrixData(int start_line, int width, int line_num,
std::shared_ptr rasterDataset, GDALDataType gdal_datatype)
@@ -1601,7 +1890,7 @@ Eigen::Matrix ReadCompl
}
bool _flag = false;
Eigen::Matrix data_mat(
- line_num * width, 2); // ǿ
+ line_num * width, 2); // 必须强制行优先
if (gdal_datatype == GDT_Byte) {
Eigen::MatrixX real_mat(line_num * width, 1);
Eigen::MatrixX imag_mat(line_num * width, 1);
@@ -1751,14 +2040,14 @@ Eigen::Matrix ReadCompl
}
else {
}
- //
+ // 保存数据
if (_flag) {
return data_mat;
}
else {
return Eigen::Matrix(
- 0, 0); // ǿ;
+ 0, 0); // 必须强制行优先;
}
}
@@ -1767,10 +2056,10 @@ ReadMatrixDoubleData(int start_line, int width, int line_num,
std::shared_ptr rasterDataset, GDALDataType gdal_datatype,
int band_idx)
{
- // 飬ʹeigen о㣬ټ
+ // 构建矩阵块,使用eigen 进行矩阵计算,加速计算
bool _flag = false;
Eigen::Matrix data_mat(
- line_num * width, 1); // ǿ
+ line_num * width, 1); // 必须强制行优先
if (gdal_datatype == GDT_Byte) {
Eigen::MatrixX real_mat(line_num * width, 1);
rasterDataset->GetRasterBand(band_idx)->RasterIO(GF_Read, 0, start_line, width, line_num,
diff --git a/BaseCommonLibrary/ToolAbstract/QToolAbstract.cpp b/BaseCommonLibrary/ToolAbstract/QToolAbstract.cpp
index 302abc3..a20a9c5 100644
--- a/BaseCommonLibrary/ToolAbstract/QToolAbstract.cpp
+++ b/BaseCommonLibrary/ToolAbstract/QToolAbstract.cpp
@@ -32,5 +32,10 @@ QString QToolAbstract::getToolName()
}
void QToolAbstract::excute()
+{
+ this->run();
+}
+
+void QToolAbstract::run()
{
}
diff --git a/BaseCommonLibrary/ToolAbstract/QToolAbstract.h b/BaseCommonLibrary/ToolAbstract/QToolAbstract.h
index 5f00324..fda74f6 100644
--- a/BaseCommonLibrary/ToolAbstract/QToolAbstract.h
+++ b/BaseCommonLibrary/ToolAbstract/QToolAbstract.h
@@ -27,6 +27,8 @@ public slots:
public:
QVector toolPath;
QString toolname;
+public:
+ virtual void run();
};
/*
diff --git a/GPUBaseLib/GPUTool/GPUTool.cuh b/GPUBaseLib/GPUTool/GPUTool.cuh
index 6c513e3..c2bd1d4 100644
--- a/GPUBaseLib/GPUTool/GPUTool.cuh
+++ b/GPUBaseLib/GPUTool/GPUTool.cuh
@@ -20,13 +20,15 @@
/** CUDA ò ************************************************************************************/
#define BLOCK_SIZE 256
#define SHAREMEMORY_BYTE 49152
-#define SHAREMEMORY_FLOAT_HALF 6144
-#define SHAREMEMORY_FLOAT_HALF_STEP 24
+#define SHAREMEMORY_FLOAT_HALF_STEP 2
+#define SHAREMEMORY_FLOAT_HALF 512
+
#define SHAREMEMORY_DEM_STEP 768
#define SHAREMEMORY_Reflect 612
+
enum LAMPGPUDATETYPE {
LAMP_LONG,
LAMP_FLOAT,
diff --git a/LAMPDataProcess.sln b/LAMPDataProcess.sln
index 1f54f80..0559e59 100644
--- a/LAMPDataProcess.sln
+++ b/LAMPDataProcess.sln
@@ -38,10 +38,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RasterMainWidgetGUI", "Rast
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageshowTool", "ImageshowTool\ImageshowTool.vcxproj", "{8C8CA066-A93A-4098-9A46-B855EFEAADF2}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SPG4Tool", "SPG4Tool\SPG4Tool.vcxproj", "{80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pluginToolboxLibrary", "pluginToolboxLibrary\pluginToolboxLibrary.vcxproj", "{667625A5-8DE2-4373-99F0-8BAD2CCED011}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SPG4Tool", "SPG4Tool\SPG4Tool.vcxproj", "{80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
@@ -172,18 +172,6 @@ Global
{8C8CA066-A93A-4098-9A46-B855EFEAADF2}.Release|x64.Build.0 = Release|x64
{8C8CA066-A93A-4098-9A46-B855EFEAADF2}.Release|x86.ActiveCfg = Release|x64
{8C8CA066-A93A-4098-9A46-B855EFEAADF2}.Release|x86.Build.0 = Release|x64
- {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Debug|ARM.ActiveCfg = Debug|x64
- {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Debug|ARM.Build.0 = Debug|x64
- {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Debug|x64.ActiveCfg = Debug|x64
- {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Debug|x64.Build.0 = Debug|x64
- {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Debug|x86.ActiveCfg = Debug|x64
- {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Debug|x86.Build.0 = Debug|x64
- {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Release|ARM.ActiveCfg = Release|x64
- {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Release|ARM.Build.0 = Release|x64
- {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Release|x64.ActiveCfg = Release|x64
- {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Release|x64.Build.0 = Release|x64
- {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Release|x86.ActiveCfg = Release|x64
- {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Release|x86.Build.0 = Release|x64
{667625A5-8DE2-4373-99F0-8BAD2CCED011}.Debug|ARM.ActiveCfg = Debug|x64
{667625A5-8DE2-4373-99F0-8BAD2CCED011}.Debug|ARM.Build.0 = Debug|x64
{667625A5-8DE2-4373-99F0-8BAD2CCED011}.Debug|x64.ActiveCfg = Debug|x64
@@ -196,6 +184,18 @@ Global
{667625A5-8DE2-4373-99F0-8BAD2CCED011}.Release|x64.Build.0 = Release|x64
{667625A5-8DE2-4373-99F0-8BAD2CCED011}.Release|x86.ActiveCfg = Release|Win32
{667625A5-8DE2-4373-99F0-8BAD2CCED011}.Release|x86.Build.0 = Release|Win32
+ {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Debug|ARM.ActiveCfg = Debug|x64
+ {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Debug|ARM.Build.0 = Debug|x64
+ {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Debug|x64.ActiveCfg = Debug|x64
+ {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Debug|x64.Build.0 = Debug|x64
+ {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Debug|x86.ActiveCfg = Debug|x64
+ {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Debug|x86.Build.0 = Debug|x64
+ {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Release|ARM.ActiveCfg = Release|x64
+ {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Release|ARM.Build.0 = Release|x64
+ {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Release|x64.ActiveCfg = Release|x64
+ {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Release|x64.Build.0 = Release|x64
+ {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Release|x86.ActiveCfg = Release|x64
+ {80A5854F-6F80-4EC2-9F73-84E0F4DB8D7E}.Release|x86.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/RasterMainWidgetGUI/RasterMainWidget/RasterMainWidget.cpp b/RasterMainWidgetGUI/RasterMainWidget/RasterMainWidget.cpp
index eb4f02a..edf4a44 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/RasterMainWidget.cpp
+++ b/RasterMainWidgetGUI/RasterMainWidget/RasterMainWidget.cpp
@@ -14,331 +14,320 @@
#include "FileOperator.h"
#include "RasterWidgetMessageShow.h"
-
+#include "ImageOperatorBase.h"
#pragma execution_character_set("utf-8")
namespace LAMPMainWidget {
-QString
-RasterMainWidget::tutorialUrl() {
- return QString{R"(https://gitee.com/qizr_admin/LAMPMainWidget)"};
-}
+ QHashRasterMainWidget::mMaps{};
-QString
-RasterMainWidget::srcUrl() {
- return QString{R"(https://gitee.com/qizr_admin/LAMPMainWidget)"};
-}
+ RasterMainWidget::RasterMainWidget(QWidget* parent)
+ : mUi(new Ui::RasterMainWidget),
+ mMapConvas(new MapCanvas),
+ mScaleText(new QLineEdit),
+ mScaleLabel(new QLabel),
+ mCenterText(new QLineEdit),
+ mCenterLabel(new QLabel),
+ mZoomText(new QLineEdit),
+ mZoomLabel(new QLabel),
+ mMapActionGroup(new QActionGroup(dynamic_cast(this))),
+ mSetLeftTop(true),
+ mLayerList(),
+ mLeftTop(),
+ mRightBottom() {
+ this->setWindowTitle(tr(u8"LAMP影像处理软件"));
+ mUi->setupUi(dynamic_cast(this));
+ setupWindow();
+ setupTaskWindow();
+ setupLayers();
+ setupStatusBar();
+ setupActions();
+ setRightToolbox();
-QHashRasterMainWidget::mMaps{};
+ mUi->panAction->trigger();
+ mUi->layerList->setCurrentItem(mLayerList.first());
-RasterMainWidget::RasterMainWidget(QWidget *parent)
- : mUi(new Ui::RasterMainWidget),
- mMapConvas(new MapCanvas),
- mScaleText(new QLineEdit),
- mScaleLabel(new QLabel),
- mCenterText(new QLineEdit),
- mCenterLabel(new QLabel),
- mZoomText(new QLineEdit),
- mZoomLabel(new QLabel),
- mMapActionGroup(new QActionGroup(dynamic_cast(this))),
- mSetLeftTop(true),
- mLayerList(),
- mLeftTop(),
- mRightBottom() {
- this->setWindowTitle(tr(u8"LAMP影像处理软件"));
- mUi->setupUi(dynamic_cast(this));
- setupWindow();
- setupTaskWindow();
- setupLayers();
- setupStatusBar();
- setupActions();
- setRightToolbox();
-
- //mUi->panAction->trigger();
- //mUi->layerList->setCurrentItem(mLayerList.first());
+ this->show();// 强制显示窗口
+ // 绑定消息显示
+ RasterMessageShow::RasterWidgetMessageShow* messageshow = RasterMessageShow::RasterWidgetMessageShow::getInstance(this);
+ messageshow->bandingTextBrowserMessage(this->mUi->textBrowserMessage);
+ connect(mUi->actioncloseAllRasterFile, SIGNAL(triggered()), this, SLOT(onactioncloseAllRasterFile_triggered()));
+
+ this->mUi->toolBar->hide();
+ this->mUi->dockWidget_Map->hide();
+ this->mUi->dockWidget->hide();
+ this->mUi->statusbar->hide();
+ this->mUi->dockWidget_2->hide();
+ this->mUi->dockWidget_3->hide();
+
+ }
+
+ RasterMainWidget::~RasterMainWidget() {
+ delete mUi;
+ delete mMapConvas;
+ delete mScaleText;
+ delete mScaleLabel;
+ delete mCenterText;
+ delete mCenterLabel;
+ }
+
+ void
+ RasterMainWidget::setupTaskWindow() {
+ mUi->taskTable->setColumnCount(5);
+ mUi->taskTable->setHorizontalHeaderLabels(QStringList{
+ "名称", "范围", "zoom值", "数据源", "进度"
+ });
+ mUi->taskTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
+ }
+
+ void
+ RasterMainWidget::setupActions() {
+ mMapActionGroup->addAction(mUi->panAction);
+ mMapActionGroup->addAction(mUi->zoomInAction);
+ mMapActionGroup->addAction(mUi->zoomOutAction);
+ mMapActionGroup->addAction(mUi->selectAction);
+
+ mUi->selectAction->setEnabled(false);
+
+ QObject::connect(mUi->panAction, &QAction::triggered, this, &RasterMainWidget::panHandle);
+ QObject::connect(mUi->zoomInAction, &QAction::triggered, this, &RasterMainWidget::zoomInHandle);
+ QObject::connect(mUi->zoomOutAction, &QAction::triggered, this, &RasterMainWidget::zoomOutHandle);
+
+ QObject::connect(mUi->refreshAction, &QAction::triggered, this, &RasterMainWidget::refreshHandle);
+ QObject::connect(mUi->sponsorAction, &QAction::triggered, this, &RasterMainWidget::sponsorHandle);
+ QObject::connect(mUi->selectAction, &QAction::triggered, this, &RasterMainWidget::selectHandle);
+ QObject::connect(mUi->downloadAction, &QAction::triggered, this, &RasterMainWidget::createDownloadTask);
+ QObject::connect(mUi->drawlineAction, &QAction::triggered, this, &RasterMainWidget::drawlineHandle);
+ }
+
+ void RasterMainWidget::setupWindow() {
+ mUi->mapCanvasLayout->addWidget(mMapConvas);
+ //setFixedSize(size());
+ //setWindowFlags(windowFlags() | Qt::WindowMinMaxButtonsHint | Qt::WindowSystemMenuHint);
+
+ QObject::connect(mMapConvas, &MapCanvas::zoomChanged, this, &RasterMainWidget::zoomChangedHandle);
+ QObject::connect(mMapConvas, &MapCanvas::clicked, this, &RasterMainWidget::clickedHandle);
+ QObject::connect(mMapConvas, &MapCanvas::mapCenterChanged, this, &RasterMainWidget::centerChangedHandle);
+ QObject::connect(mUi->layerList, &QListWidget::currentItemChanged, this, &RasterMainWidget::layerChanged);
+ QObject::connect(mUi->leftTopBtn, &QPushButton::clicked, this, &RasterMainWidget::leftTopClickedHandle);
+ QObject::connect(mUi->rightBottomBtn, &QPushButton::clicked, this, &RasterMainWidget::rightBottomClickedHandle);
+ }
+
+ void RasterMainWidget::setupStatusBar() {
+ /// 比例尺
+ mScaleLabel->setText("比例尺");
+ mScaleText->setText(QString("1cm : %1m").arg(mMapConvas->scale()));
+ mScaleText->setFixedWidth(150);
+ mScaleText->setReadOnly(true);
+ mUi->statusbar->addWidget(mScaleLabel);
+ mUi->statusbar->addWidget(mScaleText);
+
+ /// 空白间隔
+ mUi->statusbar->addWidget(spacerWiget(30));
+
+ /// zoom值
+ mZoomLabel->setText("Zoom值=>");
+ mZoomText->setText(QString("%1").arg(mMapConvas->zoomValue()));
+ mZoomText->setFixedWidth(80);
+ mZoomText->setReadOnly(true);
+ mUi->statusbar->addWidget(mZoomLabel);
+ mUi->statusbar->addWidget(mZoomText);
+
+ /// 空白间隔
+ mUi->statusbar->addWidget(spacerWiget(30));
+
+ /// 视图中心坐标
+ mCenterLabel->setText("视图中心坐标=>");
+ PointXY center = mMapConvas->mapCenter();
+ mCenterText->setText(QString("lon:%1, lat:%2").arg(center.x()).arg(center.y()));
+ mCenterText->setFixedWidth(300);
+ mCenterText->setReadOnly(true);
+ mUi->statusbar->addWidget(mCenterLabel);
+ mUi->statusbar->addWidget(mCenterText);
+ }
+
+ void RasterMainWidget::setupLayers() {
+ initMaps();
+ auto i = mMaps.constBegin();
+ for (; i != mMaps.constEnd(); ++i) {
+ mLayerList.append(new QListWidgetItem(i.key(), mUi->layerList));
+ }
+ }
+
+ void
+ RasterMainWidget::initMaps() {
+ if (false&&mMaps.isEmpty()) {
+ mMaps = QHash{
+ {"Openstreet地图", new TmsLayer(OSTNormalMap, "ostnormalmap", mMapConvas)},
+ {"高德地图", new TmsLayer(GaodeNormapMap, "gaodenormalmap", mMapConvas)}
+ };
+ }
+ }
+
+ void RasterMainWidget::setRightToolbox()
+ {
+ this->toolboxDockWidget = new QDockWidget(tr(u8"工具箱"), this);
+ toolboxDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+ toolBoxWidget = new ToolBoxWidget(this);
+ toolboxDockWidget->setWidget(toolBoxWidget);
+ addDockWidget(Qt::LeftDockWidgetArea, toolboxDockWidget);
+ setDockOptions(QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks);
+ this->initToolbox();
+ }
+
+ void RasterMainWidget::initToolbox()
+ {
+ QString appPath = QCoreApplication::applicationDirPath();
+ QString pluginPath = JoinPath(appPath, "Toolbox");
+
+ toolBoxWidget->initToolbox(pluginPath);
-}
+ }
-RasterMainWidget::~RasterMainWidget() {
- delete mUi;
- delete mMapConvas;
- delete mScaleText;
- delete mScaleLabel;
- delete mCenterText;
- delete mCenterLabel;
-}
+ QWidget* RasterMainWidget::spacerWiget(int width) const {
+ auto spacer = new QWidget{};
+ spacer->setHidden(true);
+ spacer->setVisible(true);
+ spacer->setFixedWidth(width);
-void
-RasterMainWidget::setupTaskWindow() {
- mUi->taskTable->setColumnCount(5);
- mUi->taskTable->setHorizontalHeaderLabels(QStringList{
- "名称", "范围", "zoom值", "数据源", "进度"
- });
- mUi->taskTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
-}
+ return spacer;
+ }
-void
-RasterMainWidget::setupActions() {
- mMapActionGroup->addAction(mUi->panAction);
- mMapActionGroup->addAction(mUi->zoomInAction);
- mMapActionGroup->addAction(mUi->zoomOutAction);
- mMapActionGroup->addAction(mUi->selectAction);
+ void
+ RasterMainWidget::panHandle(bool checked) {
+ mMapConvas->selectTool(QString{ "pan_tool" });
+ }
- mUi->selectAction->setEnabled(false);
+ void
+ RasterMainWidget::zoomInHandle(bool checked) {
+ mMapConvas->selectTool(QString{ "zoomin_tool" });
+ }
- QObject::connect(mUi->panAction, &QAction::triggered, this, &RasterMainWidget::panHandle);
- QObject::connect(mUi->zoomInAction, &QAction::triggered, this, &RasterMainWidget::zoomInHandle);
- QObject::connect(mUi->zoomOutAction, &QAction::triggered, this, &RasterMainWidget::zoomOutHandle);
- QObject::connect(mUi->tutorialAction, &QAction::triggered, this, &RasterMainWidget::tutorialHanle);
- QObject::connect(mUi->srcAction, &QAction::triggered, this, &RasterMainWidget::srcHandle);
- QObject::connect(mUi->refreshAction, &QAction::triggered, this, &RasterMainWidget::refreshHandle);
- QObject::connect(mUi->sponsorAction, &QAction::triggered, this, &RasterMainWidget::sponsorHandle);
- QObject::connect(mUi->selectAction, &QAction::triggered, this, &RasterMainWidget::selectHandle);
- QObject::connect(mUi->downloadAction, &QAction::triggered, this, &RasterMainWidget::createDownloadTask);
- QObject::connect(mUi->drawlineAction, &QAction::triggered, this, &RasterMainWidget::drawlineHandle);
-}
+ void
+ RasterMainWidget::zoomOutHandle(bool checked) {
+ mMapConvas->selectTool(QString{ "zoomout_tool" });
+ }
-void RasterMainWidget::setupWindow() {
- mUi->mapCanvasLayout->addWidget(mMapConvas);
- //setFixedSize(size());
- //setWindowFlags(windowFlags() | Qt::WindowMinMaxButtonsHint | Qt::WindowSystemMenuHint);
+ void RasterMainWidget::drawlineHandle(bool checked)
+ {
+ mMapConvas->selectTool("drawline_tool");
+ }
- QObject::connect(mMapConvas, &MapCanvas::zoomChanged, this, &RasterMainWidget::zoomChangedHandle);
- QObject::connect(mMapConvas, &MapCanvas::clicked, this, &RasterMainWidget::clickedHandle);
- QObject::connect(mMapConvas, &MapCanvas::mapCenterChanged, this, &RasterMainWidget::centerChangedHandle);
- QObject::connect(mUi->layerList, &QListWidget::currentItemChanged, this, &RasterMainWidget::layerChanged);
- QObject::connect(mUi->leftTopBtn, &QPushButton::clicked, this, &RasterMainWidget::leftTopClickedHandle);
- QObject::connect(mUi->rightBottomBtn, &QPushButton::clicked, this, &RasterMainWidget::rightBottomClickedHandle);
+
-
- RasterMessageShow::RasterWidgetMessageShow* messageshow = RasterMessageShow::RasterWidgetMessageShow::getInstance(this);
- messageshow->bandingTextBrowserMessage(this->mUi->textBrowserMessage);
+ void
+ RasterMainWidget::sponsorHandle(bool checked) {
+ auto* window = new SponsorWindow(dynamic_cast(this));
+ window->exec();
+ window->deleteLater();
+ }
+
+ void
+ RasterMainWidget::refreshHandle(bool checked) {
+ mMapConvas->refreshMap();
+ }
+
+ void
+ RasterMainWidget::selectHandle(bool checked) {
+ mMapConvas->selectTool(QString{ "select_tool" });
+ }
+
+ void
+ RasterMainWidget::centerChangedHandle(LAMPMainWidget::PointXY pos) {
+ mCenterText->setText(QString("lon:%1, lat:%2").arg(pos.x()).arg(pos.y()));
+ }
+
+ void
+ RasterMainWidget::zoomChangedHandle(int zoom) {
+ mZoomText->setText(QString("%1").arg(zoom));
+ mScaleText->setText(QString("1cm:%1m").arg(this->mMapConvas->scale()));
+ }
+
+ void
+ RasterMainWidget::clickedHandle(LAMPMainWidget::PointXY pos) {
+ QString posText = QString("%1, %2").arg(pos.x()).arg(pos.y());
+ if (mSetLeftTop) {
+ mUi->leftTopText->setText(posText);
+ mLeftTop = pos;
+ }
+ else {
+ mUi->rightBottomText->setText(posText);
+ mRightBottom = pos;
+ }
+ }
+
+ void
+ RasterMainWidget::leftTopClickedHandle() {
+ mSetLeftTop = true;
+ mUi->selectAction->trigger();
+ }
+
+ void
+ RasterMainWidget::rightBottomClickedHandle() {
+ mSetLeftTop = false;
+ mUi->selectAction->trigger();
+ }
+
+ void
+ RasterMainWidget::layerChanged(QListWidgetItem* current, QListWidgetItem* previous) {
+ auto mapName = current->text();
+ if (!mMaps.contains(mapName)) {
+ qDebug() << mapName << "不支持";
+ return;
+ }
+
+ auto layer = mMaps.value(mapName);
+ auto i = mMaps.begin();
+ for (; i != mMaps.end(); ++i) {
+ if (i.key() == mapName) {
+ i.value()->setVisiblity(true);
+ qDebug() << i.key() << i.value()->isVisible();
+ continue;
+ }
+
+ i.value()->setVisiblity(false);
+ }
+
+ mMapConvas->addLayer(layer);
+ mMapConvas->setCurrentLayer(layer->id());
+ mMapConvas->refreshMap();
+
+ zoomChangedHandle(mMapConvas->zoomValue());
+ centerChangedHandle(mMapConvas->mapCenter());
+ }
+
+ void
+ RasterMainWidget::createDownloadTask() {
+ auto taskWindow = new TaskWindow(dynamic_cast(this));
+ taskWindow->exec();
+ taskWindow->deleteLater();
+ }
+
+ void
+ RasterMainWidget::changeTaskTable(int row, int col, QString text) {
+ mUi->taskTable->takeItem(row, col);
+ mUi->taskTable->setItem(row, col, new QTableWidgetItem(text));
+ }
-}
+ void RasterMainWidget::on_drawArea_triggered()
+ {
+ mMapConvas->selectTool("drawarea_tool");
+ }
-void RasterMainWidget::setupStatusBar() {
- /// 比例尺
- mScaleLabel->setText("比例尺");
- mScaleText->setText(QString("1cm : %1m").arg(mMapConvas->scale()));
- mScaleText->setFixedWidth(150);
- mScaleText->setReadOnly(true);
- mUi->statusbar->addWidget(mScaleLabel);
- mUi->statusbar->addWidget(mScaleText);
- /// 空白间隔
- mUi->statusbar->addWidget(spacerWiget(30));
+ void RasterMainWidget::on_addPlaneaction_triggered()
+ {
+ mMapConvas->selectTool("addplane_tool");
+ }
- /// zoom值
- mZoomLabel->setText("Zoom值=>");
- mZoomText->setText(QString("%1").arg(mMapConvas->zoomValue()));
- mZoomText->setFixedWidth(80);
- mZoomText->setReadOnly(true);
- mUi->statusbar->addWidget(mZoomLabel);
- mUi->statusbar->addWidget(mZoomText);
-
- /// 空白间隔
- mUi->statusbar->addWidget(spacerWiget(30));
-
- /// 视图中心坐标
- mCenterLabel->setText("视图中心坐标=>");
- PointXY center = mMapConvas->mapCenter();
- mCenterText->setText(QString("lon:%1, lat:%2").arg(center.x()).arg(center.y()));
- mCenterText->setFixedWidth(300);
- mCenterText->setReadOnly(true);
- mUi->statusbar->addWidget(mCenterLabel);
- mUi->statusbar->addWidget(mCenterText);
-}
-
-void RasterMainWidget::setupLayers() {
- initMaps();
- auto i = mMaps.constBegin();
- for (; i != mMaps.constEnd(); ++i) {
- mLayerList.append(new QListWidgetItem(i.key(), mUi->layerList));
- }
-}
-
-void
-RasterMainWidget::initMaps() {
- if (mMaps.isEmpty()) {
- mMaps = QHash{
- {"Openstreet地图", new TmsLayer(OSTNormalMap, "ostnormalmap", mMapConvas)},
- {"高德地图", new TmsLayer(GaodeNormapMap, "gaodenormalmap", mMapConvas)}
- };
- }
-}
-
-void RasterMainWidget::setRightToolbox()
+void RasterMainWidget::onactioncloseAllRasterFile_triggered()
{
- this->toolboxDockWidget = new QDockWidget(tr(u8"工具箱"), this);
- toolboxDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- toolBoxWidget = new ToolBoxWidget(this);
- toolboxDockWidget->setWidget(toolBoxWidget);
- addDockWidget(Qt::LeftDockWidgetArea, toolboxDockWidget);
- setDockOptions(QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks);
- this->initToolbox();
-}
-
-void RasterMainWidget::initToolbox()
-{
- QString appPath = QCoreApplication::applicationDirPath();
- QString pluginPath = JoinPath(appPath, "Toolbox");
-
- toolBoxWidget->initToolbox(pluginPath);
-
-
-}
-
-QWidget *RasterMainWidget::spacerWiget(int width) const {
- auto spacer = new QWidget{};
- spacer->setHidden(true);
- spacer->setVisible(true);
- spacer->setFixedWidth(width);
-
- return spacer;
-}
-
-void
-RasterMainWidget::panHandle(bool checked) {
- mMapConvas->selectTool(QString{"pan_tool"});
-}
-
-void
-RasterMainWidget::zoomInHandle(bool checked) {
- mMapConvas->selectTool(QString{"zoomin_tool"});
-}
-
-void
-RasterMainWidget::zoomOutHandle(bool checked) {
- mMapConvas->selectTool(QString{"zoomout_tool"});
-}
-
-void RasterMainWidget::drawlineHandle(bool checked)
-{
- mMapConvas->selectTool("drawline_tool");
-}
-
-void
-RasterMainWidget::tutorialHanle(bool checked) {
- if (!QDesktopServices::openUrl(tutorialUrl())) {
- QMessageBox::critical(dynamic_cast(this), "异常", "未能打开系统浏览器");
- }
-}
-
-void
-RasterMainWidget::srcHandle(bool checked) {
- if (!QDesktopServices::openUrl(srcUrl())) {
- QMessageBox::critical(dynamic_cast(this), "异常", "未能打开系统浏览器");
- }
-}
-
-void
-RasterMainWidget::sponsorHandle(bool checked) {
- auto *window = new SponsorWindow(dynamic_cast(this));
- window->exec();
- window->deleteLater();
-}
-
-void
-RasterMainWidget::refreshHandle(bool checked) {
- mMapConvas->refreshMap();
-}
-
-void
-RasterMainWidget::selectHandle(bool checked) {
- mMapConvas->selectTool(QString{"select_tool"});
-}
-
-void
-RasterMainWidget::centerChangedHandle(LAMPMainWidget::PointXY pos) {
- mCenterText->setText(QString("lon:%1, lat:%2").arg(pos.x()).arg(pos.y()));
-}
-
-void
-RasterMainWidget::zoomChangedHandle(int zoom) {
- mZoomText->setText(QString("%1").arg(zoom));
- mScaleText->setText(QString("1cm:%1m").arg(this->mMapConvas->scale()));
-}
-
-void
-RasterMainWidget::clickedHandle(LAMPMainWidget::PointXY pos) {
- QString posText = QString("%1, %2").arg(pos.x()).arg(pos.y());
- if (mSetLeftTop) {
- mUi->leftTopText->setText(posText);
- mLeftTop = pos;
- } else {
- mUi->rightBottomText->setText(posText);
- mRightBottom = pos;
- }
-}
-
-void
-RasterMainWidget::leftTopClickedHandle() {
- mSetLeftTop = true;
- mUi->selectAction->trigger();
-}
-
-void
-RasterMainWidget::rightBottomClickedHandle() {
- mSetLeftTop = false;
- mUi->selectAction->trigger();
-}
-
-void
-RasterMainWidget::layerChanged(QListWidgetItem *current, QListWidgetItem *previous) {
- auto mapName = current->text();
- if (!mMaps.contains(mapName)) {
- qDebug() << mapName << "不支持";
- return;
- }
-
- auto layer = mMaps.value(mapName);
- auto i = mMaps.begin();
- for (; i != mMaps.end(); ++i) {
- if (i.key() == mapName) {
- i.value()->setVisiblity(true);
- qDebug() << i.key() << i.value()->isVisible();
- continue;
- }
-
- i.value()->setVisiblity(false);
- }
-
- mMapConvas->addLayer(layer);
- mMapConvas->setCurrentLayer(layer->id());
- mMapConvas->refreshMap();
-
- zoomChangedHandle(mMapConvas->zoomValue());
- centerChangedHandle(mMapConvas->mapCenter());
-}
-
-void
-RasterMainWidget::createDownloadTask() {
- auto taskWindow = new TaskWindow(dynamic_cast(this));
- taskWindow->exec();
- taskWindow->deleteLater();
-}
-
-void
-RasterMainWidget::changeTaskTable(int row, int col, QString text) {
- mUi->taskTable->takeItem(row, col);
- mUi->taskTable->setItem(row, col, new QTableWidgetItem(text));
-}
-
-
-void RasterMainWidget::on_drawArea_triggered()
-{
- mMapConvas->selectTool("drawarea_tool");
-}
-
-
-void RasterMainWidget::on_addPlaneaction_triggered()
-{
- mMapConvas->selectTool("addplane_tool");
+ CloseAllGDALRaster();
}
QTableWidget* RasterMainWidget::getTaskTable()
diff --git a/RasterMainWidgetGUI/RasterMainWidget/RasterMainWidget.h b/RasterMainWidgetGUI/RasterMainWidget/RasterMainWidget.h
index a64eb49..0ece4a1 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/RasterMainWidget.h
+++ b/RasterMainWidgetGUI/RasterMainWidget/RasterMainWidget.h
@@ -52,8 +52,7 @@ namespace LAMPMainWidget {
void zoomInHandle(bool checked);
void zoomOutHandle(bool checked);
void drawlineHandle(bool checked);
- void tutorialHanle(bool checked);
- void srcHandle(bool checked);
+
void sponsorHandle(bool checked);
void refreshHandle(bool checked);
void selectHandle(bool checked);
@@ -70,14 +69,10 @@ namespace LAMPMainWidget {
private:
QWidget* spacerWiget(int width) const;
- protected:
- static QString tutorialUrl();
- static QString srcUrl();
-
private slots:
void on_drawArea_triggered();
void on_addPlaneaction_triggered();
-
+ void onactioncloseAllRasterFile_triggered();
private:
Ui::RasterMainWidget* mUi;
MapCanvas* mMapConvas;
diff --git a/RasterMainWidgetGUI/RasterMainWidget/RasterMainWidget.ui b/RasterMainWidgetGUI/RasterMainWidget/RasterMainWidget.ui
index af85019..bfcfbae 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/RasterMainWidget.ui
+++ b/RasterMainWidgetGUI/RasterMainWidget/RasterMainWidget.ui
@@ -12,8 +12,8 @@
0
0
- 906
- 609
+ 898
+ 580
@@ -84,8 +84,8 @@
0
0
- 906
- 23
+ 898
+ 22
@@ -136,6 +134,9 @@
+
+ false
+
toolBar
@@ -377,6 +378,85 @@ p, li { white-space: pre-wrap; }
+
+
+ Qt::LeftToRight
+
+
+ 地图窗口
+
+
+ 1
+
+
+
+
+
+ 10
+ 0
+ 502
+ 274
+
+
+
+
+ 0
+ 0
+
+
+
+ 0
+
+
+
+ 地图
+
+
+ -
+
+
+
+
+
+
+ 任务
+
+
+
+
+ 0
+ 0
+ 1431
+ 871
+
+
+
+ -
+
+
+
+
+
+
+
+
+
使用教程
@@ -513,6 +593,11 @@ p, li { white-space: pre-wrap; }
飞机
+
+
+ 释放影像文件
+
+
diff --git a/RasterMainWidgetGUI/RasterMainWidget/gaodenormalprovider.cpp b/RasterMainWidgetGUI/RasterMainWidget/gaodenormalprovider.cpp
index cdcdf7d..116e44b 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/gaodenormalprovider.cpp
+++ b/RasterMainWidgetGUI/RasterMainWidget/gaodenormalprovider.cpp
@@ -4,17 +4,18 @@
namespace LAMPMainWidget {
-GaodeNormalProvider::GaodeNormalProvider(QObject *parent)
- : TmsProvider(parent) {
- initCache();
-}
+ GaodeNormalProvider::GaodeNormalProvider(QObject* parent)
+ : TmsProvider(parent) {
+ initCache();
+ }
-QString
-GaodeNormalProvider::tileUrl(const LAMPMainWidget::PointXY &pos, int zoom) const {
- QString urlFmt = {R"(http://wprd01.is.autonavi.com/appmaptile?style=6&x=%1&y=%2&z=%3)"};
- return QString(urlFmt).arg(pos.x()).arg(pos.y()).arg(zoom);
-}
-//http://wprd01.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=1&style=6
+ QString
+ GaodeNormalProvider::tileUrl(const LAMPMainWidget::PointXY& pos, int zoom) const {
+
+ QString urlFmt = { R"(http://wprd01.is.autonavi.com/appmaptile?style=6&x=%1&y=%2&z=%3)" };
+ return QString(urlFmt).arg(pos.x()).arg(pos.y()).arg(zoom);
+ }
+ //http://wprd01.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=1&style=6
}
diff --git a/RasterMainWidgetGUI/RasterMainWidget/mapcanvas.cpp b/RasterMainWidgetGUI/RasterMainWidget/mapcanvas.cpp
index 0b2b783..498be61 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/mapcanvas.cpp
+++ b/RasterMainWidgetGUI/RasterMainWidget/mapcanvas.cpp
@@ -15,287 +15,292 @@
namespace LAMPMainWidget {
-PointXY
-MapCanvas::defaultMapCenter() {
- return PointXY{116.4074, 39.9042};
-}
+ PointXY
+ MapCanvas::defaultMapCenter() {
+ return PointXY{ 116.4074, 39.9042 };
+ }
-MapCanvas::MapCanvas(QWidget *parent)
- : QGraphicsView(parent),
- mScene(nullptr),
- mMapExtent(),
- mViewExtent(),
- mDragRect(),
- mIsDragging(false),
- mLayers(),
- mCurrentLayer(nullptr),
- mCrs(nullptr),
- mMapCenter(defaultMapCenter()),
- mZoomValue(kDefaultZoomValue),
- mLastXY(),
- mMapUpdateTimer(nullptr),
- mCurrentTool(nullptr),
- mMapTools() {
- setAutoFillBackground(true);
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setMouseTracking(true);
- setFocusPolicy(Qt::StrongFocus);
- mScene = new QGraphicsScene();
- setScene(mScene);
- mMapUpdateTimer = new QTimer();
- QObject::connect(mMapUpdateTimer, &QTimer::timeout, [this]() {
- this->mScene->update();
- });
- mMapUpdateTimer->start(200);
- setupTools();
- this->startTimer(1000);
-}
+ MapCanvas::MapCanvas(QWidget* parent)
+ : QGraphicsView(parent),
+ mScene(nullptr),
+ mMapExtent(),
+ mViewExtent(),
+ mDragRect(),
+ mIsDragging(false),
+ mLayers(),
+ mCurrentLayer(nullptr),
+ mCrs(nullptr),
+ mMapCenter(defaultMapCenter()),
+ mZoomValue(kDefaultZoomValue),
+ mLastXY(),
+ mMapUpdateTimer(nullptr),
+ mCurrentTool(nullptr),
+ mMapTools() {
-MapCanvas::~MapCanvas() {
- mLayers.clear();
- delete mScene;
- delete mCurrentLayer;
- delete mMapUpdateTimer;
-}
+ setAutoFillBackground(true);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setMouseTracking(true);
+ setFocusPolicy(Qt::StrongFocus);
+ mScene = new QGraphicsScene();
+ setScene(mScene);
+ mMapUpdateTimer = new QTimer();
+ QObject::connect(mMapUpdateTimer, &QTimer::timeout, [this]() {
+ this->mScene->update();
+ });
+ mMapUpdateTimer->start(200);
+ setupTools();
+ this->startTimer(1000);
+ }
-void
-MapCanvas::mousePressEvent(QMouseEvent *event) {
- if (mCurrentTool) {
- mCurrentTool->execute(event);
- }
- QGraphicsView::mousePressEvent(event);
-}
+ MapCanvas::~MapCanvas() {
+ mLayers.clear();
+ delete mScene;
+ delete mCurrentLayer;
+ delete mMapUpdateTimer;
+ }
-void
-MapCanvas::mouseReleaseEvent(QMouseEvent *event) {
- if (mCurrentTool) {
- mCurrentTool->execute(event);
- }
- QGraphicsView::mouseReleaseEvent(event);
-}
+ void
+ MapCanvas::mousePressEvent(QMouseEvent* event) {
+ if (mCurrentTool) {
+ mCurrentTool->execute(event);
+ }
+ QGraphicsView::mousePressEvent(event);
+ }
-void
-MapCanvas::wheelEvent(QWheelEvent *event) {
- int delta = event->angleDelta().y() / 120;
- int zoom = zoomValue();
- zoom += delta;
- setZoomValue(zoom);
-}
+ void
+ MapCanvas::mouseReleaseEvent(QMouseEvent* event) {
+ if (mCurrentTool) {
+ mCurrentTool->execute(event);
+ }
+ QGraphicsView::mouseReleaseEvent(event);
+ }
-void
-MapCanvas::resizeEvent(QResizeEvent *event) {
- updateViewExtent(true);
-}
+ void
+ MapCanvas::wheelEvent(QWheelEvent* event) {
+ int delta = event->angleDelta().y() / 120;
+ int zoom = zoomValue();
+ zoom += delta;
+ setZoomValue(zoom);
+ }
-void MapCanvas::mouseMoveEvent(QMouseEvent *event)
-{
- if (mCurrentTool) {
- mCurrentTool->execute(event);
- }
- QGraphicsView::mouseMoveEvent(event);
-}
+ void
+ MapCanvas::resizeEvent(QResizeEvent* event) {
+ updateViewExtent(true);
+ }
-void
-MapCanvas::refreshMap() {
- QMapIterator iterator(mLayers);
- while (iterator.hasNext()) {
- iterator.next();
- iterator.value()->map()->setViewExtent(mViewExtent);
- iterator.value()->update();
- }
- mScene->update();
-}
+ void MapCanvas::mouseMoveEvent(QMouseEvent* event)
+ {
+ if (mCurrentTool) {
+ mCurrentTool->execute(event);
+ }
+ QGraphicsView::mouseMoveEvent(event);
+ }
-void
-MapCanvas::addLayer(MapLayer *const layer) {
- if (!layer)
- return;
+ void
+ MapCanvas::refreshMap() {
+ QMapIterator iterator(mLayers);
+ while (iterator.hasNext()) {
+ iterator.next();
+ iterator.value()->map()->setViewExtent(mViewExtent);
+ iterator.value()->update();
+ }
+ mScene->update();
+ }
- if (mLayers.contains(layer->id())) {
- qWarning() << layer->id() << "图层已存在";
- return;
- }
+ void
+ MapCanvas::addLayer(MapLayer* const layer) {
+ if (!layer)
+ return;
- mLayers.insert(layer->id(), layer);
- if (mLayers.count() == 1) {
- setCurrentLayer(layer->id());
- }
- mScene->addItem(layer->map());
- refreshMap();
-}
+ if (mLayers.contains(layer->id())) {
+ qWarning() << layer->id() << "图层已存在";
+ return;
+ }
-void
-MapCanvas::setZoomValue(const int zoom) {
- mZoomValue = normalizeZoom(zoom);
- zoomChanged(mZoomValue);
+ mLayers.insert(layer->id(), layer);
+ if (mLayers.count() == 1) {
+ setCurrentLayer(layer->id());
+ }
+ mScene->addItem(layer->map());
+ refreshMap();
+ }
- /// 更新每个图层的zoom值
- QMapIterator iterator(mLayers);
- while (iterator.hasNext()) {
- iterator.next();
- iterator.value()->setZoomValue(mZoomValue);
- }
+ void
+ MapCanvas::setZoomValue(const int zoom) {
+ mZoomValue = normalizeZoom(zoom);
+ zoomChanged(mZoomValue);
- /// 更新可视区域的内容
- updateViewExtent(true);
-}
+ /// 更新每个图层的zoom值
+ QMapIterator iterator(mLayers);
+ while (iterator.hasNext()) {
+ iterator.next();
+ iterator.value()->setZoomValue(mZoomValue);
+ }
-void
-MapCanvas::updateViewExtent(bool reset) {
- if (!mCurrentLayer) {
- qDebug() << "未设置当前图层,视图区域无法更新";
- return;
- }
+ /// 更新可视区域的内容
+ updateViewExtent(true);
+ }
- if (reset) {
- /// 重置视图区域
- mScene->setSceneRect(mCurrentLayer->extent());
- QRectF testrect=mCurrentLayer->extent();
- mViewExtent.setRect(0, 0, 0, 0);
- mViewExtent.setSize(size());
- PointXY crsCenter = mCrs->forward(mMapCenter);
- QPointF mapCenter{crsCenter.x() / resolution(), crsCenter.y() / resolution()};
- QPointF offset = mapCenter - mViewExtent.center();
- mViewExtent.translate(offset.x(), offset.y());
- } else {
- /// 视图偏移并重置偏移属性
- mViewExtent.translate(-mDragRect.width(), -mDragRect.height());
- mDragRect.setRect(0, 0, 0, 0);
+ void
+ MapCanvas::updateViewExtent(bool reset) {
+ if (!mCurrentLayer) {
+ qDebug() << "未设置当前图层,视图区域无法更新";
+ return;
+ }
- /// 更新地图可视区域中心点
- QPointF mapCenter = mViewExtent.center();
- PointXY crsCenter{mapCenter.x() * resolution(), mapCenter.y() * resolution()};
- mMapCenter = mCrs->inverse(crsCenter);
- mapCenterChanged(mMapCenter);
- }
+ if (reset) {
+ /// 重置视图区域
+ mScene->setSceneRect(mCurrentLayer->extent());
+ QRectF testrect = mCurrentLayer->extent();
+ mViewExtent.setRect(0, 0, 0, 0);
+ mViewExtent.setSize(size());
+ PointXY crsCenter = mCrs->forward(mMapCenter);
+ QPointF mapCenter{ crsCenter.x() / resolution(), crsCenter.y() / resolution() };
+ QPointF offset = mapCenter - mViewExtent.center();
+ mViewExtent.translate(offset.x(), offset.y());
+ }
+ else {
+ qDebug() << "视图区域更新 平移范围 x ,y "<<-mDragRect.width()<<" , "<<-mDragRect.height() ;
+ /// 视图偏移并重置偏移属性
+ mViewExtent.translate(-mDragRect.width(), -mDragRect.height());
+ mDragRect.setRect(0, 0, 0, 0);
- /// 刷新地图
- centerOn(mViewExtent.center());
- refreshMap();
-}
+ /// 更新地图可视区域中心点
+ QPointF mapCenter = mViewExtent.center();
+ PointXY crsCenter{ mapCenter.x() * resolution(), mapCenter.y() * resolution() };
+ mMapCenter = mCrs->inverse(crsCenter);
+ mapCenterChanged(mMapCenter);
+ }
-void
-MapCanvas::setCrs(const CRS *const crs) {
- mCrs = crs;
- crsChanged();
- updateViewExtent(true);
-}
+ /// 刷新地图
+ centerOn(mViewExtent.center());
+ refreshMap();
+ }
-void
-MapCanvas::setCurrentLayer(const QString &id) {
- if (!mLayers.contains(id)) {
- qWarning() << "未添加图层=>" << id;
- return;
- }
- mCurrentLayer = mLayers[id];
- if (!mCrs) {
- setCrs(&mCurrentLayer->crs());
- }
- updateViewExtent(true);
-}
+ void
+ MapCanvas::setCrs(const CRS* const crs) {
+ mCrs = crs;
+ crsChanged();
+ updateViewExtent(true);
+ }
-double
-MapCanvas::scale() const {
- return logicalDpiX() * resolution() * 39.37 / 100;;
-}
+ void
+ MapCanvas::setCurrentLayer(const QString& id) {
+ if (!mLayers.contains(id)) {
+ qWarning() << "未添加图层=>" << id;
+ return;
+ }
+ mCurrentLayer = mLayers[id];
+ if (!mCrs) {
+ setCrs(&mCurrentLayer->crs());
+ }
+ updateViewExtent(true);
+ }
-double
-MapCanvas::resolution() const {
- if (!mCurrentLayer) {
- qWarning() << "未设置当前图层,无法获取分辨率";
- return 0;
- }
+ double
+ MapCanvas::scale() const {
+ return logicalDpiX() * resolution() * 39.37 / 100;;
+ }
- return mCurrentLayer->resolution();
-}
+ double
+ MapCanvas::resolution() const {
+ if (!mCurrentLayer) {
+ qWarning() << "未设置当前图层,无法获取分辨率";
+ return 0;
+ }
-int
-MapCanvas::zoomValue() const {
- if (!mCurrentLayer) {
- qWarning() << "未设置当前图层,默认返回zoom值为0";
- return 0;
- }
+ return mCurrentLayer->resolution();
+ }
- return mCurrentLayer->zoomValue();
-}
+ int
+ MapCanvas::zoomValue() const {
+ if (!mCurrentLayer) {
+ qWarning() << "未设置当前图层,默认返回zoom值为0";
+ return 0;
+ }
-int
-MapCanvas::normalizeZoom(const int zoom) const {
- int z{};
- if (zoom <= kMinZoomValue) {
- z = kMinZoomValue;
- } else if (z >= kMaxZoomValue) {
- z = kMaxZoomValue;
- } else {
- z = zoom;
- }
+ return mCurrentLayer->zoomValue();
+ }
- return z;
-}
+ int
+ MapCanvas::normalizeZoom(const int zoom) const {
+ int z{};
+ if (zoom <= kMinZoomValue) {
+ z = kMinZoomValue;
+ }
+ else if (z >= kMaxZoomValue) {
+ z = kMaxZoomValue;
+ }
+ else {
+ z = zoom;
+ }
-PointXY
-MapCanvas::pixel2Lonlat(const QPointF &point) const {
- QPointF scenePoint = mapToScene(QPoint{static_cast(point.x()), static_cast(point.y())});
- QPointF mapPoint{scenePoint.x() * resolution(), scenePoint.y() * resolution()};
- PointXY crsPoint = mCrs->inverse(PointXY{mapPoint});
- qDebug() << "坐标装换=>{" << point << "=>" << crsPoint << "}";
- return crsPoint;
-}
+ return z;
+ }
-bool
-MapCanvas::selectTool(const QString &tool) {
- if (!mMapTools.contains(tool)) {
- qWarning() << QString("%1工具不存在").arg(tool);
- return false;
- }
+ PointXY
+ MapCanvas::pixel2Lonlat(const QPointF& point) const {
+ QPointF scenePoint = mapToScene(QPoint{ static_cast(point.x()), static_cast(point.y()) });
+ QPointF mapPoint{ scenePoint.x() * resolution(), scenePoint.y() * resolution() };
+ PointXY crsPoint = mCrs->inverse(PointXY{ mapPoint });
+ qDebug() << "坐标装换=>{" << point << "=>" << crsPoint << "}";
+ return crsPoint;
+ }
- auto toolPtr = mMapTools.value(tool);
- if (mCurrentTool) {
- mCurrentTool->deSetup();
- }
- mCurrentTool = toolPtr;
- toolPtr->setup();
+ bool
+ MapCanvas::selectTool(const QString& tool) {
+ if (!mMapTools.contains(tool)) {
+ qWarning() << QString("%1工具不存在").arg(tool);
+ return false;
+ }
- return true;
-}
+ auto toolPtr = mMapTools.value(tool);
+ if (mCurrentTool) {
+ mCurrentTool->deSetup();
+ }
+ mCurrentTool = toolPtr;
+ toolPtr->setup();
-void MapCanvas::timerEvent(QTimerEvent *event)
-{
- MapToolAddplane *maptoolAddplane=dynamic_cast(mMapTools["addplane_tool"]);
- QList planes=maptoolAddplane->getPlanes();
- foreach(MapAutoplane *plane,planes){
- plane->updatePos();
- }
-}
+ return true;
+ }
-void
-MapCanvas::setupTools() {
- auto panTool = new MapToolPan(this);
- mMapTools.insert(panTool->id(), panTool);
+ void MapCanvas::timerEvent(QTimerEvent* event)
+ {
+ MapToolAddplane* maptoolAddplane = dynamic_cast(mMapTools["addplane_tool"]);
+ QList planes = maptoolAddplane->getPlanes();
+ foreach(MapAutoplane * plane, planes) {
+ plane->updatePos();
+ }
+ }
- auto zoominTool = new MapToolZoomIn(this);
- mMapTools.insert(zoominTool->id(), zoominTool);
+ void
+ MapCanvas::setupTools() {
+ auto panTool = new MapToolPan(this);
+ mMapTools.insert(panTool->id(), panTool);
- auto zoomoutTool = new MapToolZoomOut(this);
- mMapTools.insert(zoomoutTool->id(), zoomoutTool);
+ auto zoominTool = new MapToolZoomIn(this);
+ mMapTools.insert(zoominTool->id(), zoominTool);
- auto selectTool = new MapToolSelect(this);
- mMapTools.insert(selectTool->id(), selectTool);
+ auto zoomoutTool = new MapToolZoomOut(this);
+ mMapTools.insert(zoomoutTool->id(), zoomoutTool);
- auto drawlineTool=new MapToolDrawline(this);
- mMapTools.insert(drawlineTool->id(),drawlineTool);
+ auto selectTool = new MapToolSelect(this);
+ mMapTools.insert(selectTool->id(), selectTool);
- auto drawareTool=new MapToolDrawarea(this);
- mMapTools.insert(drawareTool->id(),drawareTool);
+ auto drawlineTool = new MapToolDrawline(this);
+ mMapTools.insert(drawlineTool->id(), drawlineTool);
- auto addplaneTool=new MapToolAddplane(this);
- mMapTools.insert(addplaneTool->id(),addplaneTool);
+ auto drawareTool = new MapToolDrawarea(this);
+ mMapTools.insert(drawareTool->id(), drawareTool);
+
+ auto addplaneTool = new MapToolAddplane(this);
+ mMapTools.insert(addplaneTool->id(), addplaneTool);
-
-}
+
+ }
}
diff --git a/RasterMainWidgetGUI/RasterMainWidget/mapcanvas.h b/RasterMainWidgetGUI/RasterMainWidget/mapcanvas.h
index c781e8d..dd4e580 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/mapcanvas.h
+++ b/RasterMainWidgetGUI/RasterMainWidget/mapcanvas.h
@@ -20,170 +20,171 @@
#include
namespace LAMPMainWidget {
-class MapLayer;
-class MapTool;
-/**
- * 地图容器类,继承自QGraphicsView。
- * 整个地图的渲染都是基于“Qt GraphicsView Framework”设计。
- */
-class MapCanvas : public QGraphicsView {
- Q_OBJECT
+ class MapLayer;
+ class MapTool;
+ /**
+ * 地图容器类,继承自QGraphicsView。
+ * 整个地图的渲染都是基于“Qt GraphicsView Framework”设计。
+ */
+ class MapCanvas : public QGraphicsView {
+ Q_OBJECT
- signals:
- void zoomChanged(int zoom);
- void crsChanged();
- void clicked(PointXY pos);
- void mapCenterChanged(PointXY pos);
+ signals:
+ void zoomChanged(int zoom);
+ void crsChanged();
+ void clicked(PointXY pos);
+ void mapCenterChanged(PointXY pos);
- friend class MapToolPan;
- friend class MapToolZoomIn;
- friend class MapToolZoomOut;
- friend class MapToolSelect;
+ friend class MapToolPan;
+ friend class MapToolZoomIn;
+ friend class MapToolZoomOut;
+ friend class MapToolSelect;
- public:
- explicit MapCanvas(QWidget *parent = nullptr);
- ~MapCanvas() override;
+ public:
+ explicit MapCanvas(QWidget* parent = nullptr);
+ ~MapCanvas() override;
- public:
- /**
- * 刷新地图容器,这会更新每一个显示的图层的内容
- */
- void refreshMap();
+ public:
+ /**
+ * 刷新地图容器,这会更新每一个显示的图层的内容
+ */
+ void refreshMap();
- /**
- * 向容器中添加图层,默认情况下容器会使用首个图层的坐标系作为自身的坐标系
- * @param layer 图层对象
- */
- void addLayer(MapLayer *layer);
+ /**
+ * 向容器中添加图层,默认情况下容器会使用首个图层的坐标系作为自身的坐标系
+ * @param layer 图层对象
+ */
+ void addLayer(MapLayer* layer);
- /**
- * 获取地图容器的比例尺
- * @return 容器的比例尺
- */
- double scale() const;
+ /**
+ * 获取地图容器的比例尺
+ * @return 容器的比例尺
+ */
+ double scale() const;
- /**
- * 获取地图容器的解析度
- * @return
- */
- double resolution() const;
+ /**
+ * 获取地图容器的解析度
+ * @return
+ */
+ double resolution() const;
- /**
- * 获取容器的zoom值
- * @return 容器的zoom值
- */
- int zoomValue() const;
+ /**
+ * 获取容器的zoom值
+ * @return 容器的zoom值
+ */
+ int zoomValue() const;
- /**
- * 设置容器的zoom值
- * @param zoom zoom值
- */
- void setZoomValue(int zoom);
+ /**
+ * 设置容器的zoom值
+ * @param zoom zoom值
+ */
+ void setZoomValue(int zoom);
- /**
- * 获取容器当前所显示的地图区域
- * @return 当前所显示地图区域
- */
- const QRectF &viewExtent() const { return mViewExtent; }
+ /**
+ * 获取容器当前所显示的地图区域
+ * @return 当前所显示地图区域
+ */
+ const QRectF& viewExtent() const { return mViewExtent; }
- /**
- * 设置容器坐标系,设置过后会更新所有图层坐标系。
- * 默认会对容器中的图层做投影变换处理
- * @param crs 坐标系
- */
- void setCrs(const CRS *crs);
+ /**
+ * 设置容器坐标系,设置过后会更新所有图层坐标系。
+ * 默认会对容器中的图层做投影变换处理
+ * @param crs 坐标系
+ */
+ void setCrs(const CRS* crs);
- /**
- * 获取地图容器的坐标系
- * @return 地图容器坐标系
- */
- const CRS &crs() const { return *mCrs; }
+ /**
+ * 获取地图容器的坐标系
+ * @return 地图容器坐标系
+ */
+ const CRS& crs() const { return *mCrs; }
- /**
- * 设置地图容器的当前选中图层
- * @param id 图层的id
- */
- void setCurrentLayer(const QString &id);
+ /**
+ * 设置地图容器的当前选中图层
+ * @param id 图层的id
+ */
+ void setCurrentLayer(const QString& id);
- /**
- * 获取地图容器当前选中图层
- * @return 当前选中图层
- */
- const MapLayer *currentLayer() { return mCurrentLayer; }
+ /**
+ * 获取地图容器当前选中图层
+ * @return 当前选中图层
+ */
+ const MapLayer* currentLayer() { return mCurrentLayer; }
- /**
- * 获取地图当前视图中心点经纬度坐标
- * @return 视图中心点经纬度坐标
- */
- const PointXY &mapCenter() const { return mMapCenter; }
+ /**
+ * 获取地图当前视图中心点经纬度坐标
+ * @return 视图中心点经纬度坐标
+ */
+ const PointXY& mapCenter() const { return mMapCenter; }
- /**
- * 选择地图工具
- * @param tool 工具名称
- * @return 是否选择成功
- */
- bool selectTool(const QString &tool);
+ /**
+ * 选择地图工具
+ * @param tool 工具名称
+ * @return 是否选择成功
+ */
+ bool selectTool(const QString& tool);
- void timerEvent(QTimerEvent *event);
+ void timerEvent(QTimerEvent* event);
- protected:
- /**
- * 更新容器的可视化区域。
- * 每次拖动操作和resize事件会调用该方法
- */
- void updateViewExtent(bool reset = false);
+ protected:
+ /**
+ * 更新容器的可视化区域。
+ * 每次拖动操作和resize事件会调用该方法
+ */
+ void updateViewExtent(bool reset = false);
- /**
- * 将屏幕坐标转换为经纬度坐标
- * @param point 屏幕上点
- * @return 经纬度坐标
- */
- PointXY pixel2Lonlat(const QPointF &point) const;
+ /**
+ * 将屏幕坐标转换为经纬度坐标
+ * @param point 屏幕上点
+ * @return 经纬度坐标
+ */
+ PointXY pixel2Lonlat(const QPointF& point) const;
- /**
- * 初始设置地图必须具备的工具
- */
- void setupTools();
+ /**
+ * 初始设置地图必须具备的工具
+ */
+ void setupTools();
- private:
- /**
- * 确保zoom值在限定的范围之内
- * @param zoom 待设置zoom值
- * @return 可使用zoom值
- */
- int normalizeZoom(int zoom) const;
+ private:
+ /**
+ * 确保zoom值在限定的范围之内
+ * @param zoom 待设置zoom值
+ * @return 可使用zoom值
+ */
+ int normalizeZoom(int zoom) const;
- protected:
- void mousePressEvent(QMouseEvent *event) override;
- void mouseReleaseEvent(QMouseEvent *event) override;
- void wheelEvent(QWheelEvent *event) override;
- void resizeEvent(QResizeEvent *event) override;
- void mouseMoveEvent(QMouseEvent *event) override;
+ protected:
+ void mousePressEvent(QMouseEvent* event) override;
+ void mouseReleaseEvent(QMouseEvent* event) override;
+ void wheelEvent(QWheelEvent* event) override;
+ void resizeEvent(QResizeEvent* event) override;
+ void mouseMoveEvent(QMouseEvent* event) override;
- protected:
- QGraphicsScene *mScene;
- QRectF mMapExtent;
- QRectF mViewExtent;
- QRectF mDragRect;
- bool mIsDragging;
- QMap mLayers;
- MapLayer *mCurrentLayer;
- const CRS *mCrs;
- PointXY mMapCenter;
- int mZoomValue;
- PointXY mLastXY;
- QTimer *mMapUpdateTimer;
- MapTool *mCurrentTool;
- QHash mMapTools;
+ protected:
+ QGraphicsScene* mScene;
+ QRectF mMapExtent;
+ QRectF mViewExtent;
+ QRectF mDragRect;
+ bool mIsDragging;
+ QMap mLayers;
+ MapLayer* mCurrentLayer;
+ const CRS* mCrs;
+ PointXY mMapCenter;
+ int mZoomValue;
+ PointXY mLastXY;
+ QTimer* mMapUpdateTimer;
+ MapTool* mCurrentTool;
+ QHash mMapTools;
- private:
- const static int kDefaultZoomValue{8};
- static const int kMaxZoomValue{20};
- static const int kMinZoomValue{1};
+ private:
+ const static int kDefaultZoomValue{ 8 };
+ static const int kMaxZoomValue{ 20 };
+ static const int kMinZoomValue{ 1 };
- protected:
- static PointXY defaultMapCenter();
-};
+ protected:
+ // 设置默认地图中心点
+ static PointXY defaultMapCenter();
+ };
}
diff --git a/RasterMainWidgetGUI/RasterMainWidget/mapcanvasmap.cpp b/RasterMainWidgetGUI/RasterMainWidget/mapcanvasmap.cpp
index 248701c..a55bc79 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/mapcanvasmap.cpp
+++ b/RasterMainWidgetGUI/RasterMainWidget/mapcanvasmap.cpp
@@ -10,28 +10,28 @@
namespace LAMPMainWidget {
-void
-MapCanvasMap::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
- if (!mLayer->provider().hasContent()) {
- return;
- }
- painter->drawImage(mViewExtent.topLeft(), mLayer->provider().preparedImage());
-}
+ void
+ MapCanvasMap::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
+ if (!mLayer->provider().hasContent()) {
+ return;
+ }
+ painter->drawImage(mViewExtent.topLeft(), mLayer->provider().preparedImage());
+ }
-QRectF
-MapCanvasMap::boundingRect() const {
- auto width = mViewExtent.size().width();
- auto height = mViewExtent.size().height();
- return mViewExtent + QMarginsF(1024, 1024, 1024, 1024);
-}
+ QRectF
+ MapCanvasMap::boundingRect() const {
+ auto width = mViewExtent.size().width();
+ auto height = mViewExtent.size().height();
+ return mViewExtent + QMarginsF(1024, 1024, 1024, 1024);
+ }
-void MapCanvasMap::setViewExtent(const QRectF &rect) {
- //qDebug() << "更新图层显示对象边界=>" << rect;
- if (rect != mViewExtent) {
- prepareGeometryChange();
- mViewExtent = rect;
- }
-}
+ void MapCanvasMap::setViewExtent(const QRectF& rect) {
+ //qDebug() << "更新图层显示对象边界=>" << rect;
+ if (rect != mViewExtent) {
+ prepareGeometryChange();
+ mViewExtent = rect;
+ }
+ }
}
diff --git a/RasterMainWidgetGUI/RasterMainWidget/maplayer.cpp b/RasterMainWidgetGUI/RasterMainWidget/maplayer.cpp
index ca05d87..db3926c 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/maplayer.cpp
+++ b/RasterMainWidgetGUI/RasterMainWidget/maplayer.cpp
@@ -7,84 +7,84 @@
namespace LAMPMainWidget {
-MapLayer::MapLayer(
- const QString &id,
- LAMPMainWidget::CRS *crs,
- LAMPMainWidget::MapCanvas *mapCanvas)
- : mId(id),
- mCrs(crs),
- mZValue(-1),
- mZoomValue(kDefaultZoomValue),
- mProvider(nullptr),
- mMapCanvasMap(new MapCanvasMap(this)),
- mMapCanvas(mapCanvas) {
-
-}
-
-MapLayer::~MapLayer() {
- delete mCrs;
- delete mProvider;
-}
-
-MapLayer::MapLayer(const MapLayer &other) {
- mId = other.mId;
- mZValue = other.mZValue;
- mCrs = other.mCrs;
- mMapCanvas = other.mMapCanvas;
-}
-
-MapLayer::MapLayer(MapLayer &&other) noexcept {
- mId = other.mId;
- mZValue = other.mZValue;
- mCrs = other.mCrs;
- mMapCanvas = other.mMapCanvas;
-
- other.mId = QString{};
- other.mCrs = nullptr;
- other.mZValue = 0;
- other.mMapCanvas = nullptr;
-}
-
-MapLayer &
-MapLayer::operator=(const MapLayer &other) {
- if (this != &other) {
- mId = other.mId;
- mZValue = other.mZValue;
- mCrs = other.mCrs;
- mMapCanvas = other.mMapCanvas;
- }
-
- return *this;
-}
-
-MapLayer &
-MapLayer::operator=(MapLayer &&other) noexcept {
- if (this != &other) {
- mId = other.mId;
- mZValue = other.mZValue;
- mCrs = other.mCrs;
- mMapCanvas = other.mMapCanvas;
-
- other.mId = QString{};
- other.mCrs = nullptr;
- other.mZValue = 0;
- other.mMapCanvas = nullptr;
- }
-
- return *this;
-}
-
-void
-MapLayer::update() {
- if(!isVisible()){
- qDebug() << id() << "=>图层不显示,跳过刷新操作";
- mMapCanvasMap->hide();
- return;
- }
- //qDebug() << "刷新图层内容=>" << mMapCanvas->viewExtent()<createTask(mMapCanvas->viewExtent(), mZoomValue);
- mMapCanvasMap->show();
-}
+ MapLayer::MapLayer(
+ const QString& id,
+ LAMPMainWidget::CRS* crs,
+ LAMPMainWidget::MapCanvas* mapCanvas)
+ : mId(id),
+ mCrs(crs),
+ mZValue(-1),
+ mZoomValue(kDefaultZoomValue),
+ mProvider(nullptr),
+ mMapCanvasMap(new MapCanvasMap(this)),
+ mMapCanvas(mapCanvas) {
+
+ }
+
+ MapLayer::~MapLayer() {
+ delete mCrs;
+ delete mProvider;
+ }
+
+ MapLayer::MapLayer(const MapLayer& other) {
+ mId = other.mId;
+ mZValue = other.mZValue;
+ mCrs = other.mCrs;
+ mMapCanvas = other.mMapCanvas;
+ }
+
+ MapLayer::MapLayer(MapLayer&& other) noexcept {
+ mId = other.mId;
+ mZValue = other.mZValue;
+ mCrs = other.mCrs;
+ mMapCanvas = other.mMapCanvas;
+
+ other.mId = QString{};
+ other.mCrs = nullptr;
+ other.mZValue = 0;
+ other.mMapCanvas = nullptr;
+ }
+
+ MapLayer&
+ MapLayer::operator=(const MapLayer& other) {
+ if (this != &other) {
+ mId = other.mId;
+ mZValue = other.mZValue;
+ mCrs = other.mCrs;
+ mMapCanvas = other.mMapCanvas;
+ }
+
+ return *this;
+ }
+
+ MapLayer&
+ MapLayer::operator=(MapLayer&& other) noexcept {
+ if (this != &other) {
+ mId = other.mId;
+ mZValue = other.mZValue;
+ mCrs = other.mCrs;
+ mMapCanvas = other.mMapCanvas;
+
+ other.mId = QString{};
+ other.mCrs = nullptr;
+ other.mZValue = 0;
+ other.mMapCanvas = nullptr;
+ }
+
+ return *this;
+ }
+
+ void
+ MapLayer::update() {
+ if (!isVisible()) {
+ qDebug() << id() << "=>图层不显示,跳过刷新操作";
+ mMapCanvasMap->hide();
+ return;
+ }
+ //qDebug() << "刷新图层内容=>" << mMapCanvas->viewExtent()<createTask(mMapCanvas->viewExtent(), mZoomValue);
+ mMapCanvasMap->show();
+ }
}
diff --git a/RasterMainWidgetGUI/RasterMainWidget/maplayer.h b/RasterMainWidgetGUI/RasterMainWidget/maplayer.h
index d07f03b..9db549b 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/maplayer.h
+++ b/RasterMainWidgetGUI/RasterMainWidget/maplayer.h
@@ -9,141 +9,141 @@
#include
namespace LAMPMainWidget {
-class MapCanvas;
+ class MapCanvas;
-/*
- * 地图容器中的图层,属于数据的集合并不包含任何显示需要的数据
- */
-class MapLayer {
- public:
- MapLayer(const QString &id, CRS *crs, MapCanvas *mapCanvas);
- MapLayer(const MapLayer &other);
- MapLayer(MapLayer &&other) noexcept;
- virtual ~MapLayer();
- MapLayer &operator=(const MapLayer &other);
- MapLayer &operator=(MapLayer &&other) noexcept;
+ /*
+ * 地图容器中的图层,属于数据的集合并不包含任何显示需要的数据
+ */
+ class MapLayer {
+ public:
+ MapLayer(const QString& id, CRS* crs, MapCanvas* mapCanvas);
+ MapLayer(const MapLayer& other);
+ MapLayer(MapLayer&& other) noexcept;
+ virtual ~MapLayer();
+ MapLayer& operator=(const MapLayer& other);
+ MapLayer& operator=(MapLayer&& other) noexcept;
- public:
- /*
- * 获取图层的id
- * @return 图层id字符串
- */
- const QString &id() const { return mId; }
+ public:
+ /*
+ * 获取图层的id
+ * @return 图层id字符串
+ */
+ const QString& id() const { return mId; }
- /*
- * 获取图层的显示z值
- * @return z值
- */
- const int zValue() const { return mZValue; }
+ /*
+ * 获取图层的显示z值
+ * @return z值
+ */
+ const int zValue() const { return mZValue; }
- /*
- * 获取图层的坐标系
- * @return 图层的坐标系
- */
- const CRS &crs() const { return *mCrs; }
+ /*
+ * 获取图层的坐标系
+ * @return 图层的坐标系
+ */
+ const CRS& crs() const { return *mCrs; }
- /*
- * 获取图层所属的map容器
- * @return 图层所属的map容器
- */
- const MapCanvas &mapCanvas() const { return *mMapCanvas; }
+ /*
+ * 获取图层所属的map容器
+ * @return 图层所属的map容器
+ */
+ const MapCanvas& mapCanvas() const { return *mMapCanvas; }
- /*
- * 获取图层的数据提供对象
- * @return 图层的数据提供对象
- */
- const LayerProvider &provider() const { return *mProvider; }
+ /*
+ * 获取图层的数据提供对象
+ * @return 图层的数据提供对象
+ */
+ const LayerProvider& provider() const { return *mProvider; }
- /*
- * 设置图层的id
- * @param id 图层id
- */
- void setId(const QString &id) { mId = id; }
+ /*
+ * 设置图层的id
+ * @param id 图层id
+ */
+ void setId(const QString& id) { mId = id; }
- /*
- * 设置图层的z值
- * @param zValue 图层z值
- */
- void setZValue(const int zValue) { mZValue = zValue; }
+ /*
+ * 设置图层的z值
+ * @param zValue 图层z值
+ */
+ void setZValue(const int zValue) { mZValue = zValue; }
- /*
- * 设置图层的坐标系
- * @param crs 图层坐标系
- */
- void setCrs(CRS *const crs) { mCrs = crs; }
+ /*
+ * 设置图层的坐标系
+ * @param crs 图层坐标系
+ */
+ void setCrs(CRS* const crs) { mCrs = crs; }
- /*
- * 设置图层的数据提供对象
- * @param provider 图层的数据提供对象
- */
- void setProvider(LayerProvider *const provider) { mProvider = provider; }
+ /*
+ * 设置图层的数据提供对象
+ * @param provider 图层的数据提供对象
+ */
+ void setProvider(LayerProvider* const provider) { mProvider = provider; }
- /*
- * 获取图层的pixel:m比例尺
- * @return 图层的分辨率
- */
- virtual double resolution() const = 0;
+ /*
+ * 获取图层的pixel:m比例尺
+ * @return 图层的分辨率
+ */
+ virtual double resolution() const = 0;
- /*
- * 获取图层的整个显示边界
- * @return 图层的显示边界
- */
- virtual QRectF extent() const = 0;
+ /*
+ * 获取图层的整个显示边界
+ * @return 图层的显示边界
+ */
+ virtual QRectF extent() const = 0;
- /*
- * 获取图层的当前zoom值
- * @return 图层的当前zoom值
- */
- int zoomValue() const { return mZoomValue; }
+ /*
+ * 获取图层的当前zoom值
+ * @return 图层的当前zoom值
+ */
+ int zoomValue() const { return mZoomValue; }
- /*
- * 设置图层的当前zoom值
- * @param zoom 图层zoom值
- */
- virtual void setZoomValue(int zoom) { mZoomValue = zoom; }
+ /*
+ * 设置图层的当前zoom值
+ * @param zoom 图层zoom值
+ */
+ virtual void setZoomValue(int zoom) { mZoomValue = zoom; }
- /*
- * 设置图层所属的地图容器
- * @param map 图层所属的地图容器
- */
- void setMap(MapCanvasMap *map) { mMapCanvasMap = map; }
+ /*
+ * 设置图层所属的地图容器
+ * @param map 图层所属的地图容器
+ */
+ void setMap(MapCanvasMap* map) { mMapCanvasMap = map; }
- /*
- * 获取图层的显示图元,这是图层最终的显示对象
- * @return 图层的显示图元
- */
- MapCanvasMap *map() const { return mMapCanvasMap; }
+ /*
+ * 获取图层的显示图元,这是图层最终的显示对象
+ * @return 图层的显示图元
+ */
+ MapCanvasMap* map() const { return mMapCanvasMap; }
- /*
- * 判断图层是否可显示
- * @return 图层是否可显示,true显示,false则不显示
- */
- bool isVisible() const {return mIsVisible;}
+ /*
+ * 判断图层是否可显示
+ * @return 图层是否可显示,true显示,false则不显示
+ */
+ bool isVisible() const { return mIsVisible; }
- /*
- * 设值图层的可显示属性
- * @param visible true为显示,false则不显示
- */
- void setVisiblity(bool visible) {mIsVisible = visible;}
+ /*
+ * 设值图层的可显示属性
+ * @param visible true为显示,false则不显示
+ */
+ void setVisiblity(bool visible) { mIsVisible = visible; }
- /*
- * 刷新图层内容
- * @return 刷新图层内容,true则成功,否则为失败
- */
- virtual void update();
+ /*
+ * 刷新图层内容
+ * @return 刷新图层内容,true则成功,否则为失败
+ */
+ virtual void update();
- protected:
- QString mId;
- CRS *mCrs;
- int mZValue;
- int mZoomValue;
- LayerProvider *mProvider;
- MapCanvasMap *mMapCanvasMap;
- const MapCanvas *mMapCanvas;
- bool mIsVisible{false};
+ protected:
+ QString mId;
+ CRS* mCrs;
+ int mZValue;
+ int mZoomValue;
+ LayerProvider* mProvider;
+ MapCanvasMap* mMapCanvasMap;
+ const MapCanvas* mMapCanvas;
+ bool mIsVisible{ false };
- private:
- const static int kDefaultZoomValue{10};
-};
+ private:
+ const static int kDefaultZoomValue{ 10 };
+ };
}
diff --git a/RasterMainWidgetGUI/RasterMainWidget/maptool.h b/RasterMainWidgetGUI/RasterMainWidget/maptool.h
index a2c5044..4ad7ee3 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/maptool.h
+++ b/RasterMainWidgetGUI/RasterMainWidget/maptool.h
@@ -3,40 +3,40 @@
#include
namespace LAMPMainWidget {
-class MapCanvas;
-/**
- * 地图的处理工具
- */
-class MapTool {
- public:
- MapTool(MapCanvas *mapCanvas) : mMapCanvas(mapCanvas) {}
- virtual ~MapTool();
+ class MapCanvas;
+ /**
+ * 地图的处理工具
+ */
+ class MapTool {
+ public:
+ MapTool(MapCanvas* mapCanvas) : mMapCanvas(mapCanvas) {}
+ virtual ~MapTool();
- public:
- /**
- * 具体的工具处理程序
- * @param event 鼠标事件
- */
- virtual void execute(QMouseEvent *event) = 0;
+ public:
+ /**
+ * 具体的工具处理程序
+ * @param event 鼠标事件
+ */
+ virtual void execute(QMouseEvent* event) = 0;
- /**
- * 提示将使用工具,此方法中可以为工具的环境做一些准备
- */
- virtual void setup() = 0;
+ /**
+ * 提示将使用工具,此方法中可以为工具的环境做一些准备
+ */
+ virtual void setup() = 0;
- /**
- * 当工具不使用时,将相关环境还原至原先状态
- */
- virtual void deSetup() = 0;
+ /**
+ * 当工具不使用时,将相关环境还原至原先状态
+ */
+ virtual void deSetup() = 0;
- /**
- * 获取工具的名称
- * @return 工具名称
- */
- virtual QString id() = 0;
+ /**
+ * 获取工具的名称
+ * @return 工具名称
+ */
+ virtual QString id() = 0;
- protected:
- MapCanvas *mMapCanvas;
-};
+ protected:
+ MapCanvas* mMapCanvas;
+ };
}
diff --git a/RasterMainWidgetGUI/RasterMainWidget/maptoolpan.cpp b/RasterMainWidgetGUI/RasterMainWidget/maptoolpan.cpp
index 8c73610..1fde61a 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/maptoolpan.cpp
+++ b/RasterMainWidgetGUI/RasterMainWidget/maptoolpan.cpp
@@ -6,39 +6,39 @@
namespace LAMPMainWidget {
-void
-MapToolPan::execute(QMouseEvent *event) {
- if(!(event->button() & Qt::LeftButton)){
- return;
- }
+ void
+ MapToolPan::execute(QMouseEvent* event) {
+ if (!(event->button() & Qt::LeftButton)) {
+ return;
+ }
- auto type = event->type();
- if (QEvent::MouseButtonPress == type) {
- mDragStartPos = event->pos();
- }
+ auto type = event->type();
+ if (QEvent::MouseButtonPress == type) {
+ mDragStartPos = event->pos();
+ }
- if (QEvent::MouseButtonRelease == type) {
- mDragEndPos = event->pos();
- QRectF dragRect{mDragStartPos, mDragEndPos};
- mMapCanvas->mDragRect = dragRect;
- mMapCanvas->updateViewExtent();
- }
-}
+ if (QEvent::MouseButtonRelease == type) {
+ mDragEndPos = event->pos();
+ QRectF dragRect{ mDragStartPos, mDragEndPos };
+ mMapCanvas->mDragRect = dragRect;
+ mMapCanvas->updateViewExtent();
+ }
+ }
-void
-MapToolPan::setup() {
- mMapCanvas->setDragMode(MapCanvas::DragMode::ScrollHandDrag);
-}
+ void
+ MapToolPan::setup() {
+ mMapCanvas->setDragMode(MapCanvas::DragMode::ScrollHandDrag);
+ }
-QString
-MapToolPan::id() {
- return QString{"pan_tool"};
-}
+ QString
+ MapToolPan::id() {
+ return QString{ "pan_tool" };
+ }
-void
-MapToolPan::deSetup() {
- mMapCanvas->setDragMode(MapCanvas::DragMode::NoDrag);
-}
+ void
+ MapToolPan::deSetup() {
+ mMapCanvas->setDragMode(MapCanvas::DragMode::NoDrag);
+ }
}
diff --git a/RasterMainWidgetGUI/RasterMainWidget/ostnormalprovider.cpp b/RasterMainWidgetGUI/RasterMainWidget/ostnormalprovider.cpp
index 6581e15..010f443 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/ostnormalprovider.cpp
+++ b/RasterMainWidgetGUI/RasterMainWidget/ostnormalprovider.cpp
@@ -10,9 +10,9 @@ OSTNormalProvider::OSTNormalProvider(QObject *parent)
}
QString
-OSTNormalProvider::tileUrl(const LAMPMainWidget::PointXY &pos, int zoom) const {
- QString urlFmt = {"https://tile.openstreetmap.org/%1/%2/%3.png"};
- return QString(urlFmt).arg(zoom).arg(pos.y()).arg(pos.x());
+OSTNormalProvider::tileUrl(const LAMPMainWidget::PointXY& pos, int zoom) const {
+ QString urlFmt = { "https://tile.openstreetmap.org/%1/%2/%3.png" };
+ return QString(urlFmt).arg(zoom).arg(pos.y()).arg(pos.x());
}
//https://tile.openstreetmap.org/{z}/{x}/{y}.png
}
diff --git a/RasterMainWidgetGUI/RasterMainWidget/taskwindow.cpp b/RasterMainWidgetGUI/RasterMainWidget/taskwindow.cpp
index 7c23a78..03c6798 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/taskwindow.cpp
+++ b/RasterMainWidgetGUI/RasterMainWidget/taskwindow.cpp
@@ -17,193 +17,192 @@
namespace LAMPMainWidget
{
- void
- DownloadTask::run()
- {
- auto currentLayer = dynamic_cast(mTaskInfo.layer);
- auto provider = dynamic_cast(¤tLayer->provider());
- auto tileSize = provider->tileSize();
+ void
+ DownloadTask::run()
+ {
+ auto currentLayer = dynamic_cast(mTaskInfo.layer);
+ auto provider = dynamic_cast(¤tLayer->provider());
+ auto tileSize = provider->tileSize();
- QHash tiles{};
- QSize imgSize{};
- if (!currentLayer->parseTiles(mTaskInfo.extent, mTaskInfo.zoom, tiles, imgSize)) {
- qCritical() << "瓦片路径解析错误";
- generateErrorRow();
- return;
- }
- generateSuccessRow();
+ QHash tiles{};
+ QSize imgSize{};
+ if (!currentLayer->parseTiles(mTaskInfo.extent, mTaskInfo.zoom, tiles, imgSize)) {
+ qCritical() << "瓦片路径解析错误";
+ generateErrorRow();
+ return;
+ }
+ generateSuccessRow();
- ImgWriter imgWriter{mTaskInfo.taskPath, imgSize};
- QByteArray tileData{};
- Network web{};
- auto item = tiles.constBegin();
- auto count = tiles.count();
- int completed{0};
- for (; item != tiles.constEnd(); ++item) {
- tileData = web.httpsRequest(item.value());
- if (tileData.isEmpty()) {
- qCritical() << item.value() << "下载数据为空";
- return;
- }
- ++completed;
- auto pos = QPoint(item.key().x() * tileSize.width(), item.key().y() * tileSize.height());
- if (!imgWriter.write(pos, tileData)) {
- qCritical() << "瓦片写出失败";
- }
- double progress = static_cast(completed) / count;
- auto progessStr = QString("%1").arg(progress * 100);
- mTaskInfo.display->takeItem(mRowId, 4);
- mTaskInfo.display->setItem(mRowId, 4,
- new QTableWidgetItem(QString("%1").arg(progress * 100)));
- // mTaskInfo.display->resizeColumnsToContents();
- // mTaskInfo.display->horizontalHeader()->setStretchLastSection(true);
- }
- }
+ ImgWriter imgWriter{ mTaskInfo.taskPath, imgSize };
+ QByteArray tileData{};
+ Network web{};
+ auto item = tiles.constBegin();
+ auto count = tiles.count();
+ int completed{ 0 };
+ for (; item != tiles.constEnd(); ++item) {
+ tileData = web.httpsRequest(item.value());
+ if (tileData.isEmpty()) {
+ qCritical() << item.value() << "下载数据为空";
+ return;
+ }
+ ++completed;
+ auto pos = QPoint(item.key().x() * tileSize.width(), item.key().y() * tileSize.height());
+ if (!imgWriter.write(pos, tileData)) {
+ qCritical() << "瓦片写出失败";
+ }
+ double progress = static_cast(completed) / count;
+ auto progessStr = QString("%1").arg(progress * 100);
+ mTaskInfo.display->takeItem(mRowId, 4);
+ mTaskInfo.display->setItem(mRowId, 4,new QTableWidgetItem(QString("%1").arg(progress * 100)));
+ // mTaskInfo.display->resizeColumnsToContents();
+ // mTaskInfo.display->horizontalHeader()->setStretchLastSection(true);
+ }
+ }
- void
- DownloadTask::generateCommonRow()
- {
- auto provider = dynamic_cast(&mTaskInfo.layer->provider());
- mRowId = mTaskInfo.display->rowCount();
- mTaskInfo.display->insertRow(mRowId);
- mTaskInfo.display->setItem(mRowId, 0, new QTableWidgetItem(mTaskInfo.taskName));
- mTaskInfo.display->setItem(mRowId, 1, new QTableWidgetItem(getExtentStr()));
- mTaskInfo.display->setItem(mRowId, 2, new QTableWidgetItem(QString("%1").arg(mTaskInfo.zoom)));
- mTaskInfo.display->setItem(mRowId, 3, new QTableWidgetItem(provider->id()));
- }
+ void
+ DownloadTask::generateCommonRow()
+ {
+ auto provider = dynamic_cast(&mTaskInfo.layer->provider());
+ mRowId = mTaskInfo.display->rowCount();
+ mTaskInfo.display->insertRow(mRowId);
+ mTaskInfo.display->setItem(mRowId, 0, new QTableWidgetItem(mTaskInfo.taskName));
+ mTaskInfo.display->setItem(mRowId, 1, new QTableWidgetItem(getExtentStr()));
+ mTaskInfo.display->setItem(mRowId, 2, new QTableWidgetItem(QString("%1").arg(mTaskInfo.zoom)));
+ mTaskInfo.display->setItem(mRowId, 3, new QTableWidgetItem(provider->id()));
+ }
- void
- DownloadTask::generateErrorRow()
- {
- generateCommonRow();
- mTaskInfo.display->setItem(mRowId, 4, new QTableWidgetItem("任务新建失败"));
- mTaskInfo.display->resizeColumnsToContents();
- }
+ void
+ DownloadTask::generateErrorRow()
+ {
+ generateCommonRow();
+ mTaskInfo.display->setItem(mRowId, 4, new QTableWidgetItem("任务新建失败"));
+ mTaskInfo.display->resizeColumnsToContents();
+ }
- void
- DownloadTask::generateSuccessRow()
- {
- generateCommonRow();
- mTaskInfo.display->setItem(mRowId, 4, new QTableWidgetItem("0.0%"));
- mTaskInfo.display->resizeColumnsToContents();
- }
+ void
+ DownloadTask::generateSuccessRow()
+ {
+ generateCommonRow();
+ mTaskInfo.display->setItem(mRowId, 4, new QTableWidgetItem("0.0%"));
+ mTaskInfo.display->resizeColumnsToContents();
+ }
- QString
- DownloadTask::getExtentStr()
- {
- auto leftTop = mTaskInfo.extent.topLeft();
- auto rightBottom = mTaskInfo.extent.bottomRight();
- return QString("[%1, %2], [%3, %4]").arg(leftTop.x()).arg(leftTop.y())
- .arg(rightBottom.x()).arg(rightBottom.y());
- }
+ QString
+ DownloadTask::getExtentStr()
+ {
+ auto leftTop = mTaskInfo.extent.topLeft();
+ auto rightBottom = mTaskInfo.extent.bottomRight();
+ return QString("[%1, %2], [%3, %4]").arg(leftTop.x()).arg(leftTop.y())
+ .arg(rightBottom.x()).arg(rightBottom.y());
+ }
- TaskWindow::TaskWindow(QWidget* parent)
- : mUi(new Ui::TaskWindow),
- mParent(dynamic_cast(parent)),
- mSavePath(),
- QDialog(parent)
- {
- mUi->setupUi(this);
- setupWindow();
- setupAction();
- }
+ TaskWindow::TaskWindow(QWidget* parent)
+ : mUi(new Ui::TaskWindow),
+ mParent(dynamic_cast(parent)),
+ mSavePath(),
+ QDialog(parent)
+ {
+ mUi->setupUi(this);
+ setupWindow();
+ setupAction();
+ }
- TaskWindow::~TaskWindow()
- {
- delete mUi;
- }
+ TaskWindow::~TaskWindow()
+ {
+ delete mUi;
+ }
- void
- TaskWindow::setupWindow()
- {
- setFixedSize(size());
- auto currentLayer = dynamic_cast(mParent->mMapConvas->currentLayer());
+ void
+ TaskWindow::setupWindow()
+ {
+ setFixedSize(size());
+ auto currentLayer = dynamic_cast(mParent->mMapConvas->currentLayer());
- auto minZoom = currentLayer->minZoom();
- auto maxZoom = currentLayer->maxZoom();
- for (auto i = minZoom; i <= maxZoom; ++i) {
- mUi->zoomValueCbx->addItem(QString("%1").arg(i), i);
- }
- mUi->leftTopText->setText(
- QString("%1, %2").arg(mParent->mLeftTop.x()).arg(mParent->mLeftTop.y()));
- mUi->rightBottomText->setText(
- QString("%1, %2").arg(mParent->mRightBottom.x()).arg(mParent->mRightBottom.y()));
- }
+ auto minZoom = currentLayer->minZoom();
+ auto maxZoom = currentLayer->maxZoom();
+ for (auto i = minZoom; i <= maxZoom; ++i) {
+ mUi->zoomValueCbx->addItem(QString("%1").arg(i), i);
+ }
+ mUi->leftTopText->setText(
+ QString("%1, %2").arg(mParent->mLeftTop.x()).arg(mParent->mLeftTop.y()));
+ mUi->rightBottomText->setText(
+ QString("%1, %2").arg(mParent->mRightBottom.x()).arg(mParent->mRightBottom.y()));
+ }
- void
- TaskWindow::setupAction()
- {
- QObject::connect(mUi->exitBtn, &QPushButton::clicked, this, &TaskWindow::close);
- QObject::connect(mUi->createBtn, &QPushButton::clicked, this, &TaskWindow::createTask);
- QObject::connect(mUi->saveDirBtn, &QPushButton::clicked, this, &TaskWindow::setupSaveDir);
- QObject::connect(mUi->taskNameText, &QLineEdit::textChanged, this, &TaskWindow::setupTaskName);
- QObject::connect(mUi->zoomValueCbx, QOverload::of(&QComboBox::currentIndexChanged),
- this, &TaskWindow::setupZoomValue);
- }
+ void
+ TaskWindow::setupAction()
+ {
+ QObject::connect(mUi->exitBtn, &QPushButton::clicked, this, &TaskWindow::close);
+ QObject::connect(mUi->createBtn, &QPushButton::clicked, this, &TaskWindow::createTask);
+ QObject::connect(mUi->saveDirBtn, &QPushButton::clicked, this, &TaskWindow::setupSaveDir);
+ QObject::connect(mUi->taskNameText, &QLineEdit::textChanged, this, &TaskWindow::setupTaskName);
+ QObject::connect(mUi->zoomValueCbx, QOverload::of(&QComboBox::currentIndexChanged),
+ this, &TaskWindow::setupZoomValue);
+ }
- void
- TaskWindow::createTask()
- {
- if (!taskInfoCheck()) {
- return;
- }
+ void
+ TaskWindow::createTask()
+ {
+ if (!taskInfoCheck()) {
+ return;
+ }
- mSavePath.append("/").append(mTaskName).append(".tiff");
- auto savePath = QDir::toNativeSeparators(mSavePath);
- auto extent = QRectF(QPointF(mParent->mLeftTop.x(), mParent->mLeftTop.y()),
- QPointF(mParent->mRightBottom.x(), mParent->mRightBottom.y()));
- auto tileInfo = TaskInfo{ mTaskName, savePath, extent,
- mZoomValue,
- mParent->mMapConvas->currentLayer(),
- mParent->getTaskTable()
- /*mParent->mUi->taskTable*/};
+ mSavePath.append("/").append(mTaskName).append(".tiff");
+ auto savePath = QDir::toNativeSeparators(mSavePath);
+ auto extent = QRectF(QPointF(mParent->mLeftTop.x(), mParent->mLeftTop.y()),
+ QPointF(mParent->mRightBottom.x(), mParent->mRightBottom.y()));
+ auto tileInfo = TaskInfo{ mTaskName, savePath, extent,
+ mZoomValue,
+ mParent->mMapConvas->currentLayer(),
+ mParent->getTaskTable()
+ /*mParent->mUi->taskTable*/ };
- auto task = new DownloadTask(tileInfo);
- QThreadPool::globalInstance()->start(task);
- close();
- }
+ auto task = new DownloadTask(tileInfo);
+ QThreadPool::globalInstance()->start(task);
+ close();
+ }
- void
- TaskWindow::setupSaveDir()
- {
- auto saveDir = QFileDialog::getExistingDirectory(dynamic_cast(this), "存储路径选择");
- if (saveDir.isEmpty()) {
- qWarning() << "未选择存储路径";
- return;
- }
+ void
+ TaskWindow::setupSaveDir()
+ {
+ auto saveDir = QFileDialog::getExistingDirectory(dynamic_cast(this), "存储路径选择");
+ if (saveDir.isEmpty()) {
+ qWarning() << "未选择存储路径";
+ return;
+ }
- mSavePath = saveDir;
- mUi->saveDirText->setText(mSavePath);
- }
+ mSavePath = saveDir;
+ mUi->saveDirText->setText(mSavePath);
+ }
- void
- TaskWindow::setupTaskName(const QString& text)
- {
- qDebug() << "任务名=>" << text;
- mTaskName = text;
- }
+ void
+ TaskWindow::setupTaskName(const QString& text)
+ {
+ qDebug() << "任务名=>" << text;
+ mTaskName = text;
+ }
- bool
- TaskWindow::taskInfoCheck()
- {
- if (mTaskName.isEmpty()) {
- QMessageBox::critical(dynamic_cast(this), "错误", "任务名称为空");
- return false;
- }
+ bool
+ TaskWindow::taskInfoCheck()
+ {
+ if (mTaskName.isEmpty()) {
+ QMessageBox::critical(dynamic_cast(this), "错误", "任务名称为空");
+ return false;
+ }
- if (mSavePath.isEmpty()) {
- QMessageBox::critical(dynamic_cast(this), "错误", "存储路径为空");
- return false;
- }
+ if (mSavePath.isEmpty()) {
+ QMessageBox::critical(dynamic_cast(this), "错误", "存储路径为空");
+ return false;
+ }
- return true;
- }
+ return true;
+ }
- void
- TaskWindow::setupZoomValue(int index)
- {
- auto zoom = mUi->zoomValueCbx->itemData(index).toInt();
- qDebug() << "设置下载任务zoom值=>" << zoom;
- mZoomValue = zoom;
- }
+ void
+ TaskWindow::setupZoomValue(int index)
+ {
+ auto zoom = mUi->zoomValueCbx->itemData(index).toInt();
+ qDebug() << "设置下载任务zoom值=>" << zoom;
+ mZoomValue = zoom;
+ }
}
diff --git a/RasterMainWidgetGUI/RasterMainWidget/tmslayer.cpp b/RasterMainWidgetGUI/RasterMainWidget/tmslayer.cpp
index cfe6180..1c45cba 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/tmslayer.cpp
+++ b/RasterMainWidgetGUI/RasterMainWidget/tmslayer.cpp
@@ -10,88 +10,91 @@
namespace LAMPMainWidget {
-TmsLayer::TmsLayer(LAMPMainWidget::TmsProviders provider,
- const QString &id,
- LAMPMainWidget::MapCanvas *mapCanvas,
- LAMPMainWidget::CRS *crs)
- : MapLayer(id, crs, mapCanvas) {
- setProvider(TmsProviderFactory::create(provider));
-}
+ TmsLayer::TmsLayer(LAMPMainWidget::TmsProviders provider,
+ const QString& id,
+ LAMPMainWidget::MapCanvas* mapCanvas,
+ LAMPMainWidget::CRS* crs)
+ : MapLayer(id, crs, mapCanvas) {
+ setProvider(TmsProviderFactory::create(provider));
+ }
-double
-TmsLayer::resolution() const {
- auto pd = dynamic_cast(&provider());
- auto sz = pd->tileSize();
- double length = crs().extent().width();
- double result = length / ((power2(zoomValue())) * sz.width());
+ double
+ TmsLayer::resolution() const {
+ auto pd = dynamic_cast(&provider());
+ auto sz = pd->tileSize();
+ double length = crs().extent().width();
+ double result = length / ((power2(zoomValue())) * sz.width());
#ifdef DEBUG
- qDebug() << "resolution=>" << result;
+ qDebug() << "resolution=>" << result;
#endif
- return result;
-}
+ return result;
+ }
-QRectF
-TmsLayer::extent() const {
- auto pd = dynamic_cast(&provider());
- QSize sz = pd->tileSize();
+ QRectF
+ TmsLayer::extent() const {
+ auto pd = dynamic_cast(&provider());
+ QSize sz = pd->tileSize();
- int width = power2(zoomValue()) * sz.width();
- int height = power2(zoomValue()) * sz.height();
+ int width = power2(zoomValue()) * sz.width();
+ int height = power2(zoomValue()) * sz.height();
-//#ifdef DEBUG
- // qDebug() << "layer extent=>{width:" << width << ", height:" << height << "}";
-//#endif
+ //#ifdef DEBUG
+ // qDebug() << "layer extent=>{width:" << width << ", height:" << height << "}";
+ //#endif
- return {0, 0, static_cast(width), static_cast(height)};
-}
+ return { 0, 0, static_cast(width), static_cast(height) };
+ }
-void
-TmsLayer::setZoomValue(int zoom) {
- int zoomValue{};
- if (zoom <= minZoom()) {
- zoomValue = minZoom();
- } else if (zoom >= maxZoom()) {
- zoomValue = maxZoom();
- } else {
- zoomValue = zoom;
- }
+ void
+ TmsLayer::setZoomValue(int zoom) {
+ int zoomValue{};
+ if (zoom <= minZoom()) {
+ zoomValue = minZoom();
+ }
+ else if (zoom >= maxZoom()) {
+ zoomValue = maxZoom();
+ }
+ else {
+ zoomValue = zoom;
+ }
- mZoomValue = zoomValue;
-}
+ mZoomValue = zoomValue;
+ }
-bool
-TmsLayer::parseTiles(const QRectF &rect, int zoom, QHash &tiles, QSize &size) const {
- auto pd = dynamic_cast(&provider());
- auto tileSize = pd->tileSize();
- auto resolution = mCrs->extent().width() / ((power2(zoom)) * tileSize.width());
+ bool
+ TmsLayer::parseTiles(const QRectF& rect, int zoom, QHash& tiles, QSize& size) const {
- auto crsLeftTop = mCrs->forward(PointXY(rect.topLeft()));
- auto crsRightBottom = mCrs->forward(PointXY(rect.bottomRight()));
+ auto pd = dynamic_cast(&provider());
+ auto tileSize = pd->tileSize();
+ auto resolution = mCrs->extent().width() / ((power2(zoom)) * tileSize.width());
- auto mapLeftTop = QPointF(crsLeftTop.x() / resolution, crsLeftTop.y() / resolution);
- auto mapRightBottom = QPointF(crsRightBottom.x() / resolution, crsRightBottom.y() / resolution);
- auto xMin = qFloor(mapLeftTop.x() / tileSize.width());
- auto xMax = qFloor(mapRightBottom.x() / tileSize.width());
- auto yMin = qFloor(mapLeftTop.y() / tileSize.height());
- auto yMax = qFloor(mapRightBottom.y() / tileSize.height());
- if((xMin > xMax) || (yMin > yMax)){
- qDebug() << "下载区边界错误";
- return false;
- }
+ auto crsLeftTop = mCrs->forward(PointXY(rect.topLeft()));
+ auto crsRightBottom = mCrs->forward(PointXY(rect.bottomRight()));
- size.setWidth((xMax - xMin + 1) * tileSize.width());
- size.setHeight((yMax - yMin + 1) * tileSize.height());
+ auto mapLeftTop = QPointF(crsLeftTop.x() / resolution, crsLeftTop.y() / resolution);
+ auto mapRightBottom = QPointF(crsRightBottom.x() / resolution, crsRightBottom.y() / resolution);
+ auto xMin = qFloor(mapLeftTop.x() / tileSize.width());
+ auto xMax = qFloor(mapRightBottom.x() / tileSize.width());
+ auto yMin = qFloor(mapLeftTop.y() / tileSize.height());
+ auto yMax = qFloor(mapRightBottom.y() / tileSize.height());
+ if ((xMin > xMax) || (yMin > yMax)) {
+ qDebug() << "下载区边界错误";
+ return false;
+ }
- for (int i = xMin; i <= xMax; ++i) {
- for (int j = yMin; j <= yMax; ++j) {
- auto url = pd->tileUrl(PointXY(i, j), zoom);
- tiles.insert(QPoint(i - xMin, j - yMin), url);
- }
- }
+ size.setWidth((xMax - xMin + 1) * tileSize.width());
+ size.setHeight((yMax - yMin + 1) * tileSize.height());
- return true;
-}
+ for (int i = xMin; i <= xMax; ++i) {
+ for (int j = yMin; j <= yMax; ++j) {
+ auto url = pd->tileUrl(PointXY(i, j), zoom);
+ tiles.insert(QPoint(i - xMin, j - yMin), url);
+ }
+ }
+
+ return true;
+ }
}
diff --git a/RasterMainWidgetGUI/RasterMainWidget/tmsprovider.cpp b/RasterMainWidgetGUI/RasterMainWidget/tmsprovider.cpp
index c2ca055..26c317f 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/tmsprovider.cpp
+++ b/RasterMainWidgetGUI/RasterMainWidget/tmsprovider.cpp
@@ -11,192 +11,192 @@
namespace LAMPMainWidget
{
- TileDownloadTask::TileDownloadTask(TileInfo tile, QObject* parent)
- : QObject(parent),
- mTile(std::move(tile))
- {
- }
+ TileDownloadTask::TileDownloadTask(TileInfo tile, QObject* parent)
+ : QObject(parent),
+ mTile(std::move(tile))
+ {
+ }
- void
- TileDownloadTask::run()
- {
- Network web{};
- QByteArray data = web.httpsRequest(mTile.url);
- mTile.data = data;
- tileReady(mTile);
- }
+ void
+ TileDownloadTask::run()
+ {
+ Network web{};
+ QByteArray data = web.httpsRequest(mTile.url);
+ mTile.data = data;
+ tileReady(mTile);
+ }
- TmsProvider::TmsProvider(QObject* parent)
- : LayerProvider(parent),
- mImage(nullptr)
- {
- if (!QFile::exists(mDbName)) {
- QFile dbFile{mDbName};
- dbFile.open(QIODevice::ReadWrite);
- dbFile.close();
- }
- }
+ TmsProvider::TmsProvider(QObject* parent)
+ : LayerProvider(parent),
+ mImage(nullptr)
+ {
+ if (!QFile::exists(mDbName)) {
+ QFile dbFile{ mDbName };
+ dbFile.open(QIODevice::ReadWrite);
+ dbFile.close();
+ }
+ }
- TmsProvider::~TmsProvider()
- {
- delete mImage;
- }
+ TmsProvider::~TmsProvider()
+ {
+ delete mImage;
+ }
- bool
- TmsProvider::initCache()
- {
- mDbConn = QSqlDatabase::addDatabase("QSQLITE", id());
- mDbConn.setDatabaseName(mDbName);
- if (!mDbConn.open()) {
- qCritical() << "缓存数据库打开失败";
- return false;
- }
+ bool
+ TmsProvider::initCache()
+ {
+ mDbConn = QSqlDatabase::addDatabase("QSQLITE", id());
+ mDbConn.setDatabaseName(mDbName);
+ if (!mDbConn.open()) {
+ qCritical() << "缓存数据库打开失败";
+ return false;
+ }
- QSqlQuery sql{mDbConn};
- if (!mDbConn.tables().contains(mTableName)) {
- sql.prepare(QString("create table %1 ("
- "id integer primary key autoincrement,"
- "provider text not null,"
- "zoom integer not null,"
- "position text not null,"
- "data blob not null"
- ")").arg(mTableName));
- if (!sql.exec()) {
- qCritical() << "缓存表创建失败" << sql.lastError().text();
- return false;
- }
- }
+ QSqlQuery sql{ mDbConn };
+ if (!mDbConn.tables().contains(mTableName)) {
+ sql.prepare(QString("create table %1 ("
+ "id integer primary key autoincrement,"
+ "provider text not null,"
+ "zoom integer not null,"
+ "position text not null,"
+ "data blob not null"
+ ")").arg(mTableName));
+ if (!sql.exec()) {
+ qCritical() << "缓存表创建失败" << sql.lastError().text();
+ return false;
+ }
+ }
- mDbConn.close();
- return true;
- }
+ mDbConn.close();
+ return true;
+ }
- QByteArray
- TmsProvider::getCache(const QPoint& pos, int zoom)
- {
- QByteArray res{};
- mDbConn.open();
- QSqlQuery select{mDbConn};
- select.prepare(QString("select data from %1 "
- "where provider = :provider "
- "and zoom = :zoom "
- "and position = :position "
- "order by id desc limit 1"
- ).arg(mTableName));
- select.bindValue(":provider", id());
- select.bindValue(":zoom", zoom);
- select.bindValue(":position", QString("%1:%2").arg(pos.x()).arg(pos.y()));
- if (!select.exec()) {
- qDebug() << pos << "查询失败=>" << select.lastError().text();
- mDbConn.close();
- return res;
- }
- if (!select.seek(0)) {
- mDbConn.close();
- return res;
- }
+ QByteArray
+ TmsProvider::getCache(const QPoint& pos, int zoom)
+ {
+ QByteArray res{};
+ mDbConn.open();
+ QSqlQuery select{ mDbConn };
+ select.prepare(QString("select data from %1 "
+ "where provider = :provider "
+ "and zoom = :zoom "
+ "and position = :position "
+ "order by id desc limit 1"
+ ).arg(mTableName));
+ select.bindValue(":provider", id());
+ select.bindValue(":zoom", zoom);
+ select.bindValue(":position", QString("%1:%2").arg(pos.x()).arg(pos.y()));
+ if (!select.exec()) {
+ qDebug() << pos << "查询失败=>" << select.lastError().text();
+ mDbConn.close();
+ return res;
+ }
+ if (!select.seek(0)) {
+ mDbConn.close();
+ return res;
+ }
- res = select.value(0).toByteArray();
- mDbConn.close();
- return res;
- }
+ res = select.value(0).toByteArray();
+ mDbConn.close();
+ return res;
+ }
- bool
- TmsProvider::addCache(const QPoint& pos, int zoom, QByteArray data)
- {
- if (data.isEmpty()) {
- qWarning() << "瓦片数据为空";
- return false;
- }
- mDbConn.open();
- QSqlQuery sql{mDbConn};
- sql.prepare(QString{
- "insert into %1 (provider, zoom, position, data)"
- "values( :provider, :zoom, :position, :data)"
- }.arg(mTableName));
- sql.bindValue(":tbname", mTableName);
- sql.bindValue(":provider", id());
- sql.bindValue(":zoom", zoom);
- sql.bindValue(":position", QString("%1:%2").arg(pos.x()).arg(pos.y()));
- sql.bindValue(":data", data);
+ bool
+ TmsProvider::addCache(const QPoint& pos, int zoom, QByteArray data)
+ {
+ if (data.isEmpty()) {
+ qWarning() << "瓦片数据为空";
+ return false;
+ }
+ mDbConn.open();
+ QSqlQuery sql{ mDbConn };
+ sql.prepare(QString{
+ "insert into %1 (provider, zoom, position, data)"
+ "values( :provider, :zoom, :position, :data)"
+ }.arg(mTableName));
+ sql.bindValue(":tbname", mTableName);
+ sql.bindValue(":provider", id());
+ sql.bindValue(":zoom", zoom);
+ sql.bindValue(":position", QString("%1:%2").arg(pos.x()).arg(pos.y()));
+ sql.bindValue(":data", data);
- if (!sql.exec()) {
- qCritical() << pos << "=>" << sql.lastError().text();
- mDbConn.close();
- return false;
- }
+ if (!sql.exec()) {
+ qCritical() << pos << "=>" << sql.lastError().text();
+ mDbConn.close();
+ return false;
+ }
- mDbConn.close();
- return true;
- }
+ mDbConn.close();
+ return true;
+ }
- bool
- TmsProvider::cacheContains(const QPoint& pos, int zoom)
- {
- QByteArray res = getCache(pos, zoom);
- return !res.isEmpty();
- }
+ bool
+ TmsProvider::cacheContains(const QPoint& pos, int zoom)
+ {
+ QByteArray res = getCache(pos, zoom);
+ return !res.isEmpty();
+ }
- void
- TmsProvider::createTask(const QRectF& rect, int zoom)
- {
- newImage(rect);
+ void
+ TmsProvider::createTask(const QRectF& rect, int zoom)
+ {
+ newImage(rect);
- /// 创建下载瓦片任务
- const QSize sz = tileSize();
- int xMin = qFloor(rect.topLeft().x() / sz.width());
- double xOffset = rect.topLeft().x() / sz.width() - xMin;
- int xMax = qFloor(rect.bottomRight().x() / sz.width());
- int yMin = qFloor(rect.topLeft().y() / sz.height());
- double yOffset = rect.topLeft().y() / sz.height() - yMin;
- int yMax = qFloor(rect.bottomRight().y() / sz.height());
- for (int i = xMin; i <= xMax; ++i) {
- for (int j = yMin; j <= yMax; ++j) {
- TileInfo tile{};
- tile.index = QPointF{i - xMin - xOffset, j - yMin - yOffset};
- tile.position = QPoint{i, j};
- tile.zoom = zoom;
- tile.coord = QPoint{i - xMin, j - yMin};
- tile.url = tileUrl(PointXY{static_cast(i), static_cast(j)}, zoom);
- auto tileData = getCache(tile.position, tile.zoom);
- if (!tileData.isEmpty()) {
- tile.data = tileData;
- tileReady(tile);
- continue;
- }
+ /// 创建下载瓦片任务
+ const QSize sz = tileSize();
+ int xMin = qFloor(rect.topLeft().x() / sz.width());
+ double xOffset = rect.topLeft().x() / sz.width() - xMin;
+ int xMax = qFloor(rect.bottomRight().x() / sz.width());
+ int yMin = qFloor(rect.topLeft().y() / sz.height());
+ double yOffset = rect.topLeft().y() / sz.height() - yMin;
+ int yMax = qFloor(rect.bottomRight().y() / sz.height());
+ for (int i = xMin; i <= xMax; ++i) {
+ for (int j = yMin; j <= yMax; ++j) {
+ TileInfo tile{};
+ tile.index = QPointF{ i - xMin - xOffset, j - yMin - yOffset };
+ tile.position = QPoint{ i, j };
+ tile.zoom = zoom;
+ tile.coord = QPoint{ i - xMin, j - yMin };
+ tile.url = tileUrl(PointXY{ static_cast(i), static_cast(j) }, zoom);
+ auto tileData = getCache(tile.position, tile.zoom);
+ if (!tileData.isEmpty()) {
+ tile.data = tileData;
+ tileReady(tile);
+ continue;
+ }
- auto* task = new TileDownloadTask(tile);
- QObject::connect(task, &TileDownloadTask::tileReady, this, &TmsProvider::tileReady);
- QThreadPool::globalInstance()->start(task);
- }
- }
- }
+ auto* task = new TileDownloadTask(tile);
+ QObject::connect(task, &TileDownloadTask::tileReady, this, &TmsProvider::tileReady);
+ QThreadPool::globalInstance()->start(task);
+ }
+ }
+ }
- void
- TmsProvider::tileReady(TileInfo tile)
- {
- if (!cacheContains(tile.position, tile.zoom)) {
- addCache(tile.position, tile.zoom, tile.data);
- }
- QPainter painter{mImage};
- QImage img = QImage::fromData(tile.data);
- if (img.isNull()) {
- return;
- }
+ void
+ TmsProvider::tileReady(TileInfo tile)
+ {
+ if (!cacheContains(tile.position, tile.zoom)) {
+ addCache(tile.position, tile.zoom, tile.data);
+ }
+ QPainter painter{ mImage };
+ QImage img = QImage::fromData(tile.data);
+ if (img.isNull()) {
+ return;
+ }
- double xPos = tile.index.x() * tileSize().width();
- double yPos = tile.index.y() * tileSize().height();
+ double xPos = tile.index.x() * tileSize().width();
+ double yPos = tile.index.y() * tileSize().height();
- painter.drawImage(QPointF(xPos, yPos), img);
- }
+ painter.drawImage(QPointF(xPos, yPos), img);
+ }
- void
- TmsProvider::newImage(const QRectF& rect)
- {
- QSize imgSize{int(rect.width()), int(rect.height())};
- if (!mImage || imgSize != mImage->size()) {
- mImage = new QImage(imgSize, QImage::Format_RGB32);
- }
- mImage->fill(Qt::white);
- }
+ void
+ TmsProvider::newImage(const QRectF& rect)
+ {
+ QSize imgSize{ int(rect.width()), int(rect.height()) };
+ if (!mImage || imgSize != mImage->size()) {
+ mImage = new QImage(imgSize, QImage::Format_RGB32);
+ }
+ mImage->fill(Qt::white);
+ }
}
diff --git a/RasterMainWidgetGUI/RasterMainWidget/tmsproviderfactory.cpp b/RasterMainWidgetGUI/RasterMainWidget/tmsproviderfactory.cpp
index c0f58bf..3f46ef4 100644
--- a/RasterMainWidgetGUI/RasterMainWidget/tmsproviderfactory.cpp
+++ b/RasterMainWidgetGUI/RasterMainWidget/tmsproviderfactory.cpp
@@ -5,33 +5,35 @@
namespace LAMPMainWidget {
-QHash TmsProviderFactory::mProviders{};
+ QHash TmsProviderFactory::mProviders{};
-LayerProvider *
-TmsProviderFactory::create(LAMPMainWidget::TmsProviders provider) {
- LayerProvider *result = nullptr;
- switch (provider) {
- case OSTNormalMap:
- if (mProviders.contains(OSTNormalMap)) {
- result = mProviders.value(OSTNormalMap);
- } else {
- result = new OSTNormalProvider();
- mProviders.insert(OSTNormalMap, result);
- }
- break;
- case GaodeNormapMap:
- if (mProviders.contains(GaodeNormapMap)) {
- result = mProviders.value(GaodeNormapMap);
- } else {
- result = new GaodeNormalProvider();
- mProviders.insert(GaodeNormapMap, result);
- }
- break;
- default:break;
- }
+ LayerProvider*
+ TmsProviderFactory::create(LAMPMainWidget::TmsProviders provider) {
+ LayerProvider* result = nullptr;
+ switch (provider) {
+ case OSTNormalMap:
+ if (mProviders.contains(OSTNormalMap)) {
+ result = mProviders.value(OSTNormalMap);
+ }
+ else {
+ result = new OSTNormalProvider();
+ mProviders.insert(OSTNormalMap, result);
+ }
+ break;
+ case GaodeNormapMap:
+ if (mProviders.contains(GaodeNormapMap)) {
+ result = mProviders.value(GaodeNormapMap);
+ }
+ else {
+ result = new GaodeNormalProvider();
+ mProviders.insert(GaodeNormapMap, result);
+ }
+ break;
+ default:break;
+ }
- return result;
-}
+ return result;
+ }
}
diff --git a/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj b/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj
index 4a41a0b..3002468 100644
--- a/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj
+++ b/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj
@@ -106,6 +106,7 @@
.;.\RasterMainWidget;..\RasterProcessToolWidget;..\RasterProcessToolWidget\ToolBoxManager;..\BaseCommonLibrary;..\BaseCommonLibrary\BaseTool;..\BaseCommonLibrary\ToolAbstract;..\GPUBaseLib\GPUTool;..\GPUBaseLib;..\RasterMainWidgetGUI;..\RasterMainWidgetGUI\RasterMainWidget;$(IncludePath)
true
true
+ true
.;.\RasterMainWidget;..\RasterProcessToolWidget;..\RasterProcessToolWidget\ToolBoxManager;..\BaseCommonLibrary;..\BaseCommonLibrary\BaseTool;..\BaseCommonLibrary\ToolAbstract;..\GPUBaseLib\GPUTool;..\GPUBaseLib;..\RasterMainWidgetGUI;..\RasterMainWidgetGUI\RasterMainWidget;$(IncludePath)
@@ -115,6 +116,10 @@
_CRT_SECURE_NO_WARNINGS;_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING;RASTERMAINWIDGETGUI_LIB;%(PreprocessorDefinitions)
+ true
+ EditAndContinue
+ false
+ Disabled
diff --git a/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj.filters b/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj.filters
index 35b42fa..aeaec0b 100644
--- a/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj.filters
+++ b/RasterMainWidgetGUI/RasterMainWidgetGUI.vcxproj.filters
@@ -21,6 +21,9 @@
{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}
ts
+
+ {1a65f538-c16c-4824-895f-105eb2fc502e}
+
diff --git a/RasterMainWidgetGUI/RasterWidgetMessageShow.cpp b/RasterMainWidgetGUI/RasterWidgetMessageShow.cpp
index 2326c7c..d045371 100644
--- a/RasterMainWidgetGUI/RasterWidgetMessageShow.cpp
+++ b/RasterMainWidgetGUI/RasterWidgetMessageShow.cpp
@@ -7,6 +7,7 @@ namespace RasterMessageShow {
RasterWidgetMessageShow::RasterWidgetMessageShow(QObject* parant):QObject(parant)
{
+ this->textBrowserMessage = nullptr;
QObject::connect(this, SIGNAL(ShowMessage(QString)), this, SLOT(ShowMessageInfo(QString)));
}
@@ -26,12 +27,12 @@ namespace RasterMessageShow {
void RasterWidgetMessageShow::ShowMessageInfo(QString Message)
{
+ std::cout << Message.toLocal8Bit().constData() << std::endl;
if (nullptr != this->textBrowserMessage) {
this->textBrowserMessage->append(Message);
this->textBrowserMessage->moveCursor(QTextCursor::MoveOperation::End);
this->textBrowserMessage->repaint();
std::cout << Message.toLocal8Bit().constData() << std::endl;
-
}
else {}
}
diff --git a/RasterMainWidgetGUI/main.cpp b/RasterMainWidgetGUI/main.cpp
index 742dbf2..927abe0 100644
--- a/RasterMainWidgetGUI/main.cpp
+++ b/RasterMainWidgetGUI/main.cpp
@@ -1,6 +1,8 @@
#include "LAMPMainWidgetRunProgram.h"
#include
+// ĿǻeasygisĿԭĿַ https://gitee.com/stormeye2020/easygis.git
+
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
diff --git a/RasterProcessToolWidget/ToolBoxWidget.cpp b/RasterProcessToolWidget/ToolBoxWidget.cpp
index 5bb44ae..d0a9ae4 100644
--- a/RasterProcessToolWidget/ToolBoxWidget.cpp
+++ b/RasterProcessToolWidget/ToolBoxWidget.cpp
@@ -25,6 +25,7 @@ ToolBoxWidget::ToolBoxWidget(LAMPMainWidget::RasterMainWidget* mainWindows, QWid
ui->setupUi(this);
setContextMenuPolicy(Qt::CustomContextMenu); // Ҽݲ˵
QObject::connect(this, SIGNAL(addBoxToolItemSIGNAL(QToolAbstract*)), this, SLOT(addBoxToolItemSLOT(QToolAbstract*)));
+ QObject::connect(this, SIGNAL(addBoxToolItemInPathSIGNAL(QVector , QToolAbstract* )), this, SLOT(addBoxToolItemInPathSLOT(QVector, QToolAbstract * )));
}
@@ -122,6 +123,37 @@ void ToolBoxWidget::addBoxToolItemSLOT(QToolAbstract* item)
}
+void ToolBoxWidget::addBoxToolItemInPathSLOT(QVector xnodepath, QToolAbstract* item)
+{
+ QString toolName = item->getToolName();
+
+ QTreeWidgetItem* parentItem = findOrCreateParentItem(xnodepath);
+
+ // øǷѾ toolButton
+ if (parentItem && ui->treeWidgetToolBox->itemWidget(parentItem, 0) == nullptr) {
+
+ toollist.append(QToolboxTreeWidgetItem(ui->treeWidgetToolBox, parentItem, item));
+
+
+ //QTreeWidgetItem* actionItem = new QTreeWidgetItem(parentItem);
+ //parentItem->addChild(actionItem);
+ //actionItem->setText(0,toolName);
+ //QIcon icon(QString::fromUtf8(":/ToolBoxWidget/toolicon"));
+ //QPushButton* button = new QPushButton(ui->treeWidgetToolBox);
+ //button->setIcon(icon);
+ //button->setText(toolName);
+ //button->setLayoutDirection(Qt::LeftToRight);
+ //button->setStyleSheet("QPushButton { text-align: left; }");
+ //ui->treeWidgetToolBox->setItemWidget(actionItem, 0, button);
+ //connect(button, SIGNAL(clicked()), item, SLOT(excute()));
+ //item->setParent(ui->treeWidgetToolBox);
+ //qDebug() << "ToolButton bound to parent:" << actionItem->text(0);
+ }
+ else {
+ qDebug() << "ToolButton already bound to parent:" << parentItem->text(0);
+ }
+}
+
// ·һ
QTreeWidgetItem* ToolBoxWidget::findOrCreateParentItem( QVector& path) {
QTreeWidgetItem* currentItem = nullptr;
@@ -171,7 +203,17 @@ QTreeWidgetItem* ToolBoxWidget::findChildItemByName(QTreeWidgetItem* parentItem,
return childItem;
}
}
- return nullptr;
+
+
+ // ûҵµĶڵ
+ QTreeWidgetItem* newItem = new QTreeWidgetItem(parentItem);
+ QIcon icon(QString::fromUtf8(":/RasterProcessTool/toolboxIcon"));
+ newItem->setIcon(0, icon);
+ newItem->setTextAlignment(0, Qt::AlignLeft);
+ newItem->setText(0, name);
+ parentItem->addChild(newItem);
+ return newItem;
+ // return nullptr;
}
void ToolBoxWidget::OpenToolboxManagerWidget()
diff --git a/RasterProcessToolWidget/ToolBoxWidget.h b/RasterProcessToolWidget/ToolBoxWidget.h
index 39f7c48..fc84b7b 100644
--- a/RasterProcessToolWidget/ToolBoxWidget.h
+++ b/RasterProcessToolWidget/ToolBoxWidget.h
@@ -49,9 +49,11 @@ private:
signals:
void addBoxToolItemSIGNAL(QToolAbstract* item);
+ void addBoxToolItemInPathSIGNAL(QVector xnodepath, QToolAbstract* item);
public slots:
void addBoxToolItemSLOT(QToolAbstract* item);
+ void addBoxToolItemInPathSLOT(QVector xnodepath, QToolAbstract* item);
QTreeWidgetItem* findOrCreateParentItem( QVector& path);
QTreeWidgetItem* findOrCreateTopLevelItem( QString& name);
QTreeWidgetItem* findChildItemByName(QTreeWidgetItem* parentItem, QString& name);
diff --git a/Toolbox/BaseToolbox/BaseToolbox.cpp b/Toolbox/BaseToolbox/BaseToolbox.cpp
index 1bad4fa..22ed9c8 100644
--- a/Toolbox/BaseToolbox/BaseToolbox.cpp
+++ b/Toolbox/BaseToolbox/BaseToolbox.cpp
@@ -13,6 +13,9 @@
#include "QResampleRefrenceRaster.h"
#include "QtLookTableCorrectOffsetDialog.h"
#include "QtCreateGPSPointsDialog.h"
+#include "RasterVRT2ENVIdataDialog.h"
+
+#include "SARSatalliteSimulationWorkflow.h" //
GF3ImportDataToolButton::GF3ImportDataToolButton(QWidget* parent) :QToolAbstract(parent)
{
@@ -115,6 +118,19 @@ void RegisterPreToolBox(LAMPMainWidget::RasterMainWidget* mainwindows, ToolBoxWi
emit toolbox->addBoxToolItemSIGNAL(new QResampleRefrenceRasterToolButton(toolbox));
emit toolbox->addBoxToolItemSIGNAL(new QLookTableCorrectOffsetToolButton(toolbox));
emit toolbox->addBoxToolItemSIGNAL(new QCreateGPSPointsToolButton(toolbox));
+ emit toolbox->addBoxToolItemSIGNAL(new RasterVRT2ENVIdataDialogToolButton(toolbox));
+
+
+ //
+#ifdef __BASETOOLBOX__SARSATALLITESIMULATIONWORKFLOW__H__
+ initBaseToolSARSateSimulationWorkflow(toolbox);
+#endif // __BASETOOLBOX__SARSATALLITESIMULATIONWORKFLOW__H__
+
+
+
+
+
+
}
QDEMResampleDialogToolButton::QDEMResampleDialogToolButton(QWidget* parent)
@@ -215,4 +231,21 @@ void QCreateGPSPointsToolButton::excute()
{
QtCreateGPSPointsDialog* dialog = new QtCreateGPSPointsDialog;
dialog->show();
-}
\ No newline at end of file
+}
+
+RasterVRT2ENVIdataDialogToolButton::RasterVRT2ENVIdataDialogToolButton(QWidget* parent)
+{
+ this->toolPath = QVector(0);
+ this->toolPath.push_back(u8"");
+ this->toolname = QString(u8"vrtļתenviݸʽ");
+}
+
+RasterVRT2ENVIdataDialogToolButton::~RasterVRT2ENVIdataDialogToolButton()
+{
+}
+
+void RasterVRT2ENVIdataDialogToolButton::run()
+{
+ RasterVRT2ENVIdataDialog* dialog = new RasterVRT2ENVIdataDialog;
+ dialog->show();
+}
diff --git a/Toolbox/BaseToolbox/BaseToolbox.h b/Toolbox/BaseToolbox/BaseToolbox.h
index 5c15ea7..42a024b 100644
--- a/Toolbox/BaseToolbox/BaseToolbox.h
+++ b/Toolbox/BaseToolbox/BaseToolbox.h
@@ -10,6 +10,8 @@ namespace LAMPMainWidget {
class ToolBoxWidget;
+extern "C" BASETOOLBOX_EXPORT void RegisterPreToolBox(LAMPMainWidget::RasterMainWidget* mainwindows, ToolBoxWidget* toolbox);
+
class BASETOOLBOX_EXPORT GF3ImportDataToolButton : public QToolAbstract {
Q_OBJECT
public:
@@ -132,4 +134,18 @@ public slots:
};
-extern "C" BASETOOLBOX_EXPORT void RegisterPreToolBox(LAMPMainWidget::RasterMainWidget* mainwindows, ToolBoxWidget* toolbox);
+
+
+
+
+class BASETOOLBOX_EXPORT RasterVRT2ENVIdataDialogToolButton : public QToolAbstract {
+ Q_OBJECT
+public:
+ RasterVRT2ENVIdataDialogToolButton(QWidget* parent = nullptr);
+ ~RasterVRT2ENVIdataDialogToolButton();
+public :
+ virtual void run() override;
+
+};
+
+
diff --git a/Toolbox/BaseToolbox/BaseToolbox.vcxproj b/Toolbox/BaseToolbox/BaseToolbox.vcxproj
index 5384b55..1ace8fc 100644
--- a/Toolbox/BaseToolbox/BaseToolbox.vcxproj
+++ b/Toolbox/BaseToolbox/BaseToolbox.vcxproj
@@ -60,12 +60,12 @@
tools_qt5
- core
+ core;gui;widgets
debug
tools_qt5
- core
+ core;gui;widgets
debug
@@ -122,6 +122,7 @@
true
stdcpp14
stdc11
+ Disabled
@@ -207,10 +208,13 @@
+
+
+
@@ -225,6 +229,7 @@
+
@@ -246,6 +251,7 @@
+
diff --git a/Toolbox/BaseToolbox/BaseToolbox.vcxproj.filters b/Toolbox/BaseToolbox/BaseToolbox.vcxproj.filters
index 03e37b6..dbe0ff5 100644
--- a/Toolbox/BaseToolbox/BaseToolbox.vcxproj.filters
+++ b/Toolbox/BaseToolbox/BaseToolbox.vcxproj.filters
@@ -106,6 +106,12 @@
BaseToolbox
+
+ BaseToolbox
+
+
+ Source Files
+
@@ -147,6 +153,12 @@
BaseToolbox
+
+ BaseToolbox
+
+
+ Header Files
+
@@ -185,5 +197,8 @@
BaseToolbox
+
+ BaseToolbox
+
\ No newline at end of file
diff --git a/Toolbox/BaseToolbox/BaseToolbox/GF3CalibrationAndGeocodingClass.cpp b/Toolbox/BaseToolbox/BaseToolbox/GF3CalibrationAndGeocodingClass.cpp
index 76188ba..aadbd71 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"ݵ");
@@ -209,94 +209,10 @@ ErrorCode ImportGF3L1AProcess(QString inMetaxmlPath, QString outWorkDirPath)
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"WGS84DEMӰ");
- return ErrorCode::FAIL;
- }
-}
-
ErrorCode RD_PSTN(double& refrange, double& lamda, double& timeR, double& R, double& tx, double& ty, double& tz, double& slopex, double& slopey, double& slopez, GF3PolyfitSatelliteOribtModel& polyfitmodel, SatelliteOribtNode& node, double& d0, double& d1, double& d2, double& d3, double& d4)
{
- double dt = 1e-6;
+ double dt = 1e-4;
double inct = 0;
bool antfalg = false;
double timeR2 = 0;
@@ -315,21 +231,24 @@ ErrorCode RD_PSTN(double& refrange, double& lamda, double& timeR, double& R, dou
for (int i = 0; i < 50; i++) {
polyfitmodel.getSatelliteOribtNode(timeR, node, antfalg);
R1 = std::sqrt(std::pow(node.Px - tx, 2) + std::pow(node.Py - ty, 2) + std::pow(node.Pz - tz, 2));
- dplerTheory1 = (-2 / lamda) * (((node.Px - tx) * (node.Vx + EARTHWE * ty) + (node.Py - ty) * (node.Vy - EARTHWE * tz) + (node.Pz - tz) * (node.Vz - 0)) / R1);
- dplerR = (R1 - refrange) * 1e6 / LIGHTSPEED;
+ //dplerTheory1 = (-2 / lamda / R1) * ((node.Px - tx) * (node.Vx + EARTHWE * ty) + (node.Py - ty) * (node.Vy - EARTHWE * tx) + (node.Pz - tz) * (node.Vz - 0));
+ dplerTheory1 = (-2 / lamda / R1) * ((node.Px - tx) * (node.Vx + 0) + (node.Py - ty) * (node.Vy -0) + (node.Pz - tz) * (node.Vz - 0));
+ dplerR = (R1 - refrange) * 1e6 / LIGHTSPEED; // GF3 㹫ʽ
dplerNumber1 = d0 + dplerR * d1 + std::pow(dplerR, 2) * d2 + std::pow(dplerR, 3) * d3 + std::pow(dplerR, 4) * d4;
timeR2 = timeR + dt;
polyfitmodel.getSatelliteOribtNode(timeR2, node, antfalg);
R2 = std::sqrt(std::pow(node.Px - tx, 2) + std::pow(node.Py - ty, 2) + std::pow(node.Pz - tz, 2));
- dplerTheory2 = (-2 / lamda) * (((node.Px - tx) * (node.Vx + EARTHWE * ty) + (node.Py - ty) * (node.Vy - EARTHWE * tz) + (node.Pz - tz) * (node.Vz - 0)) / R2);
- dplerR = (R2 - refrange) * 1e6 / LIGHTSPEED;
- dplerNumber2 = d0 + dplerR * d1 + std::pow(dplerR, 2) * d2 + std::pow(dplerR, 3) * d3 + std::pow(dplerR, 4) * d4;
-
- inct = dt * (dplerTheory2 - dplerNumber1) / (dplerTheory1 - dplerTheory2);
- if (std::abs(dplerTheory1 - dplerTheory2) < 1e-9 || std::abs(inct) < dt) {
+ //dplerTheory2 = (-2 / lamda/R2) * ((node.Px - tx) * (node.Vx + EARTHWE * ty) + (node.Py - ty) * (node.Vy - EARTHWE * tx) + (node.Pz - tz) * (node.Vz - 0));
+ dplerTheory2 = (-2 / lamda/R2) * ((node.Px - tx) * (node.Vx +0) + (node.Py - ty) * (node.Vy -0) + (node.Pz - tz) * (node.Vz - 0));
+ //dplerR = (R2 - refrange) * 1e6 / LIGHTSPEED; // GF3 㹫ʽ
+ //dplerNumber2 = d0 + dplerR * d1 + std::pow(dplerR, 2) * d2 + std::pow(dplerR, 3) * d3 + std::pow(dplerR, 4) * d4;
+
+ inct = dt*(dplerTheory2-dplerNumber1) / (dplerTheory2 - dplerTheory1);
+ if (std::abs(dplerNumber1 - dplerTheory2) < 1e-6 || std::abs(inct) < 1.0e-4) {
break;
}
+ inct = std::abs(inct) < 10 ?inct:inct*1e-2;
timeR = timeR - inct;
}
R = R1; // б
@@ -349,7 +268,7 @@ ErrorCode GF3RDCreateLookTable(QString inxmlPath, QString indemPath, QString out
gdalImage rasterRC = CreategdalImage(outlooktablePath, demxyz.height, demxyz.width, 2, demxyz.gt, demxyz.projection, true, true);// X,Y,Z
gdalImage localincangleRaster;
if (localincAngleFlag) {
- localincangleRaster = CreategdalImage(outLocalIncidenceAnglePath, demxyz.height, demxyz.width, 2, demxyz.gt, demxyz.projection, true, true);// X,Y,Z
+ localincangleRaster = CreategdalImage(outLocalIncidenceAnglePath, demxyz.height, demxyz.width, 1, demxyz.gt, demxyz.projection, true, true);// X,Y,Z
}
@@ -363,44 +282,64 @@ ErrorCode GF3RDCreateLookTable(QString inxmlPath, QString indemPath, QString out
double d3 = dopplers[3];
double d4 = dopplers[4];
- double fs = l1dataset.getFs();// Fs
- double prf = (l1dataset.getEndImageTime() - l1dataset.getStartImageTime()) / (l1dataset.getrowCount() - 1);// PRF
+ double fs = l1dataset.getFs()*1e6;// Fs
+ double prf = l1dataset.getPRF();// PRF
double nearRange = l1dataset.getNearRange();
double imagestarttime = l1dataset.getStartImageTime();
+ double imageendtime = l1dataset.getEndImageTime();
double refrange = l1dataset.getRefRange();
- double lamda = (LIGHTSPEED*1e-6)/ l1dataset.getCenterFreq();
+ double lamda = (LIGHTSPEED*1.0e-9)/ l1dataset.getCenterFreq();
+ // ӡ
+ qDebug() << "Fs:\t" << fs;
+ qDebug() << "prf:\t" << prf;
+ qDebug() << "nearRange:\t" << nearRange;
+ qDebug() << "imagestarttime:\t" << imagestarttime;
+ qDebug() << "imageendtime:\t" << imageendtime;
+ qDebug() << "refrange:\t" << refrange;
+ qDebug() << "lamda:\t" << lamda;
+ //ӡ۲
+ qDebug() << u8"-----------------------------------";
+ qDebug() << u8"ղ\n";
+ qDebug() << u8"d0:\t" << d0;
+ qDebug() << u8"d1:\t" << d1;
+ qDebug() << u8"d2:\t" << d2;
+ qDebug() << u8"d3:\t" << d3;
+ qDebug() << u8"d4:\t" << d4;
+ qDebug() << u8"-----------------------------------";
// ģ
GF3PolyfitSatelliteOribtModel polyfitmodel;
QVector < SatelliteAntPos > antposes = l1dataset.getXmlSateAntPos();
- polyfitmodel.setSatelliteOribtStartTime(imagestarttime);
+ polyfitmodel.setSatelliteOribtStartTime((imagestarttime+imageendtime)/2);
for (long i = 0; i < antposes.size(); i++) {
- SatelliteOribtNode node;
- node.time = antposes[i].time;
- node.Px = antposes[i].Px;
- node.Py = antposes[i].Py;
- node.Pz = antposes[i].Pz;
- node.Vx = antposes[i].Vx;
- node.Vy = antposes[i].Vy;
- node.Vz = antposes[i].Vz;
- polyfitmodel.addOribtNode(node);
+ if (antposes[i].time > imagestarttime - 5 && antposes[i].time < imageendtime + 5) {
+ SatelliteOribtNode node;
+ node.time = antposes[i].time;
+ node.Px = antposes[i].Px;
+ node.Py = antposes[i].Py;
+ node.Pz = antposes[i].Pz;
+ node.Vx = antposes[i].Vx;
+ node.Vy = antposes[i].Vy;
+ node.Vz = antposes[i].Vz;
+ polyfitmodel.addOribtNode(node);
+ }
}
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() * 8000;
+ 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;
@@ -417,33 +356,41 @@ 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);
Eigen::MatrixXd dem_y = demxyz.getData(startRId, 0, blockline, colcount, 2);
Eigen::MatrixXd dem_z = demxyz.getData(startRId, 0, blockline, colcount, 3);
- // ص
- double timeR = 0;
+
long blockrows = sar_r.rows();
long blockcols = sar_r.cols();
- double tx = 0;
- double ty = 0;
- double tz = 0;
- double R = 0;
- double slopex=0, slopey=0, slopez=0;
- SatelliteOribtNode node{0,0,0,0,0,0,0,0};
- bool antflag = false;
+
+#pragma omp parallel for
for (long i = 0; i < blockrows; i++) {
+ // ص
+ double timeR = 0;
+ double tx = 0;
+ double ty = 0;
+ double tz = 0;
+ double R = 0;
+ double slopex = 0, slopey = 0, slopez = 0;
+ SatelliteOribtNode node{ 0,0,0,0,0,0,0,0 };
+ bool antflag = false;
for (long j = 0; j < blockcols; j++) {
+
tx = dem_x(i, j);
ty = dem_y(i, j);
tz = dem_z(i, j);
if (RD_PSTN(refrange,lamda, timeR,R,tx,ty,tz,slopex,slopey,slopez,polyfitmodel,node,d0,d1,d2,d3,d4) == ErrorCode::SUCCESS) {
- sar_r(i, j) = timeR * prf;
- sar_c(i, j) = ((R - nearRange) / 2 / LIGHTSPEED) * fs;
+ sar_r(i, j) =( timeR+ (imagestarttime + imageendtime) / 2 -imagestarttime) * prf;
+ sar_c(i, j) = ((R - nearRange) * 2 / LIGHTSPEED) * fs;
}
else {
sar_r(i, j) = -1;
@@ -452,6 +399,14 @@ ErrorCode GF3RDCreateLookTable(QString inxmlPath, QString indemPath, QString out
}
}
+ //
+ omp_set_lock(&lock);
+ rasterRC.saveImage(sar_r, startRId, 0, 1);
+ rasterRC.saveImage(sar_c, startRId, 0, 2);
+
+ omp_unset_lock(&lock);
+
+
Eigen::MatrixXd Angle_Arr = Eigen::MatrixXd::Zero(dem_x.rows(),dem_x.cols()).array()+181;
if (localincAngleFlag) {
Eigen::MatrixXd demslope_x = demslope.getData(startRId, 0, blockline, colcount, 1);
@@ -461,7 +416,20 @@ ErrorCode GF3RDCreateLookTable(QString inxmlPath, QString indemPath, QString out
double Rst_x = 0, Rst_y = 0, Rst_z = 0, localangle = 0;
double slopeR = 0;
+#pragma omp parallel for
for (long i = 0; i < blockrows; i++) {
+ // ص
+ double timeR = 0;
+ double tx = 0;
+ double ty = 0;
+ double tz = 0;
+ double R = 0;
+ double slopex = 0, slopey = 0, slopez = 0;
+ SatelliteOribtNode node{ 0,0,0,0,0,0,0,0 };
+ bool antflag = false;
+
+
+
for (long j = 0; j < blockcols; j++) {
timeR = sar_r(i, j) / prf;
slopex = demslope_x(i, j);
@@ -482,18 +450,25 @@ ErrorCode GF3RDCreateLookTable(QString inxmlPath, QString indemPath, QString out
Angle_Arr(i, j) = localangle;
}
}
+
+ //
+ omp_set_lock(&lock);
+
+ if (localincAngleFlag) {
+ localincangleRaster.saveImage(Angle_Arr, startRId, 0, 1);
+ }
+ else {}
+
+ omp_unset_lock(&lock);
+
}
+
//
omp_set_lock(&lock);
- rasterRC.saveImage(sar_r, startRId, 0, 1);
- rasterRC.saveImage(sar_c, startRId, 0, 2);
- if (localincAngleFlag) {
- localincangleRaster.saveImage(Angle_Arr, startRId, 0, 1);
- }
- 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;
}
@@ -511,16 +486,17 @@ ErrorCode GF3OrthSLC( QString inRasterPath, QString inlooktablePath, QString out
gdalImage slcRaster(inRasterPath);//
gdalImage looktableRaster(inlooktablePath);//
- gdalImage outRaster(outRasterPath);//
+ gdalImage outRaster = CreategdalImage(outRasterPath, looktableRaster.height, looktableRaster.width, 1, looktableRaster.gt, looktableRaster.projection, true, true);// X,Y,Z
+ //gdalImage outRaster(outRasterPath);//
if (outRaster.height != looktableRaster.height || outRaster.width != looktableRaster.width) {
- qDebug() << "look table size is not same as outRaster size"<< looktableRaster.height <<"!="<= slcRows || nextc >= slcCols) {
continue;
}
- p11 = { sar_r(i,j),sar_c(i,j),0 };
+
+ p0 = { sar_c(i,j)-lastc, sar_r(i,j)-lastr,0 };
p11 = Landpoint{ 0,0,slcImg(lastr,lastc) };
p21 = Landpoint{ 0,1,slcImg(nextr,lastc) };
p12 = Landpoint{ 1,0,slcImg(lastr,nextc) };
p22 = Landpoint{ 1,1,slcImg(nextr,nextc) };
+
Bileanervalue = Bilinear_interpolation(p0, p11, p21, p12, p22);
outImg(i, j) = Bileanervalue;
}
@@ -585,6 +563,35 @@ ErrorCode GF3RDProcess(QString inxmlPath, QString indemPath, QString outworkdir,
double minlon = box.min_lon - dlon;
double maxlat = box.max_lat + dlat;
double maxlon = box.max_lon + dlon;
+ qDebug() << u8"ӰΧ:";
+ qDebug() << u8"Bounding Box:";
+ qDebug() << u8"Latitude:" << minlat <<" - "<< maxlat;
+ qDebug() << u8"Longitude:" << minlon <<" - "<< maxlon;
+ double centerlat = (minlat + maxlat) / 2;
+ double centerlon = (minlon + maxlon) / 2;
+ long sourceespgcode = getProjectEPSGCodeByLon_Lat(centerlon, centerlat);
+ long demespgcode = GetEPSGFromRasterFile(indemPath);
+ double grid_resolution = gridx < gridy ? gridx : gridy;
+ double degreePerPixelX = grid_resolution / 110000.0;
+ double degreePerPixelY = grid_resolution / 110000.0;
+ bool meter2degreeflag = ConvertResolutionToDegrees(
+ sourceespgcode,
+ grid_resolution,
+ centerlon,
+ centerlat,
+ degreePerPixelX,
+ degreePerPixelY
+ );
+ if (!meter2degreeflag) {
+ qDebug() << u8"תֱΪγʧ";
+ degreePerPixelX = grid_resolution / 110000.0;
+ degreePerPixelY = grid_resolution / 110000.0;
+ }
+ qDebug() << u8"DEMӰΧ:";
+ qDebug() << u8"ֱʣ"< 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);
// RD 㷨
ErrorCode RD_PSTN(double& refrange,double& lamda, double& timeR, double& R, double& tx, double& ty, double& tz, double& slopex, double& slopey, double& slopez, GF3PolyfitSatelliteOribtModel& polyfitmodel, SatelliteOribtNode& node,double& d0,double& d1, double& d2, double& d3, double& d4);
@@ -36,6 +29,3 @@ ErrorCode GF3OrthSLC( QString inRasterPath, QString inlooktablePath, QString out
// 䴦
ErrorCode GF3RDProcess(QString inxmlPath, QString indemPath, QString outworkdir, double gridx, double gridy);
-
-
-
diff --git a/Toolbox/BaseToolbox/BaseToolbox/GF3PSTNClass.cpp b/Toolbox/BaseToolbox/BaseToolbox/GF3PSTNClass.cpp
index b350012..735d954 100644
--- a/Toolbox/BaseToolbox/BaseToolbox/GF3PSTNClass.cpp
+++ b/Toolbox/BaseToolbox/BaseToolbox/GF3PSTNClass.cpp
@@ -66,7 +66,7 @@ QString GF3PolyfitSatelliteOribtModel::getSatelliteOribtModelParamsString()
result += QString::number(this->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 90b6580..ea9936f 100644
--- a/Toolbox/BaseToolbox/BaseToolbox/QComplex2AmpPhase.cpp
+++ b/Toolbox/BaseToolbox/BaseToolbox/QComplex2AmpPhase.cpp
@@ -5,6 +5,7 @@
#include "BaseTool.h"
#include "SARSimulationImageL1.h"
#include "GF3CalibrationAndGeocodingClass.h"
+#include "RasterToolBase.h"
QComplex2AmpPhase::QComplex2AmpPhase(QWidget *parent)
: QDialog(parent)
@@ -15,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 )
}
@@ -46,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/QOrthSlrRaster.cpp b/Toolbox/BaseToolbox/BaseToolbox/QOrthSlrRaster.cpp
index 6e4ad79..62a5ad5 100644
--- a/Toolbox/BaseToolbox/BaseToolbox/QOrthSlrRaster.cpp
+++ b/Toolbox/BaseToolbox/BaseToolbox/QOrthSlrRaster.cpp
@@ -14,10 +14,10 @@ QOrthSlrRaster::QOrthSlrRaster(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.pushButtonDEMSelect, SIGNAL(clicked(bool)), this, SLOT(pushButtonDEMSelectClicked(bool)));
+ 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(onreject()));
+ QObject::connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(onaccept()));
}
QOrthSlrRaster::~QOrthSlrRaster()
@@ -61,7 +61,7 @@ void QOrthSlrRaster::onpushButtonAddClicked(bool)
this, //
tr(u8"ѡxmlļ"), //
QString(), // Ĭ·
- tr(u8"xml Files (*.xml);;All Files (*)") // ļ
+ tr(ENVI_FILE_FORMAT_FILTER) // ļ
);
// ûѡļ
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/RasterVRT2ENVIdataDialog.cpp b/Toolbox/BaseToolbox/BaseToolbox/RasterVRT2ENVIdataDialog.cpp
new file mode 100644
index 0000000..85964ab
--- /dev/null
+++ b/Toolbox/BaseToolbox/BaseToolbox/RasterVRT2ENVIdataDialog.cpp
@@ -0,0 +1,77 @@
+#include "RasterVRT2ENVIdataDialog.h"
+#include "ui_RasterVRT2ENVIdataDialog.h"
+#include "BaseConstVariable.h"
+#include "BaseTool.h"
+#include "RasterToolBase.h"
+#include "LogInfoCls.h"
+#include
+#include
+#include "ImageOperatorBase.h"
+
+RasterVRT2ENVIdataDialog::RasterVRT2ENVIdataDialog(QWidget *parent)
+ : QDialog(parent)
+ ,ui(new Ui::RasterVRT2ENVIdataDialogClass)
+{
+ ui->setupUi(this);
+
+ connect(ui->pushButtonVRTSelect, SIGNAL(clicked()), this, SLOT(onpushButtonVRTSelect_clicked()));
+ connect(ui->pushButtonENVIDatSelect, SIGNAL(clicked()), this, SLOT(onpushButtonENVIDatSelect_clicked()));
+ connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(onbuttonBox_accepted()));
+ connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(onbuttonBox_rejected()));
+
+}
+
+RasterVRT2ENVIdataDialog::~RasterVRT2ENVIdataDialog()
+{}
+
+void RasterVRT2ENVIdataDialog::onpushButtonVRTSelect_clicked()
+{
+ QString fileNames = QFileDialog::getOpenFileName(
+ this, //
+ tr(u8"ѡL1Bļ"), //
+ QString(), // Ĭ·
+ tr(ENVI_FILE_FORMAT_FILTER) // ļ
+ );
+ // ûѡļ
+ if (!fileNames.isEmpty()) {
+ QString message = "ѡļУ\n";
+ this->ui->lineEditVRTPath->setText(fileNames);
+ }
+ else {
+ QMessageBox::information(this, tr(u8"ûѡļ"), tr(u8"ûѡκļ"));
+ }
+}
+
+void RasterVRT2ENVIdataDialog::onpushButtonENVIDatSelect_clicked()
+{
+ QString fileNames = QFileDialog::getSaveFileName(
+ this, //
+ tr(u8"ѡENVIDataļ"), //
+ QString(), // Ĭ·
+ tr(ENVI_FILE_FORMAT_FILTER) // ļ
+ );
+ // ûѡļ
+ if (!fileNames.isEmpty()) {
+ QString message = "ѡļУ\n";
+ this->ui->lineEditENVIDatPath->setText(fileNames);
+ }
+ else {
+ QMessageBox::information(this, tr(u8"ûѡļ"), tr(u8"ûѡκļ"));
+ }
+}
+
+void RasterVRT2ENVIdataDialog::onbuttonBox_accepted()
+{
+ QString vrtrasterpath = ui->lineEditVRTPath->text();
+ QString envidatapath = ui->lineEditENVIDatPath->text();
+
+ ConvertVrtToEnvi(vrtrasterpath, envidatapath);
+
+
+ QMessageBox::information(this, tr(u8"ʾ"), tr(u8""));
+}
+
+void RasterVRT2ENVIdataDialog::onbuttonBox_rejected()
+{
+ this->close();
+}
diff --git a/Toolbox/BaseToolbox/BaseToolbox/RasterVRT2ENVIdataDialog.h b/Toolbox/BaseToolbox/BaseToolbox/RasterVRT2ENVIdataDialog.h
new file mode 100644
index 0000000..b4123c8
--- /dev/null
+++ b/Toolbox/BaseToolbox/BaseToolbox/RasterVRT2ENVIdataDialog.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include
+
+namespace Ui {
+ class RasterVRT2ENVIdataDialogClass;
+}
+
+
+class RasterVRT2ENVIdataDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ RasterVRT2ENVIdataDialog(QWidget *parent = nullptr);
+ ~RasterVRT2ENVIdataDialog();
+
+
+public slots:
+ void onpushButtonVRTSelect_clicked();
+ void onpushButtonENVIDatSelect_clicked();
+ void onbuttonBox_accepted();
+ void onbuttonBox_rejected();
+private:
+ Ui::RasterVRT2ENVIdataDialogClass* ui;
+};
diff --git a/Toolbox/BaseToolbox/BaseToolbox/RasterVRT2ENVIdataDialog.ui b/Toolbox/BaseToolbox/BaseToolbox/RasterVRT2ENVIdataDialog.ui
new file mode 100644
index 0000000..9e76517
--- /dev/null
+++ b/Toolbox/BaseToolbox/BaseToolbox/RasterVRT2ENVIdataDialog.ui
@@ -0,0 +1,126 @@
+
+
+ RasterVRT2ENVIdataDialogClass
+
+
+
+ 0
+ 0
+ 396
+ 156
+
+
+
+ RasterVRT2ENVIdataDialog
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ 选择
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ 选择
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ vrt文件地址:
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ 输出dat地址:
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+
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;
}
diff --git a/Toolbox/BaseToolbox/SARSatalliteSimulationWorkflow.cpp b/Toolbox/BaseToolbox/SARSatalliteSimulationWorkflow.cpp
new file mode 100644
index 0000000..a7d7db9
--- /dev/null
+++ b/Toolbox/BaseToolbox/SARSatalliteSimulationWorkflow.cpp
@@ -0,0 +1,90 @@
+#include "SARSatalliteSimulationWorkflow.h"
+#include "QtCreateGPSPointsDialog.h"
+#include "QResampleRefrenceRaster.h"
+#include "DEMLLA2XYZTool.h"
+
+
+void initBaseToolSARSateSimulationWorkflow(ToolBoxWidget* toolbox)
+{
+ // 1. иɹڵ
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"GF3B"}, new TLE2SatePositionVelocityToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"GF3C"}, new TLE2SatePositionVelocityToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"LT1A"}, new TLE2SatePositionVelocityToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"LT1B"}, new TLE2SatePositionVelocityToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"HJ2E"}, new TLE2SatePositionVelocityToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"HJ2F"}, new TLE2SatePositionVelocityToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"LT04"}, new TLE2SatePositionVelocityToolButton(toolbox));
+
+ // 3. Ӱ
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"GF3B"}, new QAligendLandClsAndDEMToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"GF3C"}, new QAligendLandClsAndDEMToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"LT1A"}, new QAligendLandClsAndDEMToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"LT1B"}, new QAligendLandClsAndDEMToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"HJ2E"}, new QAligendLandClsAndDEMToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"HJ2F"}, new QAligendLandClsAndDEMToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"LT04"}, new QAligendLandClsAndDEMToolButton(toolbox));
+
+
+ // 4. عʸӰ
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"GF3B"}, new QDEMLLA2XYZSloperVectorToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"GF3C"}, new QDEMLLA2XYZSloperVectorToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"LT1A"}, new QDEMLLA2XYZSloperVectorToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"LT1B"}, new QDEMLLA2XYZSloperVectorToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"HJ2E"}, new QDEMLLA2XYZSloperVectorToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"HJ2F"}, new QDEMLLA2XYZSloperVectorToolButton(toolbox));
+ emit toolbox->addBoxToolItemInPathSIGNAL(QVector{u8"", u8"LT04"}, new QDEMLLA2XYZSloperVectorToolButton(toolbox));
+
+
+
+
+
+
+}
+
+TLE2SatePositionVelocityToolButton::TLE2SatePositionVelocityToolButton(QWidget* parent)
+{
+ this->toolname = QString(u8" иɹڵ");
+}
+
+TLE2SatePositionVelocityToolButton::~TLE2SatePositionVelocityToolButton()
+{
+}
+
+void TLE2SatePositionVelocityToolButton::run()
+{
+ QtCreateGPSPointsDialog* dialog = new QtCreateGPSPointsDialog;
+ dialog->setWindowTitle(u8"иɹڵ");
+ dialog->show();
+}
+
+QAligendLandClsAndDEMToolButton::QAligendLandClsAndDEMToolButton(QWidget* parent)
+{
+ this->toolname = QString(u8" Ӱ");
+}
+
+QAligendLandClsAndDEMToolButton::~QAligendLandClsAndDEMToolButton()
+{
+}
+
+void QAligendLandClsAndDEMToolButton::run()
+{
+ QResampleRefrenceRaster* dialog = new QResampleRefrenceRaster;
+ dialog->setWindowTitle(u8"ΣݵդزӰ");
+ dialog->show();
+}
+
+QDEMLLA2XYZSloperVectorToolButton::QDEMLLA2XYZSloperVectorToolButton(QWidget* parent)
+{
+ this->toolname = QString(u8" ɵĿʸ");
+}
+
+QDEMLLA2XYZSloperVectorToolButton::~QDEMLLA2XYZSloperVectorToolButton()
+{
+}
+
+void QDEMLLA2XYZSloperVectorToolButton::run()
+{
+ DEMLLA2XYZTool* dialog = new DEMLLA2XYZTool();
+ dialog->setWindowTitle(u8"ݵդɵĿʸ");
+ dialog->show();
+}
diff --git a/Toolbox/BaseToolbox/SARSatalliteSimulationWorkflow.h b/Toolbox/BaseToolbox/SARSatalliteSimulationWorkflow.h
new file mode 100644
index 0000000..9f447b9
--- /dev/null
+++ b/Toolbox/BaseToolbox/SARSatalliteSimulationWorkflow.h
@@ -0,0 +1,64 @@
+#pragma once
+
+
+#ifndef __BASETOOLBOX__SARSATALLITESIMULATIONWORKFLOW__H__
+#define __BASETOOLBOX__SARSATALLITESIMULATIONWORKFLOW__H__
+
+
+/**
+ * \file SARSatalliteSimulationWorkflow.h
+ * \brief 洦˵
+ *
+ * \author 30453
+ * \date April 2025
+ *
+ **/
+#include "basetoolbox_global.h"
+#include "ToolBoxWidget.h"
+
+
+extern "C" BASETOOLBOX_EXPORT void initBaseToolSARSateSimulationWorkflow(ToolBoxWidget* toolbox);
+
+
+
+
+class BASETOOLBOX_EXPORT TLE2SatePositionVelocityToolButton : public QToolAbstract {
+ Q_OBJECT
+public:
+ TLE2SatePositionVelocityToolButton(QWidget* parent = nullptr);
+ ~TLE2SatePositionVelocityToolButton();
+public:
+ virtual void run() override;
+
+};
+
+
+
+class BASETOOLBOX_EXPORT QAligendLandClsAndDEMToolButton : public QToolAbstract {
+ Q_OBJECT
+public:
+ QAligendLandClsAndDEMToolButton(QWidget* parent = nullptr);
+ ~QAligendLandClsAndDEMToolButton();
+public :
+ virtual void run() override;
+
+};
+
+class BASETOOLBOX_EXPORT QDEMLLA2XYZSloperVectorToolButton : public QToolAbstract {
+ Q_OBJECT
+public:
+ QDEMLLA2XYZSloperVectorToolButton(QWidget* parent = nullptr);
+ ~QDEMLLA2XYZSloperVectorToolButton();
+public:
+ virtual void run() override;
+
+};
+
+
+
+
+
+#endif
+
+
+
diff --git a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableSimulationComputer.cu b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableSimulationComputer.cu
index 6d6e7ef..2252520 100644
--- a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableSimulationComputer.cu
+++ b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableSimulationComputer.cu
@@ -145,6 +145,87 @@ __global__ void Kernel_RDProcess_doppler(
+__global__ void Kernel_RDProcess_doppler_calRangeDistance(
+ double* demX, double* demY, double* demZ,
+ double* outR,
+ long pixelcount,
+ double Xp0, double Yp0, double Zp0, double Xv0, double Yv0, double Zv0,
+ double Xp1, double Yp1, double Zp1, double Xv1, double Yv1, double Zv1,
+ double Xp2, double Yp2, double Zp2, double Xv2, double Yv2, double Zv2,
+ double Xp3, double Yp3, double Zp3, double Xv3, double Yv3, double Zv3,
+ double Xp4, double Yp4, double Zp4, double Xv4, double Yv4, double Zv4,
+ double Xp5, double Yp5, double Zp5, double Xv5, double Yv5, double Zv5,
+ double reftime, double r0, double r1, double r2, double r3, double r4,
+ double starttime, double nearRange, double farRange,
+ double PRF, double Fs,
+ double fact_lamda
+) {
+ long idx = blockIdx.x * blockDim.x + threadIdx.x;
+ if (idx < pixelcount) {
+ double demx = demX[idx];
+ double demy = demY[idx];
+ double demz = demZ[idx];
+ double dt = 1.0 / PRF / 3;
+ double Spx = 0, Spy = 0, Spz = 0, Svx = 0, Svy = 0, Svz = 0;
+ double Rx = 0, Ry = 0, Rz = 0, R = 0;
+
+ double dp1 = 0, dpn1 = 0, dp2 = 0, dpn2 = 0;
+
+ double ti = 0;
+ double inct = 0;
+ for (long i = 0; i < 10000; i++) { // Χ
+ Spx = getPolyfitNumber(ti + dt, Xp0, Xp1, Xp2, Xp3, Xp4, Xp5);
+ Spy = getPolyfitNumber(ti + dt, Yp0, Yp1, Yp2, Yp3, Yp4, Yp5);
+ Spz = getPolyfitNumber(ti + dt, Zp0, Zp1, Zp2, Zp3, Zp4, Zp5);
+ Svx = getPolyfitNumber(ti + dt, Xv0, Xv1, Xv2, Xv3, Xv4, Xv5);
+ Svy = getPolyfitNumber(ti + dt, Yv0, Yv1, Yv2, Yv3, Yv4, Yv5);
+ Svz = getPolyfitNumber(ti + dt, Zv0, Zv1, Zv2, Zv3, Zv4, Zv5);
+
+ Rx = Spx - demx;
+ Ry = Spy - demy;
+ Rz = Spz - demz;
+ R = sqrt(Rx * Rx + Ry * Ry + Rz * Rz);
+ Rx = Rx / R;
+ Ry = Ry / R;
+ Rz = Rz / R;
+
+ dp2 = getDopplerCenterRate(Rx, Ry, Rz, Svx, Svy, Svz, fact_lamda);
+ dpn2 = getNumberDopplerCenterRate(R, r0, r1, r2, r3, r4, reftime);
+
+ // ti
+ Spx = getPolyfitNumber(ti, Xp0, Xp1, Xp2, Xp3, Xp4, Xp5);
+ Spy = getPolyfitNumber(ti, Yp0, Yp1, Yp2, Yp3, Yp4, Yp5);
+ Spz = getPolyfitNumber(ti, Zp0, Zp1, Zp2, Zp3, Zp4, Zp5);
+ Svx = getPolyfitNumber(ti, Xv0, Xv1, Xv2, Xv3, Xv4, Xv5);
+ Svy = getPolyfitNumber(ti, Yv0, Yv1, Yv2, Yv3, Yv4, Yv5);
+ Svz = getPolyfitNumber(ti, Zv0, Zv1, Zv2, Zv3, Zv4, Zv5);
+
+ Rx = Spx - demx;
+ Ry = Spy - demy;
+ Rz = Spz - demz;
+ R = sqrt(Rx * Rx + Ry * Ry + Rz * Rz);
+ Rx = Rx / R;
+ Ry = Ry / R;
+ Rz = Rz / R;
+
+ dp1 = getDopplerCenterRate(Rx, Ry, Rz, Svx, Svy, Svz, fact_lamda);
+ dpn1 = getNumberDopplerCenterRate(R, r0, r1, r2, r3, r4, reftime);
+
+ // iter
+ inct = dt * (dp2 - dpn1) / (dp1 - dp2);
+
+ if (abs(inct) <= dt || isnan(inct)) {
+ outR[idx] = R;//Rd_c;
+ return;
+ }
+ ti = ti + inct;
+ }
+ outR[idx] = 0;
+ }
+}
+
+
+
void RDProcess_dopplerGPU(
@@ -185,6 +266,51 @@ void RDProcess_dopplerGPU(
cudaDeviceSynchronize();
}
+
+
+void RDProcess_dopplerGPU_InSARImagePlaneXYZR(
+ double* demX, double* demY, double* demZ,
+ double* outR,
+ long rowcount, long colcount,
+ double starttime, double nearRange, double farRange,
+ double PRF, double Fs,
+ double fact_lamda,
+ double Xp0, double Yp0, double Zp0, double Xv0, double Yv0, double Zv0,
+ double Xp1, double Yp1, double Zp1, double Xv1, double Yv1, double Zv1,
+ double Xp2, double Yp2, double Zp2, double Xv2, double Yv2, double Zv2,
+ double Xp3, double Yp3, double Zp3, double Xv3, double Yv3, double Zv3,
+ double Xp4, double Yp4, double Zp4, double Xv4, double Yv4, double Zv4,
+ double Xp5, double Yp5, double Zp5, double Xv5, double Yv5, double Zv5,
+ double reftime, double r0, double r1, double r2, double r3, double r4
+
+)
+{
+ long pixelcount = rowcount * colcount;
+ int numBlocks = (pixelcount + BLOCK_SIZE - 1) / BLOCK_SIZE;
+ Kernel_RDProcess_doppler_calRangeDistance << > > (
+ demX, demY, demZ,
+ outR,
+ pixelcount,
+ Xp0, Yp0, Zp0, Xv0, Yv0, Zv0,
+ Xp1, Yp1, Zp1, Xv1, Yv1, Zv1,
+ Xp2, Yp2, Zp2, Xv2, Yv2, Zv2,
+ Xp3, Yp3, Zp3, Xv3, Yv3, Zv3,
+ Xp4, Yp4, Zp4, Xv4, Yv4, Zv4,
+ Xp5, Yp5, Zp5, Xv5, Yv5, Zv5,
+ reftime, r0, r1, r2, r3, r4,
+ starttime, nearRange, farRange,
+ PRF, Fs,
+ fact_lamda
+ );
+ PrintLasterError("RD with doppler function");
+ cudaDeviceSynchronize();
+}
+
+
+
+
+
+
__device__ double calculateIncidenceAngle(double Rx, double Ry, double Rz, double Sx, double Sy, double Sz) {
double dotProduct = Rx * Sx + Ry * Sy + Rz * Sz;
double magnitudeR = sqrt(Rx * Rx + Ry * Ry + Rz * Rz);
diff --git a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableSimulationComputer.cuh b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableSimulationComputer.cuh
index 1ce140e..a697719 100644
--- a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableSimulationComputer.cuh
+++ b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/LookTableSimulationComputer.cuh
@@ -57,3 +57,21 @@ extern "C" void RDProcess_demSloperGPU(
);
+
+
+
+extern "C" void RDProcess_dopplerGPU_InSARImagePlaneXYZR(
+ double* demX, double* demY, double* demZ,
+ double* outR,
+ long rowcount, long colcount,
+ double starttime, double nearRange, double farRange,
+ double PRF, double Fs,
+ double fact_lamda,
+ double Xp0, double Yp0, double Zp0, double Xv0, double Yv0, double Zv0,
+ double Xp1, double Yp1, double Zp1, double Xv1, double Yv1, double Zv1,
+ double Xp2, double Yp2, double Zp2, double Xv2, double Yv2, double Zv2,
+ double Xp3, double Yp3, double Zp3, double Xv3, double Yv3, double Zv3,
+ double Xp4, double Yp4, double Zp4, double Xv4, double Yv4, double Zv4,
+ double Xp5, double Yp5, double Zp5, double Xv5, double Yv5, double Zv5,
+ double reftime, double r0, double r1, double r2, double r3, double r4
+);
\ No newline at end of file
diff --git a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QLookTableResampleFromWGS84ToRange.cpp b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QLookTableResampleFromWGS84ToRange.cpp
new file mode 100644
index 0000000..38004a5
--- /dev/null
+++ b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QLookTableResampleFromWGS84ToRange.cpp
@@ -0,0 +1,95 @@
+#include "QLookTableResampleFromWGS84ToRange.h"
+#include "BaseConstVariable.h"
+#include "BaseTool.h"
+#include
+#include
+#include "ui_QLookTableResampleFromWGS84ToRange.h"
+#include "ImageNetOperator.h"
+
+QLookTableResampleFromWGS84ToRange::QLookTableResampleFromWGS84ToRange(QWidget *parent)
+ : QDialog(parent)
+ ,ui(new Ui::QLookTableResampleFromWGS84ToRangeClass)
+{
+ ui->setupUi(this);
+
+ connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(onaccepted()));
+ connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(onrejected()));
+ connect(ui->pushButtonLookTableWGS84Select, SIGNAL(clicked(bool)), this, SLOT(onpushButtonLookTableWGS84SelectClicked(bool)));
+ connect(ui->pushButtonLookTableRangeSelect, SIGNAL(clicked(bool)), this, SLOT(onpushButtonLookTableRangeSelectClicked(bool)));
+ connect(ui->pushButtonLookTableCountSelect, SIGNAL(clicked(bool)), this, SLOT(onpushButtonLookTableCountSelectClicked(bool)));
+}
+
+QLookTableResampleFromWGS84ToRange::~QLookTableResampleFromWGS84ToRange()
+{}
+
+void QLookTableResampleFromWGS84ToRange::onaccepted()
+{
+ QString looktableWGS84Ptah = ui->lineEditLookTableWGS84Path->text();
+ QString looktableRangePtah = ui->lineEditLookTableRangePath->text();
+ QString looktableCountPtah = ui->lineEditLookTableCountPath->text();
+
+ long Oriheight = ui->spinBoxRowCount->value();
+ long OriWidth = ui->spinBoxColCount->value();
+
+ ReflectTable_WGS2Range(looktableWGS84Ptah, looktableRangePtah, looktableCountPtah, Oriheight, OriWidth);
+ QMessageBox::information(nullptr, u8"ʾ", u8"");
+}
+
+void QLookTableResampleFromWGS84ToRange::onrejected()
+{
+ this->close();
+}
+
+void QLookTableResampleFromWGS84ToRange::onpushButtonLookTableWGS84SelectClicked(bool)
+{
+ QString fileNames = QFileDialog::getOpenFileName(
+ this,
+ tr(u8"ѡWGS84ļ"),
+ QString(),
+ tr(ENVI_FILE_FORMAT_FILTER)
+ );
+
+ if (!fileNames.isEmpty()) {
+ QString message = "ѡļ\n";
+ this->ui->lineEditLookTableWGS84Path->setText(fileNames);
+ }
+ else {
+ QMessageBox::information(this, tr(u8"ʾ"), tr(u8"ûѡļ"));
+ }
+}
+
+void QLookTableResampleFromWGS84ToRange::onpushButtonLookTableRangeSelectClicked(bool)
+{
+ QString fileNames = QFileDialog::getSaveFileName(
+ this,
+ tr(u8"бƽļ"),
+ QString(),
+ tr(ENVI_FILE_FORMAT_FILTER)
+ );
+
+ if (!fileNames.isEmpty()) {
+ QString message = "ѡļ\n";
+ this->ui->lineEditLookTableRangePath->setText(fileNames);
+ }
+ else {
+ QMessageBox::information(this, tr(u8"ʾ"), tr(u8"ûѡļ"));
+ }
+}
+
+void QLookTableResampleFromWGS84ToRange::onpushButtonLookTableCountSelectClicked(bool)
+{
+ QString fileNames = QFileDialog::getSaveFileName(
+ this,
+ tr(u8"ͳƲƽļ"),
+ QString(),
+ tr(ENVI_FILE_FORMAT_FILTER)
+ );
+
+ if (!fileNames.isEmpty()) {
+ QString message = "ѡļ\n";
+ this->ui->lineEditLookTableCountPath->setText(fileNames);
+ }
+ else {
+ QMessageBox::information(this, tr(u8"ʾ"), tr(u8"ûѡļ"));
+ }
+}
diff --git a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QLookTableResampleFromWGS84ToRange.h b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QLookTableResampleFromWGS84ToRange.h
new file mode 100644
index 0000000..6f90bf2
--- /dev/null
+++ b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QLookTableResampleFromWGS84ToRange.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include
+
+
+namespace Ui {
+ class QLookTableResampleFromWGS84ToRangeClass;
+}
+
+class QLookTableResampleFromWGS84ToRange : public QDialog
+{
+ Q_OBJECT
+
+public:
+ QLookTableResampleFromWGS84ToRange(QWidget *parent = nullptr);
+ ~QLookTableResampleFromWGS84ToRange();
+
+
+public slots:
+
+ void onaccepted();
+ void onrejected();
+ void onpushButtonLookTableWGS84SelectClicked(bool);
+ void onpushButtonLookTableRangeSelectClicked(bool);
+ void onpushButtonLookTableCountSelectClicked(bool);
+
+
+private:
+ Ui::QLookTableResampleFromWGS84ToRangeClass* ui;
+};
diff --git a/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QLookTableResampleFromWGS84ToRange.ui b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QLookTableResampleFromWGS84ToRange.ui
new file mode 100644
index 0000000..42e6ae2
--- /dev/null
+++ b/Toolbox/SimulationSARTool/PowerSimulationIncoherent/QLookTableResampleFromWGS84ToRange.ui
@@ -0,0 +1,201 @@
+
+
+ QLookTableResampleFromWGS84ToRangeClass
+
+
+
+ 0
+ 0
+ 747
+ 293
+
+
+
+ QLookTableResampleFromWGS84ToRange
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ 选择
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ 行数
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ 查找表(斜距)
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ 选择
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ 查找表(WGS84)
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ 查找表采样点数
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ 选择
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ 列数
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ 999999999
+
+
+
+ -
+
+
+
+ 0
+ 30
+
+
+
+ 999999999
+
+
+
+
+
+
+
+
+
diff --git a/Toolbox/SimulationSARTool/SARImage/GPUBPImageNet.cu b/Toolbox/SimulationSARTool/SARImage/GPUBPImageNet.cu
new file mode 100644
index 0000000..c5e94a2
--- /dev/null
+++ b/Toolbox/SimulationSARTool/SARImage/GPUBPImageNet.cu
@@ -0,0 +1,204 @@
+#include "GPUBaseTool.h"
+#include "GPUBPTool.cuh"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "BaseConstVariable.h"
+#include "GPUBPImageNet.cuh"
+
+#ifndef MAX_ITER
+#define EPSILON 1e-12
+#define MAX_ITER 50
+#endif
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+
+__global__ void kernel_TimeBPImageGridNet(
+ double* antPx, double* antPy, double* antPz,
+ double* antDirx, double* antDiry, double* antDirz,
+ double* imgx, double* imgy, double* imgz,
+ long prfcount, long freqpoints, double meanH,
+ double Rnear, double dx) {
+
+ long idx = blockIdx.x * blockDim.x + threadIdx.x;
+ long pixelcount = prfcount * freqpoints;
+ long prfid = idx / freqpoints;
+ long Rid = idx % freqpoints;
+ if (idx < pixelcount) {
+ //
+ Vector3 S = { antPx[prfid], antPy[prfid], antPz[prfid] }; // λ (m)
+ Vector3 ray = { antDirx[prfid], antDiry[prfid], antDirz[prfid] }; // ߷
+ double H = meanH; // ƽ߳
+ double R = Rnear + dx * Rid; // Ŀ
+ // У
+ if (R <= 0 || H < -WGS84_A * 0.1 || H > WGS84_A * 0.1) {
+ //printf("\n HΧ%.1f km\n R>0\n", WGS84_A * 0.1 / 1000);
+ imgx[idx] = 0;
+ imgy[idx] = 0;
+ imgz[idx] = 0;
+ return;
+ //printf("idx=%d;prfid=%d;Rid=%d;S=[%f , %f ,%f ];ray=[%f ,%f ,%f ];H=%f;R=%f,imgP=[%f ,%f , %f ];Rextend\n",
+ // idx, prfid, Rid, S.x, S.y, S.z, ray.x, ray.y, ray.z, H, R,imgx[idx],imgy[idx],imgz[idx]);
+ // У
+ //return;
+ }
+
+ // Step 1: 㽻T
+ Vector3 T = compute_T(S, ray, H);
+ if (isnan(T.x)) {
+ imgx[idx] = 0;
+ imgy[idx] = 0;
+ imgz[idx] = 0;
+ //printf("idx=%d;prfid=%d;Rid=%d;Tnan\n",
+ // idx, prfid, Rid, S.x, S.y, S.z, ray.x, ray.y, ray.z, H, R,T.x,T.y,T.z, imgx[idx], imgy[idx], imgz[idx]);
+ return;
+ }
+
+ // Step 2: ĿP
+
+ Vector3 P;// = compute_P(S, T, R, H);
+ { // P
+ Vector3 ex, ey, ez; // ƽ
+ Vector3 ST = vec_normalize(vec_sub(T, S));// S->T
+ Vector3 SO = vec_normalize(vec_sub(Vector3{ 0, 0, 0 }, S)); // S->O
+
+
+ Vector3 st1 = vec_sub(T, S);
+ double R0 = sqrt(st1.x * st1.x + st1.y * st1.y + st1.z * st1.z);
+ ez = vec_normalize(vec_cross(SO, ST)); // Z
+ ey = vec_normalize(vec_cross(ez, SO)); // Y ST ͬ --ǵؼԼȻģ
+ ex = vec_normalize(SO); //X
+
+
+
+ double h2 = (WGS84_A + H) * (WGS84_A + H);
+ double b2 = WGS84_B * WGS84_B;
+ double R2 = R * R;
+ double A = R2 * ((ex.x * ex.x + ex.y * ex.y) / h2 + (ex.z * ex.z) / b2);
+ double B = R2 * ((ex.x * ey.x + ex.y * ey.y) / h2 + (ex.z * ey.z) / b2) * 2;
+ double C = R2 * ((ey.x * ey.x + ey.y * ey.y) / h2 + (ey.z * ey.z) / b2);
+ double D = 1 - ((S.x * S.x + S.y * S.y) / h2 + (S.z * S.z) / b2);
+ double E = 2 * R * ((S.x * ex.x + S.y * ex.y) / h2 + (S.z * ex.z) / b2);
+ double F = 2 * R * ((S.x * ey.x + S.y * ey.y) / h2 + (S.z * ey.z) / b2);
+ double Q0 = angleBetweenVectors(SO, ST, false);
+ double dQ = 0;
+ double fQ = 0;
+ double dfQ = 0;
+ double Q = R < R0 ? Q0 - 1e-3 : Q0 + 1e-3;
+
+ //printf("A=%f;B=%f;C=%f;D=%f;E=%f;F=%f;Q=%f;\
+ // S=[%f , %f ,%f ];\
+ // T=[%f , %f ,%f ];\
+ // ex=[%f , %f ,%f ];\
+ // ey=[%f , %f ,%f ];\
+ // ez=[%f , %f ,%f ];\
+ //ray=[%f ,%f ,%f ];\
+ //H=%f;R=%f;;\n",A,B,C,D,E,F,Q,
+ // S.x,S.y,S.z,
+ // T.x,T.y,T.z ,
+ // ex.x,ex.y,ex.z,
+ // ey.x,ey.y,ey.z,
+ // ez.x,ez.y,ez.z,
+ // ray.x, ray.y, ray.z,
+ // H, R);
+ // return;
+
+ // ţٵ
+ for (int iter = 0; iter < MAX_ITER * 10; ++iter) {
+ fQ = A * cos(Q) * cos(Q) + B * sin(Q) * cos(Q) + C * sin(Q) * sin(Q) + E * cos(Q) + F * sin(Q) - D;
+ dfQ = (C - A) * sin(2 * Q) + B * cos(2 * Q) - E * sin(Q) + F * cos(Q);
+ dQ = fQ / dfQ;
+ if (abs(dQ) < 1e-8) {
+ //printf("iter=%d;check Q0=%f;Q=%f;dQ=%f;fQ=%f;dfQ=%f;break\n", iter, Q0, Q, dQ, fQ, dfQ);
+ break;
+ }
+ else {
+ dQ = (abs(dQ) < d2r * 3) ? dQ : (abs(dQ) / dQ * d2r * 3);
+ Q = Q - dQ;
+ //printf("iter=%d;check Q0=%f;Q=%f;dQ=%f;fQ=%f;dfQ=%f;\n", iter, Q0, Q, dQ, fQ, dfQ);
+ }
+
+ }
+ //printf("check Q0=%f;Q=%f;\n", Q0, Q);
+ double t1 = R * cos(Q);
+ double t2 = R * sin(Q);
+ P = Vector3{
+ S.x + t1 * ex.x + t2 * ey.x, //Ϊ t3=0
+ S.y + t1 * ex.y + t2 * ey.y,
+ S.z + t1 * ex.z + t2 * ey.z,
+ };
+ double check = (P.x * P.x + P.y * P.y) / ((WGS84_A + H) * (WGS84_A + H))
+ + P.z * P.z / (WGS84_B * WGS84_B);
+ if (isnan(Q) || isinf(Q) || fabs(check - 1.0) > 1e-6) {
+ P = Vector3{ 0,0,0 };
+ imgx[idx] = 0;
+ imgy[idx] = 0;
+ imgz[idx] = 0;
+ return;
+ }
+ }
+
+ double Rt = sqrt(pow(S.x - T.x, 2) + pow(S.y - T.y, 2) + pow(S.z - T.z, 2));
+ double Rp = sqrt(pow(S.x - P.x, 2) + pow(S.y - P.y, 2) + pow(S.z - P.z, 2));
+ double Rop = sqrt(pow(P.x, 2) + pow(P.y, 2) + pow(P.z, 2));
+
+ if (!isnan(P.x) && (Rop > WGS84_A * 0.3) && (Rop < WGS84_A * 3)) {
+
+ imgx[idx] = P.x;
+ imgy[idx] = P.y;
+ imgz[idx] = P.z;
+ return;
+ //printf("idx=%d; S=[%f , %f ,%f ]; H=%f;R=%f;RP=%f;Rr=%f;imgT=[%f ,%f ,%f ];imgP=[%f ,%f , %f ]; \n",
+ // idx, S.x, S.y, S.z, H, R, Rp, Rt,T.x, T.y, T.z, P.x, P.y, P.z);
+ }
+ else {
+ imgx[idx] = 0;
+ imgy[idx] = 0;
+ imgz[idx] = 0;
+ printf("idx=%d; S=[%f , %f ,%f ]; H=%f;R=%f;RP=%f;Rr=%f;imgT=[%f ,%f ,%f ];imgP=[%f ,%f , %f ]; ERROR\n",
+ idx, S.x, S.y, S.z, H, R, Rp, Rt, T.x, T.y, T.z, P.x, P.y, P.z);
+ return;
+ }
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+void TIMEBPCreateImageGrid(double* antPx, double* antPy, double* antPz,
+ double* antDirx, double* antDiry, double* antDirz,
+ double* imgx, double* imgy, double* imgz,
+ long prfcount, long freqpoints, double meanH,
+ double Rnear, double dx
+)
+{
+ long pixelcount = prfcount * freqpoints;
+ int grid_size = (pixelcount + BLOCK_SIZE - 1) / BLOCK_SIZE;
+
+ kernel_TimeBPImageGridNet << > > (
+ antPx, antPy, antPz,
+ antDirx, antDiry, antDirz,
+ imgx, imgy, imgz,
+ prfcount, freqpoints, meanH,
+ Rnear, dx);
+ PrintLasterError("TIMEBPCreateImageGrid");
+ cudaDeviceSynchronize();
+}
diff --git a/Toolbox/SimulationSARTool/SARImage/GPUBPImageNet.cuh b/Toolbox/SimulationSARTool/SARImage/GPUBPImageNet.cuh
new file mode 100644
index 0000000..e62e525
--- /dev/null
+++ b/Toolbox/SimulationSARTool/SARImage/GPUBPImageNet.cuh
@@ -0,0 +1,28 @@
+#ifndef __GPUBPIMAGENET_CUH___
+#define __GPUBPIMAGENET_CUH___
+
+
+#include "BaseConstVariable.h"
+#include "GPUTool.cuh"
+#include
+#include
+#include
+#include
+#include "GPUTool.cuh"
+#include "GPUBPTool.cuh"
+
+
+
+
+
+extern "C" void TIMEBPCreateImageGrid(
+ double* antPx, double* antPy, double* antPz, // S
+ double* antDirx, double* antDiry, double* antDirz, //
+ double* imgx, double* imgy, double* imgz,
+ long prfcount, long freqpoints, double meanH,
+ double Rnear, double dx
+);
+
+
+
+#endif
\ No newline at end of file
diff --git a/Toolbox/SimulationSARTool/SARImage/ImageNetOperator.cpp b/Toolbox/SimulationSARTool/SARImage/ImageNetOperator.cpp
new file mode 100644
index 0000000..cd5078d
--- /dev/null
+++ b/Toolbox/SimulationSARTool/SARImage/ImageNetOperator.cpp
@@ -0,0 +1,1118 @@
+#include "ImageNetOperator.h"
+#include "LogInfoCls.h"
+#include "PrintMsgToQDebug.h"
+#include
+#include "ImageOperatorBase.h"
+#include "GPUBaseTool.h"
+#include "GPUBPImageNet.cuh"
+#include "BaseTool.h"
+#include "BaseConstVariable.h"
+
+
+void InitCreateImageXYZProcess(QString& outImageLLPath, QString& outImageXYZPath, QString& InEchoGPSDataPath,
+ double& NearRange, double& RangeResolution, int64_t& RangeNum)
+{
+ qDebug() << "---------------------------------------------------------------------------------";
+ qDebug() << u8"ֳƽбͶӰ";
+ gdalImage antimg(InEchoGPSDataPath);
+ qDebug() << u8"1. زGPSļ\t";
+ qDebug() << u8"ļ·\t" << InEchoGPSDataPath;
+ qDebug() << u8"GPS \t" << antimg.height;
+ qDebug() << u8"ļ\t" << antimg.width;
+ qDebug() << u8"2.б";
+ qDebug() << u8"룺\t" << NearRange;
+ qDebug() << u8"ֱʣ\t" << RangeResolution;
+ qDebug() << u8"\t" << RangeNum;
+ qDebug() << u8"3.ļ";
+ gdalImage outimgll = CreategdalImageDouble(outImageLLPath, antimg.height,RangeNum, 3,true,true);
+ gdalImage outimgxyz = CreategdalImageDouble(outImageXYZPath, antimg.height, RangeNum, 3, true, true);
+ qDebug() << u8"ƽļγȣ·\t" << outImageLLPath;
+ qDebug() << u8"ƽļXYZ·\t" << outImageXYZPath;
+ qDebug() << u8"4.ʼXYZ";
+ long prfcount = antimg.height;
+ long rangeNum = RangeNum;
+ double Rnear = NearRange;
+ double dx = RangeResolution;
+
+ long blockRangeCount = Memory1GB / sizeof(double) / 4 / prfcount *6;
+ blockRangeCount = blockRangeCount < 1 ? 1 : blockRangeCount;
+
+ std::shared_ptr Pxs((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr Pys((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr Pzs((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr AntDirectX((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr AntDirectY((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr AntDirectZ((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+
+ {
+ long colnum = 19;
+ std::shared_ptr antpos =readDataArr(antimg,0,0,prfcount, colnum,1,GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
+ double time = 0;
+ double Px = 0;
+ double Py = 0;
+ double Pz = 0;
+ for (long i = 0; i < prfcount; i++) {
+
+ Pxs.get()[i] = antpos.get()[i * 19 + 1]; //
+ Pys.get()[i] = antpos.get()[i * 19 + 2];
+ Pzs.get()[i] = antpos.get()[i * 19 + 3];
+ AntDirectX.get()[i] = antpos.get()[i * 19 + 13];// zero doppler
+ AntDirectY.get()[i] = antpos.get()[i * 19 + 14];
+ AntDirectZ.get()[i] = antpos.get()[i * 19 + 15];
+
+ double NormAnt = std::sqrt(AntDirectX.get()[i] * AntDirectX.get()[i] +
+ AntDirectY.get()[i] * AntDirectY.get()[i] +
+ AntDirectZ.get()[i] * AntDirectZ.get()[i]);
+ AntDirectX.get()[i] = AntDirectX.get()[i] / NormAnt;
+ AntDirectY.get()[i] = AntDirectY.get()[i] / NormAnt;
+ AntDirectZ.get()[i] = AntDirectZ.get()[i] / NormAnt;// һ
+ }
+ antpos.reset();
+ }
+
+ std::shared_ptr d_Pxs((double*)mallocCUDADevice(sizeof(double) * prfcount), FreeCUDADevice);
+ std::shared_ptr d_Pys((double*)mallocCUDADevice(sizeof(double) * prfcount), FreeCUDADevice);
+ std::shared_ptr d_Pzs((double*)mallocCUDADevice(sizeof(double) * prfcount), FreeCUDADevice);
+ std::shared_ptr d_AntDirectX((double*)mallocCUDADevice(sizeof(double) * prfcount), FreeCUDADevice);
+ std::shared_ptr d_AntDirectY((double*)mallocCUDADevice(sizeof(double) * prfcount), FreeCUDADevice);
+ std::shared_ptr d_AntDirectZ((double*)mallocCUDADevice(sizeof(double) * prfcount), FreeCUDADevice);
+
+ HostToDevice(Pxs.get(), d_Pxs.get(), sizeof(double) * prfcount);
+ HostToDevice(Pys.get(), d_Pys.get(), sizeof(double) * prfcount);
+ HostToDevice(Pzs.get(), d_Pzs.get(), sizeof(double) * prfcount);
+ HostToDevice(AntDirectX.get(), d_AntDirectX.get(), sizeof(double) * prfcount);
+ HostToDevice(AntDirectY.get(), d_AntDirectY.get(), sizeof(double) * prfcount);
+ HostToDevice(AntDirectZ.get(), d_AntDirectZ.get(), sizeof(double) * prfcount);
+
+
+ for (long startcolidx = 0; startcolidx < RangeNum; startcolidx = startcolidx + blockRangeCount) {
+
+ long tempechocol = blockRangeCount;
+ if (startcolidx + tempechocol >= RangeNum) {
+ tempechocol = RangeNum - startcolidx;
+ }
+ qDebug() << " imgxyz :\t" << startcolidx << "\t-\t" << startcolidx + tempechocol << " / " << RangeNum;
+
+ std::shared_ptr demx = readDataArr(outimgxyz, 0, startcolidx, prfcount, tempechocol, 1, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
+ std::shared_ptr demy = readDataArr(outimgxyz, 0, startcolidx, prfcount, tempechocol, 2, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
+ std::shared_ptr demz = readDataArr(outimgxyz, 0, startcolidx, prfcount, tempechocol, 3, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
+
+ std::shared_ptr h_demx((double*)mallocCUDAHost(sizeof(double) * prfcount * tempechocol), FreeCUDAHost);
+ std::shared_ptr h_demy((double*)mallocCUDAHost(sizeof(double) * prfcount * tempechocol), FreeCUDAHost);
+ std::shared_ptr h_demz((double*)mallocCUDAHost(sizeof(double) * prfcount * tempechocol), FreeCUDAHost);
+
+#pragma omp parallel for
+ for (long ii = 0; ii < prfcount; ii++) {
+ for (long jj = 0; jj < tempechocol; jj++) {
+ h_demx.get()[ii * tempechocol + jj] = demx.get()[ii * tempechocol + jj];
+ h_demy.get()[ii * tempechocol + jj] = demy.get()[ii * tempechocol + jj];
+ h_demz.get()[ii * tempechocol + jj] = demz.get()[ii * tempechocol + jj];
+ }
+ }
+
+ std::shared_ptr d_demx((double*)mallocCUDADevice(sizeof(double) * prfcount * tempechocol), FreeCUDADevice);
+ std::shared_ptr d_demy((double*)mallocCUDADevice(sizeof(double) * prfcount * tempechocol), FreeCUDADevice);
+ std::shared_ptr d_demz((double*)mallocCUDADevice(sizeof(double) * prfcount * tempechocol), FreeCUDADevice);
+
+ HostToDevice(h_demx.get(), d_demx.get(), sizeof(double) * prfcount * tempechocol);
+ HostToDevice(h_demy.get(), d_demy.get(), sizeof(double) * prfcount * tempechocol);
+ HostToDevice(h_demz.get(), d_demz.get(), sizeof(double) * prfcount * tempechocol);
+
+
+ TIMEBPCreateImageGrid(
+ d_Pxs.get(), d_Pys.get(), d_Pzs.get(),
+ d_AntDirectX.get(), d_AntDirectY.get(), d_AntDirectZ.get(),
+ d_demx.get(), d_demy.get(), d_demz.get(),
+ prfcount, tempechocol, 0,
+ Rnear + dx * startcolidx, dx //
+ );
+
+ DeviceToHost(h_demx.get(), d_demx.get(), sizeof(double) * prfcount * tempechocol);
+ DeviceToHost(h_demy.get(), d_demy.get(), sizeof(double) * prfcount * tempechocol);
+ DeviceToHost(h_demz.get(), d_demz.get(), sizeof(double) * prfcount * tempechocol);
+
+#pragma omp parallel for
+ for (long ii = 0; ii < prfcount; ii++) {
+ for (long jj = 0; jj < tempechocol; jj++) {
+ demx.get()[ii * tempechocol + jj] = h_demx.get()[ii * tempechocol + jj];
+ demy.get()[ii * tempechocol + jj] = h_demy.get()[ii * tempechocol + jj];
+ demz.get()[ii * tempechocol + jj] = h_demz.get()[ii * tempechocol + jj];
+ }
+ }
+
+ outimgxyz.saveImage(demx, 0, startcolidx, prfcount, tempechocol, 1);
+ outimgxyz.saveImage(demy, 0, startcolidx, prfcount, tempechocol, 2);
+ outimgxyz.saveImage(demz, 0, startcolidx, prfcount, tempechocol, 3);
+
+ // XYZתΪγ
+ std::shared_ptr demllx = readDataArr(outimgll, 0, startcolidx, prfcount, tempechocol, 1, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
+ std::shared_ptr demlly = readDataArr(outimgll, 0, startcolidx, prfcount, tempechocol, 2, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
+ std::shared_ptr demllz = readDataArr(outimgll, 0, startcolidx, prfcount, tempechocol, 3, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
+
+#pragma omp parallel for
+ for (long ii = 0; ii < prfcount; ii++) {
+ for (long jj = 0; jj < tempechocol; jj++) {
+ double x = demx.get()[ii * tempechocol + jj];
+ double y = demy.get()[ii * tempechocol + jj];
+ double z = demz.get()[ii * tempechocol + jj];
+ Landpoint point;
+ XYZ2BLH_FixedHeight(x, y, z, 0, point);
+ demllx.get()[ii * tempechocol + jj] = point.lon;
+ demlly.get()[ii * tempechocol + jj] = point.lat;
+ demllz.get()[ii * tempechocol + jj] = point.ati;
+ }
+ }
+
+
+ outimgll.saveImage(demllx, 0, startcolidx, prfcount, tempechocol, 1);
+ outimgll.saveImage(demlly, 0, startcolidx, prfcount, tempechocol, 2);
+ outimgll.saveImage(demllz, 0, startcolidx, prfcount, tempechocol, 3);
+
+ }
+
+ qDebug() << u8"6.";
+ qDebug() << "---------------------------------------------------------------------------------";
+}
+
+bool OverlapCheck(QString& ImageLLPath, QString& ImageDEMPath)
+{
+ // DEMǷWGS84ϵ
+ //long demEPSG = GetEPSGFromRasterFile(ImageDEMPath);
+ //if (demEPSG != 4326) {
+ // qDebug() << u8"DEMϵWGS84ϵ,ESPG:"<< demEPSG;
+ // return false;
+ //}
+
+ gdalImage demimg(ImageDEMPath);
+ gdalImage imgll(ImageLLPath);
+
+ long imgheight = imgll.height;
+ long imgwidth = imgll.width;
+ Eigen::MatrixXd imglonArr = imgll.getData(0, 0, imgheight, imgwidth, 1);
+ Eigen::MatrixXd imglatArr = imgll.getData(0, 0, imgheight, imgwidth, 2);
+
+ // ӡΧ
+ qDebug() << u8"ӰΧ";
+ qDebug() << u8"Сȣ\t" << imglonArr.minCoeff();
+ qDebug() << u8"ȣ\t" << imglonArr.maxCoeff();
+ qDebug() << u8"Сγȣ\t" << imglatArr.minCoeff();
+ qDebug() << u8"γȣ\t" << imglatArr.maxCoeff();
+ qDebug() << u8"DEMΧ";
+ RasterExtend demextend = demimg.getExtend();
+ qDebug() << u8"Сȣ\t" << demextend.min_x;
+ qDebug() << u8"ȣ\t" << demextend.max_x;
+ qDebug() << u8"Сγȣ\t" << demextend.min_y;
+ qDebug() << u8"γȣ\t" << demextend.max_y;
+ qDebug() << u8"ӰС\t" << demimg.height << " * " << demimg.width;
+
+
+
+ for (long i = 0; i < imgheight; i++)
+ {
+ for (long j = 0; j < imgwidth; j++)
+ {
+ double lon = imglonArr(i, j); // X
+ double lat = imglatArr(i, j); // Y
+ Landpoint point = demimg.getRow_Col(lon, lat);
+ imglonArr(i, j) = point.lon;
+ imglatArr(i, j) = point.lat;
+ }
+ }
+
+ double minX = imglonArr.minCoeff();
+ double maxX = imglonArr.maxCoeff();
+ double minY = imglatArr.minCoeff();
+ double maxY = imglatArr.maxCoeff();
+
+ //ӡΧ
+ qDebug() << u8"dem ķΧ";
+ qDebug() << u8"minX:"<demimg.width - 1 || minY<1 || maxY>demimg.height - 1) {
+ return false;
+ }
+ else {
+ return true;
+ }
+
+
+
+}
+
+bool GPSPointsNumberEqualCheck(QString& ImageLLPath, QString& InEchoGPSDataPath)
+{
+
+ gdalImage antimg(InEchoGPSDataPath);
+ gdalImage imgll(ImageLLPath);
+ return antimg.height == imgll.height;
+
+}
+
+
+
+void InterploateAtiByRefDEM(QString& ImageLLPath, QString& ImageDEMPath, QString& outImageLLAPath, QString& InEchoGPSDataPath)
+{
+ gdalImage demimg(ImageDEMPath);
+ gdalImage imgll(ImageLLPath);
+ gdalImage outimgll = CreategdalImageDouble(outImageLLAPath, imgll.height, imgll.width, 4, true, true); // ȡγȡ̡߳б
+
+ long imgheight = imgll.height;
+ long imgwidth = imgll.width;
+
+ Eigen::MatrixXd imglonArr = imgll.getData(0, 0, imgheight, imgwidth, 1);
+ Eigen::MatrixXd imglatArr = imgll.getData(0, 0, imgheight, imgwidth, 2);
+ Eigen::MatrixXd demArr = demimg.getData(0, 0, demimg.height, demimg.width, 1);
+ Eigen::MatrixXd imgatiArr = Eigen::MatrixXd::Zero(imgheight, imgwidth);
+ Eigen::MatrixXd imgRArr = Eigen::MatrixXd::Zero(imgheight, imgwidth);
+
+ outimgll.saveImage(imglonArr, 0, 0, 1);
+ outimgll.saveImage(imglatArr, 0, 0, 2);
+
+
+ double minX = imglonArr.minCoeff();
+ double maxX = imglonArr.maxCoeff();
+ double minY = imglatArr.minCoeff();
+ double maxY = imglatArr.maxCoeff();
+ //ӡΧ
+ qDebug() << u8"dem ķΧ";
+ qDebug() << u8"minX:" << minX << "\t" << demimg.width;
+ qDebug() << u8"maxX:" << maxX << "\t" << demimg.width;
+ qDebug() << u8"minY:" << minY << "\t" << demimg.height;
+ qDebug() << u8"maxY:" << maxY << "\t" << demimg.height;
+ qDebug() << u8"ͼУ\t" << demimg.height << " , " << demimg.width;
+
+
+ for (long i = 0; i < imgheight; i++) {
+ //printf("\rprocess:%f precent\t\t\t",i*100.0/imgheight);
+ for (long j = 0; j < imgwidth; j++) {
+ double lon = imglonArr(i, j);
+ double lat = imglatArr(i, j);
+ Landpoint point = demimg.getRow_Col(lon, lat);
+
+ if (point.lon<1 || point.lon>demimg.width - 2 || point.lat < 1 || point.lat - 2) {
+ continue;
+ }
+ else {}
+
+ Landpoint p0, p11, p21, p12, p22;
+
+ p0.lon = point.lon;
+ p0.lat = point.lat;
+
+ p11.lon = floor(p0.lon);
+ p11.lat = floor(p0.lat);
+ p11.ati = demArr(long(p11.lat), long(p11.lon));
+
+ p12.lon = ceil(p0.lon);
+ p12.lat = floor(p0.lat);
+ p12.ati = demArr(long(p12.lat), long(p12.lon));
+
+ p21.lon = floor(p0.lon);
+ p21.lat = ceil(p0.lat);
+ p21.ati = demArr(long(p21.lat), long(p21.lon));
+
+ p22.lon = ceil(p0.lon);
+ p22.lat = ceil(p0.lat);
+ p22.ati = demArr(long(p22.lat), long(p22.lon));
+
+ p0.lon = p0.lon - p11.lon;
+ p0.lat = p0.lat - p11.lat;
+
+ p12.lon = p12.lon - p11.lon;
+ p12.lat = p12.lat - p11.lat;
+
+ p21.lon = p21.lon - p11.lon;
+ p21.lat = p21.lat - p11.lat;
+
+ p22.lon = p22.lon - p11.lon;
+ p22.lat = p22.lat - p11.lat;
+
+ p11.lon = p11.lon - p11.lon;
+ p11.lat = p11.lat - p11.lat;
+
+ p0.ati=Bilinear_interpolation(p0, p11, p21, p12, p22);
+ imgatiArr(i, j) = p0.ati;
+
+ }
+ }
+ outimgll.saveImage(imgatiArr, 0, 0, 3);
+ qDebug() << u8"ÿбֵ";
+
+
+ gdalImage antimg(InEchoGPSDataPath);
+ qDebug() << u8"1. زGPSļ\t";
+ qDebug() << u8"ļ·\t" << InEchoGPSDataPath;
+ qDebug() << u8"GPS \t" << antimg.height;
+ qDebug() << u8"ļ\t" << antimg.width;
+
+ long prfcount = antimg.height;
+
+
+ std::shared_ptr Pxs((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr Pys((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr Pzs((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr AntDirectX((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr AntDirectY((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr AntDirectZ((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+
+ {
+ long colnum = 19;
+ std::shared_ptr antpos = readDataArr(antimg, 0, 0, prfcount, colnum, 1, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
+ double time = 0;
+ double Px = 0;
+ double Py = 0;
+ double Pz = 0;
+ for (long i = 0; i < prfcount; i++) {
+
+ Pxs.get()[i] = antpos.get()[i * 19 + 1]; //
+ Pys.get()[i] = antpos.get()[i * 19 + 2];
+ Pzs.get()[i] = antpos.get()[i * 19 + 3];
+ AntDirectX.get()[i] = antpos.get()[i * 19 + 13];// zero doppler
+ AntDirectY.get()[i] = antpos.get()[i * 19 + 14];
+ AntDirectZ.get()[i] = antpos.get()[i * 19 + 15];
+
+ double NormAnt = std::sqrt(AntDirectX.get()[i] * AntDirectX.get()[i] +
+ AntDirectY.get()[i] * AntDirectY.get()[i] +
+ AntDirectZ.get()[i] * AntDirectZ.get()[i]);
+ AntDirectX.get()[i] = AntDirectX.get()[i] / NormAnt;
+ AntDirectY.get()[i] = AntDirectY.get()[i] / NormAnt;
+ AntDirectZ.get()[i] = AntDirectZ.get()[i] / NormAnt;// һ
+ }
+ antpos.reset();
+ }
+
+
+
+#pragma omp parallel for
+ for (long prfid = 0; prfid < prfcount; prfid++) {
+ double Px = Pxs.get()[prfid];
+ double Py = Pys.get()[prfid];
+ double Pz = Pzs.get()[prfid];
+ double R = 0;
+ Landpoint LLA = {};
+ Point3 XYZ = {};
+ for (long j = 0; j < imgwidth; j++) {
+ LLA.lon = imglonArr(prfid, j);
+ LLA.lat = imglatArr(prfid, j);
+ LLA.ati = imgatiArr(prfid, j);
+
+ LLA2XYZ(LLA, XYZ);
+
+ R = sqrt(pow(Px - XYZ.x, 2) +
+ pow(Py - XYZ.y, 2) +
+ pow(Pz - XYZ.z, 2));
+ imgRArr(prfid, j) = R;
+ }
+ }
+
+ outimgll.saveImage(imgRArr, 0, 0, 4);
+
+ qDebug() << u8"ֵ";
+}
+
+
+void InterploateClipAtiByRefDEM(QString ImageLLPath, QString& ImageDEMPath, QString& outImageLLAPath, QString& InEchoGPSDataPath) {
+
+ gdalImage demimg(ImageDEMPath);
+ gdalImage imgll(ImageLLPath);
+
+ // ü
+ long imgheight = imgll.height;
+ long imgwidth = imgll.width;
+
+ long minRow = -1;
+ long maxRow = imgheight;
+ long minCol = -1;
+ long maxCol = imgwidth;
+
+
+ Eigen::MatrixXd imglonArr = imgll.getData(0, 0, imgheight, imgwidth, 1);
+ Eigen::MatrixXd imglatArr = imgll.getData(0, 0, imgheight, imgwidth, 2);
+
+#pragma omp parallel for
+ for (long i = 0; i < imgheight; i++) {
+ for (long j = 0; j < imgwidth; j++) {
+ double lon = imglonArr(i, j);
+ double lat = imglatArr(i, j);
+ Landpoint point = demimg.getRow_Col(lon, lat);
+ imglonArr(i, j) = point.lon;
+ imglatArr(i, j) = point.lat;
+ }
+ }
+
+ // ʼɨ
+
+ bool minRowFlag=true, maxRowFlag= true, minColFlag = true, maxColFlag = true;
+
+ for (long i = 0; i < imgheight; i++) {
+ for (long j = 0; j < imgwidth; j++) {
+ if (imglonArr(i, j) > 0 && minRowFlag) {
+ minRowFlag = false;
+ minRow = i;
+ break;
+ }
+ if (imglonArr(i, j) < imgheight) {
+ maxRow = i;
+ }
+ }
+ }
+
+ for (long j = 0; j < imgwidth; j++) {
+ for (long i = 0; i < imgheight; i++) {
+ if (imglatArr(i, j) > 0 && minColFlag) {
+ minColFlag = false;
+ minCol = j;
+ break;
+ }
+ if (imglatArr(i, j) < imgheight) {
+ maxCol = j;
+ }
+ }
+ }
+
+
+ long RowCount = maxRow - minRow;
+ long ColCount = maxCol - minCol;
+
+ gdalImage outimgll = CreategdalImageDouble(outImageLLAPath, RowCount, ColCount, 4, true, true); // ȡγȡ̡߳б
+
+ imgheight = outimgll.height;
+ imgwidth = outimgll.width;
+
+ imglonArr = imgll.getData(minRow, minCol, RowCount, ColCount, 1);
+ imglatArr = imgll.getData(minRow, minCol, RowCount, ColCount, 2);
+
+ Eigen::MatrixXd demArr = demimg.getData(0, 0, demimg.height, demimg.width, 1);
+
+ Eigen::MatrixXd imgatiArr = Eigen::MatrixXd::Zero(imgheight, imgwidth);
+ Eigen::MatrixXd imgRArr = Eigen::MatrixXd::Zero(imgheight, imgwidth);
+
+ outimgll.saveImage(imglonArr, 0, 0, 1);
+ outimgll.saveImage(imglatArr, 0, 0, 2);
+
+
+ double minX = imglonArr.minCoeff();
+ double maxX = imglonArr.maxCoeff();
+ double minY = imglatArr.minCoeff();
+ double maxY = imglatArr.maxCoeff();
+
+ //ӡΧ
+ qDebug() << u8"dem ķΧ";
+ qDebug() << u8"minX:" << minX << "\t" << demimg.width;
+ qDebug() << u8"maxX:" << maxX << "\t" << demimg.width;
+ qDebug() << u8"minY:" << minY << "\t" << demimg.height;
+ qDebug() << u8"maxY:" << maxY << "\t" << demimg.height;
+ qDebug() << u8"ͼУ\t" << demimg.height << " , " << demimg.width;
+
+
+ for (long i = 0; i < imgheight; i++) {
+ //printf("\rprocess:%f precent\t\t\t",i*100.0/imgheight);
+ for (long j = 0; j < imgwidth; j++) {
+ double lon = imglonArr(i, j);
+ double lat = imglatArr(i, j);
+ Landpoint point = demimg.getRow_Col(lon, lat);
+
+ if (point.lon<1 || point.lon>demimg.width - 2 || point.lat < 1 || point.lat - 2) {
+ continue;
+ }
+ else {}
+
+ Landpoint p0, p11, p21, p12, p22;
+
+ p0.lon = point.lon;
+ p0.lat = point.lat;
+
+ p11.lon = floor(p0.lon);
+ p11.lat = floor(p0.lat);
+ p11.ati = demArr(long(p11.lat), long(p11.lon));
+
+ p12.lon = ceil(p0.lon);
+ p12.lat = floor(p0.lat);
+ p12.ati = demArr(long(p12.lat), long(p12.lon));
+
+ p21.lon = floor(p0.lon);
+ p21.lat = ceil(p0.lat);
+ p21.ati = demArr(long(p21.lat), long(p21.lon));
+
+ p22.lon = ceil(p0.lon);
+ p22.lat = ceil(p0.lat);
+ p22.ati = demArr(long(p22.lat), long(p22.lon));
+
+ p0.lon = p0.lon - p11.lon;
+ p0.lat = p0.lat - p11.lat;
+
+ p12.lon = p12.lon - p11.lon;
+ p12.lat = p12.lat - p11.lat;
+
+ p21.lon = p21.lon - p11.lon;
+ p21.lat = p21.lat - p11.lat;
+
+ p22.lon = p22.lon - p11.lon;
+ p22.lat = p22.lat - p11.lat;
+
+ p11.lon = p11.lon - p11.lon;
+ p11.lat = p11.lat - p11.lat;
+
+ p0.ati = Bilinear_interpolation(p0, p11, p21, p12, p22);
+ imgatiArr(i, j) = p0.ati;
+ }
+ }
+
+ outimgll.saveImage(imgatiArr, 0, 0, 3);
+ qDebug() << u8"ÿбֵ";
+
+
+ gdalImage antimg(InEchoGPSDataPath);
+ qDebug() << u8"1. زGPSļ\t";
+ qDebug() << u8"ļ·\t" << InEchoGPSDataPath;
+ qDebug() << u8"GPS \t" << antimg.height;
+ qDebug() << u8"ļ\t" << antimg.width;
+
+ long prfcount = antimg.height;
+
+
+ std::shared_ptr Pxs((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr Pys((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr Pzs((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr AntDirectX((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr AntDirectY((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+ std::shared_ptr AntDirectZ((double*)mallocCUDAHost(sizeof(double) * prfcount), FreeCUDAHost);
+
+ {
+ long colnum = 19;
+ std::shared_ptr antpos = readDataArr(antimg, 0, 0, prfcount, colnum, 1, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
+ double time = 0;
+ double Px = 0;
+ double Py = 0;
+ double Pz = 0;
+ for (long i = 0; i < prfcount; i++) {
+
+ Pxs.get()[i] = antpos.get()[i * 19 + 1]; //
+ Pys.get()[i] = antpos.get()[i * 19 + 2];
+ Pzs.get()[i] = antpos.get()[i * 19 + 3];
+ AntDirectX.get()[i] = antpos.get()[i * 19 + 13];// zero doppler
+ AntDirectY.get()[i] = antpos.get()[i * 19 + 14];
+ AntDirectZ.get()[i] = antpos.get()[i * 19 + 15];
+
+ double NormAnt = std::sqrt(AntDirectX.get()[i] * AntDirectX.get()[i] +
+ AntDirectY.get()[i] * AntDirectY.get()[i] +
+ AntDirectZ.get()[i] * AntDirectZ.get()[i]);
+ AntDirectX.get()[i] = AntDirectX.get()[i] / NormAnt;
+ AntDirectY.get()[i] = AntDirectY.get()[i] / NormAnt;
+ AntDirectZ.get()[i] = AntDirectZ.get()[i] / NormAnt;// һ
+ }
+ antpos.reset();
+ }
+
+
+
+#pragma omp parallel for
+ for (long prfid = minRow; prfid < maxRow; prfid++) {
+ double Px = Pxs.get()[prfid];
+ double Py = Pys.get()[prfid];
+ double Pz = Pzs.get()[prfid];
+ double R = 0;
+ Landpoint LLA = {};
+ Point3 XYZ = {};
+ for (long j = 0; j < imgwidth; j++) {
+ LLA.lon = imglonArr(prfid-minRow, j);
+ LLA.lat = imglatArr(prfid - minRow, j);
+ LLA.ati = imgatiArr(prfid - minRow, j);
+
+ LLA2XYZ(LLA, XYZ);
+
+ R = sqrt(pow(Px - XYZ.x, 2) +
+ pow(Py - XYZ.y, 2) +
+ pow(Pz - XYZ.z, 2));
+ imgRArr(prfid - minRow, j) = R;
+ }
+ }
+
+ outimgll.saveImage(imgRArr, 0, 0, 4);
+
+ qDebug() << u8"ֵ";
+
+}
+
+
+int ReflectTable_WGS2Range(QString dem_rc_path,QString outOriSimTiffPath,QString ori_sim_count_tiffPath,long OriHeight,long OriWidth)
+{
+ gdalImage sim_rc(dem_rc_path);
+ gdalImage sim_sar_img = CreategdalImage(outOriSimTiffPath, OriHeight, OriWidth, 2, sim_rc.gt, sim_rc.projection, false);// עﱣ
+ for (int max_rows_ids = 0; max_rows_ids < OriHeight; max_rows_ids = max_rows_ids + 1000) {
+ Eigen::MatrixXd sim_sar = sim_sar_img.getData(max_rows_ids, 0, 1000, OriWidth, 1);
+ Eigen::MatrixXd sim_sarc = sim_sar_img.getData(max_rows_ids, 0, 1000, OriWidth, 2);
+ sim_sar = sim_sar.array() * 0 - 9999;
+ sim_sarc = sim_sar.array() * 0 - 9999;
+ sim_sar_img.saveImage(sim_sar, max_rows_ids, 0, 1);
+ sim_sar_img.saveImage(sim_sarc, max_rows_ids, 0, 2);
+ }
+ sim_sar_img.setNoDataValue(-9999, 1);
+ sim_sar_img.setNoDataValue(-9999, 2);
+ int conver_lines = 5000;
+ int line_invert = 4000;// ص
+ int line_offset = 60;
+ //
+ omp_lock_t lock;
+ omp_init_lock(&lock); // ʼ
+ int allCount = 0;
+
+ for (int max_rows_ids = 0; max_rows_ids < sim_rc.height; max_rows_ids = max_rows_ids + line_invert) {
+ Eigen::MatrixXd dem_r = sim_rc.getData(max_rows_ids, 0, conver_lines, sim_rc.width, 1);
+ Eigen::MatrixXd dem_c = sim_rc.getData(max_rows_ids, 0, conver_lines, sim_rc.width, 2);
+ int dem_rows_num = dem_r.rows();
+ int dem_cols_num = dem_r.cols();
+ // ²ֵγ
+ //Eigen::MatrixXd dem_lon = dem_r;
+ //Eigen::MatrixXd dem_lat = dem_c;
+ // ¾γȲ
+
+ int temp_r, temp_c;
+
+ int min_row = dem_r.minCoeff() + 1;
+ int max_row = dem_r.maxCoeff() + 1;
+
+ if (max_row < 0) {
+ continue;
+ }
+
+ int len_rows = max_row - min_row;
+ min_row = min_row < 0 ? 0 : min_row;
+ Eigen::MatrixXd sar_r = sim_sar_img.getData(min_row, 0, len_rows, OriWidth, 1);
+ Eigen::MatrixXd sar_c = sim_sar_img.getData(min_row, 0, len_rows, OriWidth, 2);
+ len_rows = sar_r.rows();
+
+
+#pragma omp parallel for num_threads(8) // NEW ADD
+ for (int i = 0; i < dem_rows_num - 1; i++) {
+ for (int j = 0; j < dem_cols_num - 1; j++) {
+ Point3 p, p1, p2, p3, p4;
+ Landpoint lp1, lp2, lp3, lp4;
+ lp1 = sim_rc.getLandPoint(i + max_rows_ids, j, 0);
+ lp2 = sim_rc.getLandPoint(i + max_rows_ids, j + 1, 0);
+ lp3 = sim_rc.getLandPoint(i + 1 + max_rows_ids, j + 1, 0);
+ lp4 = sim_rc.getLandPoint(i + 1 + max_rows_ids, j, 0);
+
+ p1 = { dem_r(i,j),dem_c(i,j) };
+ p2 = { dem_r(i,j + 1),dem_c(i,j + 1) };
+ p3 = { dem_r(i + 1,j + 1),dem_c(i + 1,j + 1) };
+ p4 = { dem_r(i + 1,j),dem_c(i + 1,j) };
+
+ //if (angle(i, j) >= 90 && angle(i, j + 1) >= 90 && angle(i + 1, j) >= 90 && angle(i + 1, j + 1) >= 90) {
+ // continue;
+ //}
+
+ double temp_min_r = dem_r.block(i, j, 2, 2).minCoeff();
+ double temp_max_r = dem_r.block(i, j, 2, 2).maxCoeff();
+ double temp_min_c = dem_c.block(i, j, 2, 2).minCoeff();
+ double temp_max_c = dem_c.block(i, j, 2, 2).maxCoeff();
+ if ((int(temp_min_r) != int(temp_max_r)) && (int(temp_min_c) != int(temp_max_c))) {
+ for (int ii = int(temp_min_r); ii <= temp_max_r + 1; ii++) {
+ for (int jj = int(temp_min_c); jj < temp_max_c + 1; jj++) {
+ if (ii < min_row || ii - min_row >= len_rows || jj < 0 || jj >= OriWidth) {
+ continue;
+ }
+ p = { double(ii),double(jj),0 };
+ //if (PtInRect(p, p1, p2, p3, p4)) {
+ p1.z = lp1.lon;
+ p2.z = lp2.lon;
+ p3.z = lp3.lon;
+ p4.z = lp4.lon;
+
+ p = invBilinear(p, p1, p2, p3, p4);
+ if (isnan(p.z)) {
+ continue;
+ }
+
+ if (p.x < 0) {
+ continue;
+ }
+ double mean = (p1.z + p2.z + p3.z + p4.z) / 4;
+ if (p.z > p1.z && p.z > p2.z && p.z > p3.z && p.z > p4.z) {
+ p.z = mean;
+ }
+ if (p.z < p1.z && p.z < p2.z && p.z < p3.z && p.z < p4.z) {
+ p.z = mean;
+ }
+ sar_r(ii - min_row, jj) = p.z;
+ p1.z = lp1.lat;
+ p2.z = lp2.lat;
+ p3.z = lp3.lat;
+ p4.z = lp4.lat;
+ p = invBilinear(p, p1, p2, p3, p4);
+ if (isnan(p.z)) {
+ continue;
+ }
+
+ if (p.x < 0) {
+ continue;
+ }
+ mean = (p1.z + p2.z + p3.z + p4.z) / 4;
+ if (p.z > p1.z && p.z > p2.z && p.z > p3.z && p.z > p4.z) {
+ p.z = mean;
+ }
+ if (p.z < p1.z && p.z < p2.z && p.z < p3.z && p.z < p4.z) {
+ p.z = mean;
+ }
+ sar_c(ii - min_row, jj) = p.z;
+ //}
+ }
+ }
+
+ }
+ }
+ }
+
+ omp_set_lock(&lock); //û
+ sim_sar_img.saveImage(sar_r, min_row, 0, 1);
+ sim_sar_img.saveImage(sar_c, min_row, 0, 2);
+ allCount = allCount + conver_lines;
+ qDebug() << "rows:\t" << allCount << "/" << sim_rc.height << "\t computing.....\t" ;
+ omp_unset_lock(&lock); //ͷŻ
+
+
+ }
+
+ return 0;
+}
+
+
+int ResampleEChoDataFromGeoEcho(QString L2echodataPath, QString RangeLooktablePath, QString L1AEchoDataPath) {
+ gdalImageComplex echodata(L2echodataPath);
+ gdalImage looktable(RangeLooktablePath);
+ gdalImageComplex l1adata(L1AEchoDataPath);
+ Eigen::MatrixXcd echoArr = echodata.getDataComplex(0, 0, echodata.height, echodata.width, 1);
+
+ long blockHeight = Memory1GB / looktable.width / 8 * 2;
+
+ for (long startRow = 0; startRow < looktable.height; startRow = startRow + blockHeight) {
+ printf("\rGEC: process:%f precent\t\t\t", startRow * 100.0 / looktable.height);
+ blockHeight = blockHeight + startRow < looktable.height ? blockHeight : looktable.height - startRow;
+ Eigen::MatrixXd imglonArr = looktable.getData(startRow, 0, blockHeight, looktable.width, 1);
+ Eigen::MatrixXd imglatArr = looktable.getData(startRow, 0, blockHeight, looktable.width, 2);
+ Eigen::MatrixXcd l1aArr = l1adata.getDataComplex(0, 0, blockHeight, l1adata.width, 1);
+ l1aArr = l1aArr.array() * 0;
+
+ long imgheight = blockHeight;
+ long imgwidth = looktable.width;
+#pragma omp parallel for
+ for (long i = 0; i < imgheight; i++) {
+
+ for (long j = 0; j < imgwidth; j++) {
+ double lon = imglonArr(i, j);
+ double lat = imglatArr(i, j);
+ Landpoint point = echodata.getRow_Col(lon, lat);
+
+ if (point.lon<1 || point.lon>echodata.width - 2 || point.lat < 1 || point.lat >echodata.height - 2) {
+ continue;
+ }
+ else {}
+ // ʵֵ
+ {
+ Landpoint p0, p11, p21, p12, p22;
+
+ p0.lon = point.lon;
+ p0.lat = point.lat;
+
+ p11.lon = floor(p0.lon);
+ p11.lat = floor(p0.lat);
+ p11.ati = echoArr(long(p11.lat), long(p11.lon)).real();
+
+ p12.lon = ceil(p0.lon);
+ p12.lat = floor(p0.lat);
+ p12.ati = echoArr(long(p12.lat), long(p12.lon)).real();
+
+ p21.lon = floor(p0.lon);
+ p21.lat = ceil(p0.lat);
+ p21.ati = echoArr(long(p21.lat), long(p21.lon)).real();
+
+ p22.lon = ceil(p0.lon);
+ p22.lat = ceil(p0.lat);
+ p22.ati = echoArr(long(p22.lat), long(p22.lon)).real();
+
+ p0.lon = p0.lon - p11.lon;
+ p0.lat = p0.lat - p11.lat;
+
+ p12.lon = p12.lon - p11.lon;
+ p12.lat = p12.lat - p11.lat;
+
+ p21.lon = p21.lon - p11.lon;
+ p21.lat = p21.lat - p11.lat;
+
+ p22.lon = p22.lon - p11.lon;
+ p22.lat = p22.lat - p11.lat;
+
+ p11.lon = p11.lon - p11.lon;
+ p11.lat = p11.lat - p11.lat;
+
+ p0.ati = Bilinear_interpolation(p0, p11, p21, p12, p22);
+ l1aArr(i, j).real(p0.ati);
+ }
+ //鲿ֵ
+ {
+ Landpoint p0, p11, p21, p12, p22;
+
+ p0.lon = point.lon;
+ p0.lat = point.lat;
+
+ p11.lon = floor(p0.lon);
+ p11.lat = floor(p0.lat);
+ p11.ati = echoArr(long(p11.lat), long(p11.lon)).imag();
+
+ p12.lon = ceil(p0.lon);
+ p12.lat = floor(p0.lat);
+ p12.ati = echoArr(long(p12.lat), long(p12.lon)).imag();
+
+ p21.lon = floor(p0.lon);
+ p21.lat = ceil(p0.lat);
+ p21.ati = echoArr(long(p21.lat), long(p21.lon)).imag();
+
+ p22.lon = ceil(p0.lon);
+ p22.lat = ceil(p0.lat);
+ p22.ati = echoArr(long(p22.lat), long(p22.lon)).imag();
+
+ p0.lon = p0.lon - p11.lon;
+ p0.lat = p0.lat - p11.lat;
+
+ p12.lon = p12.lon - p11.lon;
+ p12.lat = p12.lat - p11.lat;
+
+ p21.lon = p21.lon - p11.lon;
+ p21.lat = p21.lat - p11.lat;
+
+ p22.lon = p22.lon - p11.lon;
+ p22.lat = p22.lat - p11.lat;
+
+ p11.lon = p11.lon - p11.lon;
+ p11.lat = p11.lat - p11.lat;
+
+ p0.ati = Bilinear_interpolation(p0, p11, p21, p12, p22);
+ l1aArr(i, j).imag(p0.ati);
+ }
+
+ }
+ }
+
+ l1adata.saveImage(l1aArr, startRow, 0, 1);
+ }
+
+
+
+ return 0;
+
+}
+
+int ResampleRangeDataFromGeoImage(QString geodataPath, QString RangeLooktablePath, QString RangeDataPath)
+{
+ gdalImage echodata(geodataPath);
+ gdalImage looktable(RangeLooktablePath);
+ gdalImage l1adata(RangeDataPath);
+ Eigen::MatrixXd echoArr = echodata.getData(0, 0, echodata.height, echodata.width, 1);
+
+ long blockHeight = Memory1GB / looktable.width / 8 * 2;
+
+ for (long startRow = 0; startRow < looktable.height; startRow = startRow + blockHeight) {
+ printf("\rGEC: process:%f precent\t\t\t", startRow * 100.0 / looktable.height);
+ blockHeight = blockHeight + startRow < looktable.height ? blockHeight : looktable.height - startRow;
+ Eigen::MatrixXd imglonArr = looktable.getData(startRow, 0, blockHeight, looktable.width, 1);
+ Eigen::MatrixXd imglatArr = looktable.getData(startRow, 0, blockHeight, looktable.width, 2);
+ Eigen::MatrixXd l1aArr = l1adata.getData(0, 0, blockHeight, l1adata.width, 1);
+ l1aArr = l1aArr.array() * 0;
+
+ long imgheight = blockHeight;
+ long imgwidth = looktable.width;
+#pragma omp parallel for
+ for (long i = 0; i < imgheight; i++) {
+
+ for (long j = 0; j < imgwidth; j++) {
+ double lon = imglonArr(i, j);
+ double lat = imglatArr(i, j);
+ Landpoint point = echodata.getRow_Col(lon, lat);
+
+ if (point.lon<1 || point.lon>echodata.width - 2 || point.lat < 1 || point.lat >echodata.height - 2) {
+ continue;
+ }
+ else {}
+ {
+ Landpoint p0, p11, p21, p12, p22;
+
+ p0.lon = point.lon;
+ p0.lat = point.lat;
+
+ p11.lon = floor(p0.lon);
+ p11.lat = floor(p0.lat);
+ p11.ati = echoArr(long(p11.lat), long(p11.lon));
+
+ p12.lon = ceil(p0.lon);
+ p12.lat = floor(p0.lat);
+ p12.ati = echoArr(long(p12.lat), long(p12.lon));
+
+ p21.lon = floor(p0.lon);
+ p21.lat = ceil(p0.lat);
+ p21.ati = echoArr(long(p21.lat), long(p21.lon));
+
+ p22.lon = ceil(p0.lon);
+ p22.lat = ceil(p0.lat);
+ p22.ati = echoArr(long(p22.lat), long(p22.lon));
+
+ p0.lon = p0.lon - p11.lon;
+ p0.lat = p0.lat - p11.lat;
+
+ p12.lon = p12.lon - p11.lon;
+ p12.lat = p12.lat - p11.lat;
+
+ p21.lon = p21.lon - p11.lon;
+ p21.lat = p21.lat - p11.lat;
+
+ p22.lon = p22.lon - p11.lon;
+ p22.lat = p22.lat - p11.lat;
+
+ p11.lon = p11.lon - p11.lon;
+ p11.lat = p11.lat - p11.lat;
+
+ p0.ati = Bilinear_interpolation(p0, p11, p21, p12, p22);
+ l1aArr(i, j)=p0.ati;
+ }
+ }
+ }
+
+ l1adata.saveImage(l1aArr, startRow, 0, 1);
+ }
+
+
+
+ return 0;
+}
+
+void InterpLookTableRfromDEM(QString lonlatPath, QString DEMPath, QString outllrpath)
+{
+ gdalImage LLimg(lonlatPath);
+ gdalImage demimg(DEMPath);
+ gdalImage LLRimg = CreategdalImageDouble(outllrpath, LLimg.height, LLimg.width, 3, true, true);
+
+ long llimgheight = LLimg.height;
+ long llimgWidth = LLimg.width;
+
+ Eigen::MatrixXd imglonArr = LLimg.getData(0, 0, llimgheight, llimgWidth, 1);
+ Eigen::MatrixXd imglatArr = LLimg.getData(0, 0, llimgheight, llimgWidth, 2);
+ Eigen::MatrixXd demArr = demimg.getData(0, 0, demimg.height, demimg.width, 1);
+
+ Eigen::MatrixXd outRArr = imglonArr.array() * 0;
+
+ LLRimg.saveImage(imglonArr, 0, 0, 1);
+ LLRimg.saveImage(imglatArr, 0, 0, 2);
+
+
+ for (long i = 0; i < llimgheight; i++) {
+ for (long j = 0; j < llimgWidth; j++) {
+ double lon = imglonArr(i, j);
+ double lat = imglatArr(i, j);
+ Landpoint point = demimg.getRow_Col(lon, lat);
+
+ if (point.lon<1 || point.lon>demimg.width - 2 || point.lat < 1 || point.lat - 2) {
+ continue;
+ }
+ else {}
+
+ Landpoint p0, p11, p21, p12, p22;
+
+ p0.lon = point.lon;
+ p0.lat = point.lat;
+
+ p11.lon = floor(p0.lon);
+ p11.lat = floor(p0.lat);
+ p11.ati = demArr(long(p11.lat), long(p11.lon));
+
+ p12.lon = ceil(p0.lon);
+ p12.lat = floor(p0.lat);
+ p12.ati = demArr(long(p12.lat), long(p12.lon));
+
+ p21.lon = floor(p0.lon);
+ p21.lat = ceil(p0.lat);
+ p21.ati = demArr(long(p21.lat), long(p21.lon));
+
+ p22.lon = ceil(p0.lon);
+ p22.lat = ceil(p0.lat);
+ p22.ati = demArr(long(p22.lat), long(p22.lon));
+
+ p0.lon = p0.lon - p11.lon;
+ p0.lat = p0.lat - p11.lat;
+
+ p12.lon = p12.lon - p11.lon;
+ p12.lat = p12.lat - p11.lat;
+
+ p21.lon = p21.lon - p11.lon;
+ p21.lat = p21.lat - p11.lat;
+
+ p22.lon = p22.lon - p11.lon;
+ p22.lat = p22.lat - p11.lat;
+
+ p11.lon = p11.lon - p11.lon;
+ p11.lat = p11.lat - p11.lat;
+
+ p0.ati = Bilinear_interpolation(p0, p11, p21, p12, p22);
+ outRArr(i, j) = p0.ati;
+
+ }
+ }
+
+ LLRimg.saveImage(outRArr, 0, 0, 3);
+
+ return;
+}
+
+void RangeLooktableLLA_2_RangeLooktableXYZ(QString LLAPath, QString outXYZPath)
+{
+
+ gdalImage LLAimg(LLAPath);
+ gdalImage xyzimg = CreategdalImageDouble(outXYZPath, LLAimg.height, LLAimg.width, 3, true, true);
+
+ long llimgheight = LLAimg.height;
+ long llimgWidth = LLAimg.width;
+
+ Eigen::MatrixXd lonArr = LLAimg.getData(0, 0, llimgheight, llimgWidth, 1);
+ Eigen::MatrixXd latArr = LLAimg.getData(0, 0, llimgheight, llimgWidth, 2);
+ Eigen::MatrixXd atiArr = LLAimg.getData(0, 0, llimgheight, llimgWidth, 3);
+
+ // ʹLLAץΪXYZ
+ Eigen::MatrixXd xArr = lonArr.array() * 0;
+ Eigen::MatrixXd yArr = lonArr.array() * 0;
+ Eigen::MatrixXd zArr = lonArr.array() * 0;
+
+
+
+ for (long i = 0; i < llimgheight; i++) {
+ for (long j = 0; j < llimgWidth; j++) {
+ double lon = lonArr(i, j);
+ double lat = latArr(i, j);
+ double ati = atiArr(i, j);
+ Landpoint p{ lon,lat,ati };
+ Landpoint XYZP=LLA2XYZ(p);
+
+ xArr(i, j) = XYZP.lon;
+ yArr(i, j) = XYZP.lat;
+ zArr(i, j) = XYZP.ati;
+
+
+ }
+ }
+
+ xyzimg.saveImage(xArr, 0, 0, 1);
+ xyzimg.saveImage(yArr, 0, 0, 2);
+ xyzimg.saveImage(zArr, 0, 0, 3);
+
+ return;
+}
+
+
+
+
+
+
+
+
+
diff --git a/Toolbox/SimulationSARTool/SARImage/ImageNetOperator.h b/Toolbox/SimulationSARTool/SARImage/ImageNetOperator.h
new file mode 100644
index 0000000..59f5920
--- /dev/null
+++ b/Toolbox/SimulationSARTool/SARImage/ImageNetOperator.h
@@ -0,0 +1,28 @@
+#pragma once
+#ifndef __ImageNetOperator__H_
+#define __ImageNetOperator__H_
+#include "BaseConstVariable.h"
+#include
+
+
+void InitCreateImageXYZProcess(QString& outImageLLPath, QString& outImageXYZPath, QString& InEchoGPSDataPath, double& NearRange, double& RangeResolution, int64_t& RangeNum);
+
+bool OverlapCheck(QString& ImageLLPath, QString& ImageDEMPath);
+
+bool GPSPointsNumberEqualCheck(QString& ImageLLPath, QString& InEchoGPSDataPath);
+
+void InterploateClipAtiByRefDEM(QString ImageLLPath, QString& ImageDEMPath, QString& outImageLLAPath, QString& InEchoGPSDataPath);
+void InterploateAtiByRefDEM(QString& ImageLLPath, QString& ImageDEMPath, QString& outImageLLAPath, QString& InEchoGPSDataPath);
+int ReflectTable_WGS2Range(QString dem_rc_path, QString outOriSimTiffPath, QString ori_sim_count_tiffPath, long OriHeight, long OriWidth);
+
+int ResampleEChoDataFromGeoEcho(QString L2complexechodataPath, QString RangeLooktablePath, QString L1AEchoDataPath);
+
+int ResampleRangeDataFromGeoImage(QString geodataPath, QString RangeLooktablePath, QString RangeDataPath);
+
+
+void InterpLookTableRfromDEM(QString lonlatPath, QString DEMPath, QString outllrpath);
+
+void RangeLooktableLLA_2_RangeLooktableXYZ(QString LLAPath, QString outXYZPath);
+
+
+#endif
diff --git a/Toolbox/SimulationSARTool/SARImage/ImagePlaneAtiInterpDialog.cpp b/Toolbox/SimulationSARTool/SARImage/ImagePlaneAtiInterpDialog.cpp
new file mode 100644
index 0000000..4c78e3b
--- /dev/null
+++ b/Toolbox/SimulationSARTool/SARImage/ImagePlaneAtiInterpDialog.cpp
@@ -0,0 +1,146 @@
+#include "ImagePlaneAtiInterpDialog.h"
+#include "ui_ImagePlaneAtiInterpDialog.h"
+#include
+#include
+#include
+#include "BaseConstVariable.h"
+#include "ImageNetOperator.h"
+
+ImagePlaneAtiInterpDialog::ImagePlaneAtiInterpDialog(QWidget *parent)
+ : QDialog(parent)
+ , ui(new Ui::ImagePlaneAtiInterpDialogClass)
+{
+ ui->setupUi(this);
+
+ connect(ui->pushButtonImageLLASelect, SIGNAL(clicked()), this, SLOT(onpushButtonImageLLASelect_clicked()));
+ connect(ui->pushButtonImageNet0Select, SIGNAL(clicked()), this, SLOT(onpushButtonImageNet0Select_clicked()));
+ connect(ui->pushButtonRefRangeDEMSelect, SIGNAL(clicked()), this, SLOT(onpushButtonRefRangeDEMSelect_clicked()));
+ connect(ui->pushButtonEchoGPSPointDataSelect, SIGNAL(clicked()), this, SLOT(onpushButtonEchoGPSPointSelect_clicked()));
+ connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(onbuttonBoxAccepted()));
+ connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(onbuttonBoxRejected()));
+
+
+}
+
+ImagePlaneAtiInterpDialog::~ImagePlaneAtiInterpDialog()
+{}
+
+void ImagePlaneAtiInterpDialog::onpushButtonImageNet0Select_clicked()
+{
+ QString fileNames = QFileDialog::getOpenFileName(
+ this,
+ tr(u8"ѡƽļ"),
+ QString(),
+ tr(ENVI_FILE_FORMAT_FILTER)
+ );
+
+ if (!fileNames.isEmpty()) {
+ QString message = "ѡļ\n";
+ this->ui->lineEditImageNet0Path->setText(fileNames);
+ }
+ else {
+ QMessageBox::information(this, tr(u8"ʾ"), tr(u8"ûѡļ"));
+ }
+}
+
+void ImagePlaneAtiInterpDialog::onpushButtonEchoGPSPointSelect_clicked()
+{
+ QString fileNames = QFileDialog::getOpenFileName(
+ this, //
+ tr(u8"ѡزGPSļ"), //
+ QString(), // Ĭ·
+ tr(u8"GPSļ(*.gpspos.data);;All Files(*.*)") // ļ
+ );
+ // ûѡļ
+ if (!fileNames.isEmpty()) {
+ QString message = "ѡļУ\n";
+ this->ui->lineEditGPSPointsPath->setText(fileNames);
+ }
+ else {
+ QMessageBox::information(this, tr(u8"ûѡļ"), tr(u8"ûѡκļ"));
+ }
+}
+
+void ImagePlaneAtiInterpDialog::onpushButtonRefRangeDEMSelect_clicked()
+{
+ QString fileNames = QFileDialog::getOpenFileName(
+ this,
+ tr(u8"ѡοDEM"),
+ QString(),
+ tr(ENVI_FILE_FORMAT_FILTER)
+ );
+ if (!fileNames.isEmpty()) {
+ QString message = "ѡļ\n";
+ this->ui->lineEditRefRangeDEMPath->setText(fileNames);
+ }
+ else {
+ QMessageBox::information(this, tr(u8"ʾ"), tr(u8"ûѡļ"));
+ }
+}
+
+void ImagePlaneAtiInterpDialog::onpushButtonImageLLASelect_clicked()
+{
+ QString fileNames = QFileDialog::getSaveFileName(
+ this,
+ tr(u8"ʾ"),
+ QString(),
+ tr(ENVI_FILE_FORMAT_FILTER)
+ );
+
+ if (!fileNames.isEmpty()) {
+ QString message = "ѡļ\n";
+ this->ui->lineEditImageLLAPath->setText(fileNames);
+ }
+ else {
+ QMessageBox::information(this, tr(u8"ʾ"), tr(u8"ûѡļ"));
+ }
+}
+
+void ImagePlaneAtiInterpDialog::onbuttonBoxAccepted()
+{
+ QString imageNet0Path = this->ui->lineEditImageNet0Path->text().trimmed();
+ QString refRangeDEMPath = this->ui->lineEditRefRangeDEMPath->text().trimmed();
+ QString imageLLAPath = this->ui->lineEditImageLLAPath->text().trimmed();
+ QString echoGPSDataPath = this->ui->lineEditGPSPointsPath->text().trimmed();
+ if (imageNet0Path.isEmpty() || refRangeDEMPath.isEmpty() || imageLLAPath.isEmpty()||echoGPSDataPath.isEmpty()) {
+ QMessageBox::warning(this, tr(u8"ʾ"), tr(u8"ûѡļ"));
+ return;
+ }
+ else {
+
+ }
+
+ if (GPSPointsNumberEqualCheck(imageNet0Path, echoGPSDataPath)) {
+ }
+ else {
+ QMessageBox::warning(nullptr, u8"", u8"زGPSĿһ");
+ return;
+ }
+
+ bool checkflag= this->ui->checkBoxOverLap->isChecked();
+ if (checkflag) {
+ InterploateClipAtiByRefDEM(imageNet0Path, refRangeDEMPath, imageLLAPath, echoGPSDataPath);
+ QMessageBox::information(this, tr(u8"ʾ"), tr(u8""));
+ return;
+ }
+ else {
+ if (OverlapCheck(imageNet0Path, refRangeDEMPath)) { // ????DEM???
+ InterploateAtiByRefDEM(imageNet0Path, refRangeDEMPath, imageLLAPath, echoGPSDataPath);
+
+ QMessageBox::information(nullptr, u8"ʾ", u8"completed!!");
+ return;
+
+ }
+ else {
+ QMessageBox::warning(nullptr, u8"", u8"DEMӰСڳƽҪ");
+ return;
+ }
+ }
+}
+
+void ImagePlaneAtiInterpDialog::onbuttonBoxRejected()
+{
+ this->close();
+}
+
+
\ No newline at end of file
diff --git a/Toolbox/SimulationSARTool/SARImage/ImagePlaneAtiInterpDialog.h b/Toolbox/SimulationSARTool/SARImage/ImagePlaneAtiInterpDialog.h
new file mode 100644
index 0000000..5b37329
--- /dev/null
+++ b/Toolbox/SimulationSARTool/SARImage/ImagePlaneAtiInterpDialog.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#ifndef __ImagePlaneAtiInterpDialog__HH__
+#define __ImagePlaneAtiInterpDialog__HH__
+
+#include