完成了 图像定标与xml格式文件 功能编写
parent
4208aca10a
commit
13985f31aa
|
@ -124,7 +124,6 @@ enum SIGMATYPE {
|
|||
LINEARVALUE
|
||||
};
|
||||
|
||||
|
||||
/*********************************************** 基础结构体区域 ********************************************************************/
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -43,6 +43,29 @@
|
|||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/date_time/posix_time/conversion.hpp>
|
||||
|
||||
|
||||
|
||||
QString PolarTypeEnumToString(POLARTYPEENUM type)
|
||||
{
|
||||
switch (type) {
|
||||
case POLARHH: return "HH";
|
||||
case POLARHV: return "HV";
|
||||
case POLARVH: return "VH";
|
||||
case POLARVV: return "VV";
|
||||
default: return "UNKOWN";
|
||||
}
|
||||
}
|
||||
|
||||
POLARTYPEENUM StringToPolarTypeEnum(const QString& str)
|
||||
{
|
||||
if (str.compare("HH", Qt::CaseInsensitive) == 0) return POLARHH;
|
||||
if (str.compare("HV", Qt::CaseInsensitive) == 0) return POLARHV;
|
||||
if (str.compare("VH", Qt::CaseInsensitive) == 0) return POLARVH;
|
||||
if (str.compare("VV", Qt::CaseInsensitive) == 0) return POLARVV;
|
||||
return POLARUNKOWN;
|
||||
}
|
||||
|
||||
|
||||
QString longDoubleToQStringScientific(long double value) {
|
||||
std::ostringstream stream;
|
||||
|
||||
|
@ -136,8 +159,6 @@ double Bilinear_interpolation(Landpoint p0, Landpoint p11, Landpoint p21, Land
|
|||
p22.ati * p0.lon * p0.lat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool onSegment(Point3 Pi, Point3 Pj, Point3 Q)
|
||||
{
|
||||
if ((Q.x - Pi.x) * (Pj.y - Pi.y) == (Pj.x - Pi.x) * (Q.y - Pi.y) //叉乘
|
||||
|
@ -260,6 +281,7 @@ QString JoinPath(const QString& path, const QString& filename)
|
|||
|
||||
return dir.filePath(filename);
|
||||
}
|
||||
|
||||
std::vector<QString> convertQStringListToStdVector(const QStringList& qStringList)
|
||||
{
|
||||
std::vector<QString> stdVector;
|
||||
|
|
|
@ -33,6 +33,18 @@
|
|||
#include <sstream>
|
||||
#include <QDatetime>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
///////////////////////////////////// 基础类型转换函数 /////////////////////////////////////////////////////////////
|
||||
QString BASECONSTVARIABLEAPI PolarTypeEnumToString(POLARTYPEENUM type);
|
||||
POLARTYPEENUM BASECONSTVARIABLEAPI StringToPolarTypeEnum(const QString& str);
|
||||
|
||||
|
||||
///////////////////////////////////// 基础数学函数 /////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -47,6 +59,84 @@ QString BASECONSTVARIABLEAPI getCurrentShortTimeString();
|
|||
|
||||
std::vector<QString> BASECONSTVARIABLEAPI splitString(const QString& str, char delimiter);
|
||||
std::vector<QString> BASECONSTVARIABLEAPI convertQStringListToStdVector(const QStringList& qStringList);
|
||||
|
||||
|
||||
|
||||
|
||||
// 解析ISO 8601格式时间字符串到time_point
|
||||
template<typename Clock = std::chrono::system_clock>
|
||||
inline typename Clock::time_point parse_iso8601(const std::string& timestamp) {
|
||||
std::tm tm = {};
|
||||
std::istringstream ss(timestamp);
|
||||
char sep;
|
||||
|
||||
// 解析日期部分
|
||||
ss >> tm.tm_year >> sep; // sep是'-'
|
||||
ss >> tm.tm_mon >> sep; // sep是'-'
|
||||
ss >> tm.tm_mday;
|
||||
|
||||
// 解析时间部分
|
||||
ss >> sep; // 'T'
|
||||
ss >> tm.tm_hour >> sep; // ':'
|
||||
ss >> tm.tm_min >> sep; // ':'
|
||||
ss >> tm.tm_sec;
|
||||
|
||||
// 调整tm结构的值(年份从1900开始,月份0-11)
|
||||
tm.tm_year -= 1900;
|
||||
tm.tm_mon -= 1;
|
||||
|
||||
// 转换为time_t
|
||||
std::time_t tt = std::mktime(&tm);
|
||||
if (tt == -1) {
|
||||
throw std::runtime_error("Invalid time");
|
||||
}
|
||||
|
||||
// 解析毫秒和纳秒部分
|
||||
double fractional_seconds = 0.0;
|
||||
if (ss.peek() == '.') {
|
||||
ss >> sep; // '.'
|
||||
ss >> fractional_seconds;
|
||||
}
|
||||
|
||||
// 转换为time_point
|
||||
auto tp = Clock::from_time_t(tt);
|
||||
|
||||
// 添加纳秒部分
|
||||
auto duration_since_epoch = tp.time_since_epoch();
|
||||
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(duration_since_epoch);
|
||||
auto nanoseconds = std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
duration_since_epoch - seconds +
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::duration<double>(fractional_seconds)));
|
||||
|
||||
return typename Clock::time_point(seconds + nanoseconds);
|
||||
};
|
||||
|
||||
// 格式化输出时间(带纳秒精度)
|
||||
template<typename Clock = std::chrono::system_clock>
|
||||
inline std::string format_iso8601_nano(typename Clock::time_point tp) {
|
||||
using namespace std::chrono;
|
||||
|
||||
// 转换为time_t
|
||||
auto tt = Clock::to_time_t(tp);
|
||||
std::tm tm = *std::gmtime(&tt); // 使用UTC时间
|
||||
|
||||
// 获取毫秒和纳秒部分
|
||||
auto since_epoch = tp.time_since_epoch();
|
||||
auto sec = duration_cast<seconds>(since_epoch);
|
||||
auto ns = duration_cast<nanoseconds>(since_epoch - sec);
|
||||
|
||||
// 格式化为字符串
|
||||
std::ostringstream oss;
|
||||
oss << std::put_time(&tm, "%Y-%m-%dT%H:%M:%S");
|
||||
|
||||
// 添加纳秒部分(9位小数)
|
||||
oss << "." << std::setfill('0') << std::setw(9) << ns.count();
|
||||
|
||||
return oss.str();
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////// 基本图像类 结束
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
Loading…
Reference in New Issue