From 73c5bc0cac9cd413bc8049c759a9f60dd7906970 Mon Sep 17 00:00:00 2001
From: chenzenghui <3045316072@qq.com>
Date: Wed, 18 Jun 2025 23:32:53 +0800
Subject: [PATCH] =?UTF-8?q?=E8=BD=A8=E9=81=93=E6=8B=9F=E5=90=88=E5=AE=8C?=
=?UTF-8?q?=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BaseCommonLibrary.vcxproj | 2 +-
BaseTool/BaseTool.cpp | 47 +++++++++++++++++++++++++++++++++++-
BaseTool/BaseTool.h | 25 ++++++++++++++-----
BaseTool/FileOperator.cpp | 20 ++++++++++++++-
BaseTool/FileOperator.h | 3 +++
BaseTool/ImageOperatorBase.h | 1 +
6 files changed, 89 insertions(+), 9 deletions(-)
diff --git a/BaseCommonLibrary.vcxproj b/BaseCommonLibrary.vcxproj
index c3f038f..521d067 100644
--- a/BaseCommonLibrary.vcxproj
+++ b/BaseCommonLibrary.vcxproj
@@ -226,7 +226,7 @@
true
NoExtensions
true
- stdcpp14
+ stdcpp17
stdc11
true
false
diff --git a/BaseTool/BaseTool.cpp b/BaseTool/BaseTool.cpp
index 25bcb81..3ff3472 100644
--- a/BaseTool/BaseTool.cpp
+++ b/BaseTool/BaseTool.cpp
@@ -252,6 +252,50 @@ Point3 invBilinear(Point3 p, Point3 a, Point3 b, Point3 c, Point3 d)
return p;
}
+Point3 BASECONSTVARIABLEAPI InverseDistanceWeighting(Point3 sreachp, QList ps)
+{
+ // 反距离加权插值(IDW)
+ // sreachp: 需要插值的点(x, y),z值将被插值
+ // ps: 已知点集,每个点包含x, y, z
+
+ if (ps.isEmpty()) {
+ sreachp.z = 0;
+ return sreachp;
+ }
+ if (ps.size() == 1) {
+ sreachp.z = ps[0].z;
+ return sreachp;
+ }
+
+ double numerator = 0.0;
+ double denominator = 0.0;
+ double power = 2.0; // 常用幂次为2
+
+ for (const Point3& p : ps) {
+ double dx = sreachp.x - p.x;
+ double dy = sreachp.y - p.y;
+ double dist = std::sqrt(dx * dx + dy * dy);
+
+ // 距离为0,直接返回该点的z值
+ if (dist < 1e-12) {
+ sreachp.z = p.z;
+ return sreachp;
+ }
+
+ double weight = 1.0 / std::pow(dist, power);
+ numerator += weight * p.z;
+ denominator += weight;
+ }
+
+ if (denominator == 0.0) {
+ sreachp.z = 0;
+ }
+ else {
+ sreachp.z = numerator / denominator;
+ }
+ return sreachp;
+ }
+
double sind(double degree)
{
return sin(degree * d2r);
@@ -577,7 +621,8 @@ long FindValueInStdVectorLast(std::vector& list, double& insertValue)
}
-ErrorCode polynomial_fit(const std::vector& x, const std::vector& y, int degree, std::vector& out_factor, double& out_chisq) {
+ErrorCode polynomial_fit(
+ const std::vector& x, const std::vector& y, int degree, std::vector& out_factor, double& out_chisq) {
int xyLength = x.size();
double* xdata = new double[xyLength];
double* ydata = new double[xyLength];
diff --git a/BaseTool/BaseTool.h b/BaseTool/BaseTool.h
index 874dbec..568ec07 100644
--- a/BaseTool/BaseTool.h
+++ b/BaseTool/BaseTool.h
@@ -65,7 +65,7 @@ std::vector BASECONSTVARIABLEAPI convertQStringListToStdVector(const
// 解析ISO 8601格式时间字符串到time_point
template
-inline typename Clock::time_point parse_iso8601(const std::string& timestamp) {
+typename Clock::time_point parse_iso8601(const std::string& timestamp) {
std::tm tm = {};
std::istringstream ss(timestamp);
char sep;
@@ -109,12 +109,17 @@ inline typename Clock::time_point parse_iso8601(const std::string& timestamp) {
std::chrono::duration_cast(
std::chrono::duration(fractional_seconds)));
- return typename Clock::time_point(seconds + nanoseconds);
+ // 计算纳秒部分,并转换为 system_clock::duration
+ auto nanoseconds = std::chrono::duration(fractional_seconds);
+ auto adjusted_duration = std::chrono::duration_cast(nanoseconds);
+
+ return tp + adjusted_duration;
+ //return typename Clock::time_point(seconds + nanoseconds);
};
// 格式化输出时间(带纳秒精度)
template
-inline std::string format_iso8601_nano(typename Clock::time_point tp) {
+std::string format_iso8601_nano(typename Clock::time_point tp) {
using namespace std::chrono;
// 转换为time_t
@@ -136,6 +141,11 @@ inline std::string format_iso8601_nano(typename Clock::time_point tp) {
return oss.str();
};
+double diffSeconds(std::chrono::system_clock::time_point starttime, std::chrono::system_clock::time_point endtime) {
+ std::chrono::duration diff = endtime - starttime; // 返回 duration 对象
+ return diff.count();
+};
+
/////////////////////////////// 基本图像类 结束
/////////////////////////////////////////////////////////////
@@ -154,11 +164,15 @@ std::complex BASECONSTVARIABLEAPI Cubic_Convolution_interpolation(dou
std::complex BASECONSTVARIABLEAPI Cubic_kernel_weight(double s);
-double BASECONSTVARIABLEAPI Bilinear_interpolation(Landpoint p0, Landpoint p11, Landpoint p21, Landpoint p12,Landpoint p22);
+double BASECONSTVARIABLEAPI Bilinear_interpolation(Landpoint p0, Landpoint p11, Landpoint p21, Landpoint p12,Landpoint p22);
bool BASECONSTVARIABLEAPI onSegment(Point3 Pi, Point3 Pj, Point3 Q);
-Point3 BASECONSTVARIABLEAPI invBilinear(Point3 p, Point3 a, Point3 b, Point3 c, Point3 d);
+Point3 BASECONSTVARIABLEAPI invBilinear(Point3 p, Point3 a, Point3 b, Point3 c, Point3 d);
+
+Point3 BASECONSTVARIABLEAPI InverseDistanceWeighting(Point3 sreachp,QList ps);
+
+
//
// WGS84 到J2000 坐标系的变换
@@ -251,7 +265,6 @@ inline double calculate_MuhlemanSigma(double eta_deg) {
};
-
template
inline void memsetInitArray(std::shared_ptr ptr, long arrcount, T ti) {
for (long i = 0; i < arrcount; i++) {
diff --git a/BaseTool/FileOperator.cpp b/BaseTool/FileOperator.cpp
index 7422a86..80f670a 100644
--- a/BaseTool/FileOperator.cpp
+++ b/BaseTool/FileOperator.cpp
@@ -269,7 +269,7 @@ bool BASECONSTVARIABLEAPI unTarfile(QString inTargzPath, QString outGzFolderPath
// tar -zxvf 压缩包路径 文件或目录路径
QProcess process;
// 同步执行(阻塞当前线程)
- QString cmdstr = QString("tar -zxvf %1 -C %2").arg(inTargzPath).arg(outGzFolderPath);
+ QString cmdstr = QString("WinRAR.exe e %1 %2").arg(inTargzPath).arg(outGzFolderPath);
process.execute("cmd.exe", QStringList() << "/c" << cmdstr); // "/c" 表示执行后关闭 CMD
process.waitForFinished(); // 等待执行完成
// 获取输出
@@ -280,6 +280,24 @@ bool BASECONSTVARIABLEAPI unTarfile(QString inTargzPath, QString outGzFolderPath
return true;
}
+bool BASECONSTVARIABLEAPI unZipFile(QString inZipPath, QString outZipFolderPath)
+{
+
+ // tar -zxvf 压缩包路径 文件或目录路径
+ QProcess process;
+ // 同步执行(阻塞当前线程)
+ QString cmdstr = QString("WinRAR.exe e %1 %2").arg(inZipPath).arg(outZipFolderPath);
+ process.execute("cmd.exe", QStringList() << "/c" << cmdstr); // "/c" 表示执行后关闭 CMD
+ process.waitForFinished(); // 等待执行完成
+ // 获取输出
+ QString output = QString::fromLocal8Bit(process.readAllStandardOutput());
+ QString error = QString::fromLocal8Bit(process.readAllStandardError());
+ qDebug() << "Output:" << output;
+ qDebug() << "Error:" << error;
+ return true;
+
+}
+
bool BASECONSTVARIABLEAPI createNewFolerPath(QString inpath, bool isremoveExist)
{
QDir outDir(inpath);
diff --git a/BaseTool/FileOperator.h b/BaseTool/FileOperator.h
index 1f727d6..49096bb 100644
--- a/BaseTool/FileOperator.h
+++ b/BaseTool/FileOperator.h
@@ -58,6 +58,9 @@ bool BASECONSTVARIABLEAPI copyAndReplaceFile(const QString& sourceFilePath, co
// 压缩包文件解压
bool BASECONSTVARIABLEAPI unTarfile(QString inTargzPath,QString outGzFolderPath);
+
+bool BASECONSTVARIABLEAPI unZipFile(QString inZipPath, QString outZipFolderPath);
+
bool BASECONSTVARIABLEAPI createNewFolerPath(QString inpath, bool isremoveExist = false);
QFileInfoList BASECONSTVARIABLEAPI findFilePath(const QString& dirPath, const QString& pattern, QDirIterator::IteratorFlag flag= QDirIterator::IteratorFlag::Subdirectories);
diff --git a/BaseTool/ImageOperatorBase.h b/BaseTool/ImageOperatorBase.h
index 3af8396..091ac2a 100644
--- a/BaseTool/ImageOperatorBase.h
+++ b/BaseTool/ImageOperatorBase.h
@@ -622,6 +622,7 @@ inline std::shared_ptr readDataArrComplex(gdalImageComplex& imgds, long start
//--------------------- 图像分块 ------------------------------
+//-------------------- 图像滤波 -------------------------------