轨道拟合完成

master
chenzenghui 2025-06-18 23:32:53 +08:00
parent 13985f31aa
commit 73c5bc0cac
6 changed files with 89 additions and 9 deletions

View File

@ -226,7 +226,7 @@
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration> <EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet> <EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
<OpenMPSupport>true</OpenMPSupport> <OpenMPSupport>true</OpenMPSupport>
<LanguageStandard>stdcpp14</LanguageStandard> <LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C> <LanguageStandard_C>stdc11</LanguageStandard_C>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations> <EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<WholeProgramOptimization>false</WholeProgramOptimization> <WholeProgramOptimization>false</WholeProgramOptimization>

View File

@ -252,6 +252,50 @@ Point3 invBilinear(Point3 p, Point3 a, Point3 b, Point3 c, Point3 d)
return p; return p;
} }
Point3 BASECONSTVARIABLEAPI InverseDistanceWeighting(Point3 sreachp, QList<Point3> ps)
{
// 反距离加权插值IDW
// sreachp: 需要插值的点x, yz值将被插值
// 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) double sind(double degree)
{ {
return sin(degree * d2r); return sin(degree * d2r);
@ -577,7 +621,8 @@ long FindValueInStdVectorLast(std::vector<double>& list, double& insertValue)
} }
ErrorCode polynomial_fit(const std::vector<double>& x, const std::vector<double>& y, int degree, std::vector<double>& out_factor, double& out_chisq) { ErrorCode polynomial_fit(
const std::vector<double>& x, const std::vector<double>& y, int degree, std::vector<double>& out_factor, double& out_chisq) {
int xyLength = x.size(); int xyLength = x.size();
double* xdata = new double[xyLength]; double* xdata = new double[xyLength];
double* ydata = new double[xyLength]; double* ydata = new double[xyLength];

View File

@ -65,7 +65,7 @@ std::vector<QString> BASECONSTVARIABLEAPI convertQStringListToStdVector(const
// 解析ISO 8601格式时间字符串到time_point // 解析ISO 8601格式时间字符串到time_point
template<typename Clock = std::chrono::system_clock> template<typename Clock = std::chrono::system_clock>
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::tm tm = {};
std::istringstream ss(timestamp); std::istringstream ss(timestamp);
char sep; char sep;
@ -109,12 +109,17 @@ inline typename Clock::time_point parse_iso8601(const std::string& timestamp) {
std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double>(fractional_seconds))); std::chrono::duration<double>(fractional_seconds)));
return typename Clock::time_point(seconds + nanoseconds); // 计算纳秒部分,并转换为 system_clock::duration
auto nanoseconds = std::chrono::duration<double>(fractional_seconds);
auto adjusted_duration = std::chrono::duration_cast<std::chrono::system_clock::duration>(nanoseconds);
return tp + adjusted_duration;
//return typename Clock::time_point(seconds + nanoseconds);
}; };
// 格式化输出时间(带纳秒精度) // 格式化输出时间(带纳秒精度)
template<typename Clock = std::chrono::system_clock> template<typename Clock = std::chrono::system_clock>
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; using namespace std::chrono;
// 转换为time_t // 转换为time_t
@ -136,6 +141,11 @@ inline std::string format_iso8601_nano(typename Clock::time_point tp) {
return oss.str(); return oss.str();
}; };
double diffSeconds(std::chrono::system_clock::time_point starttime, std::chrono::system_clock::time_point endtime) {
std::chrono::duration<double> diff = endtime - starttime; // 返回 duration 对象
return diff.count();
};
/////////////////////////////// 基本图像类 结束 /////////////////////////////// 基本图像类 结束
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
@ -154,11 +164,15 @@ std::complex<double> BASECONSTVARIABLEAPI Cubic_Convolution_interpolation(dou
std::complex<double> BASECONSTVARIABLEAPI Cubic_kernel_weight(double s); std::complex<double> 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); 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<Point3> ps);
// //
// WGS84 到J2000 坐标系的变换 // WGS84 到J2000 坐标系的变换
@ -251,7 +265,6 @@ inline double calculate_MuhlemanSigma(double eta_deg) {
}; };
template<typename T> template<typename T>
inline void memsetInitArray(std::shared_ptr<T> ptr, long arrcount, T ti) { inline void memsetInitArray(std::shared_ptr<T> ptr, long arrcount, T ti) {
for (long i = 0; i < arrcount; i++) { for (long i = 0; i < arrcount; i++) {

View File

@ -269,7 +269,7 @@ bool BASECONSTVARIABLEAPI unTarfile(QString inTargzPath, QString outGzFolderPath
// tar -zxvf 压缩包路径 文件或目录路径 // tar -zxvf 压缩包路径 文件或目录路径
QProcess process; 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.execute("cmd.exe", QStringList() << "/c" << cmdstr); // "/c" 表示执行后关闭 CMD
process.waitForFinished(); // 等待执行完成 process.waitForFinished(); // 等待执行完成
// 获取输出 // 获取输出
@ -280,6 +280,24 @@ bool BASECONSTVARIABLEAPI unTarfile(QString inTargzPath, QString outGzFolderPath
return true; 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) bool BASECONSTVARIABLEAPI createNewFolerPath(QString inpath, bool isremoveExist)
{ {
QDir outDir(inpath); QDir outDir(inpath);

View File

@ -58,6 +58,9 @@ bool BASECONSTVARIABLEAPI copyAndReplaceFile(const QString& sourceFilePath, co
// 压缩包文件解压 // 压缩包文件解压
bool BASECONSTVARIABLEAPI unTarfile(QString inTargzPath,QString outGzFolderPath); bool BASECONSTVARIABLEAPI unTarfile(QString inTargzPath,QString outGzFolderPath);
bool BASECONSTVARIABLEAPI unZipFile(QString inZipPath, QString outZipFolderPath);
bool BASECONSTVARIABLEAPI createNewFolerPath(QString inpath, bool isremoveExist = false); bool BASECONSTVARIABLEAPI createNewFolerPath(QString inpath, bool isremoveExist = false);
QFileInfoList BASECONSTVARIABLEAPI findFilePath(const QString& dirPath, const QString& pattern, QDirIterator::IteratorFlag flag= QDirIterator::IteratorFlag::Subdirectories); QFileInfoList BASECONSTVARIABLEAPI findFilePath(const QString& dirPath, const QString& pattern, QDirIterator::IteratorFlag flag= QDirIterator::IteratorFlag::Subdirectories);

View File

@ -622,6 +622,7 @@ inline std::shared_ptr<T> readDataArrComplex(gdalImageComplex& imgds, long start
//--------------------- 图像分块 ------------------------------ //--------------------- 图像分块 ------------------------------
//-------------------- 图像滤波 -------------------------------