geopro/src/io/gpr/GpsTrack.hpp

47 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef GEOPRO_IO_GPR_GPSTRACK_HPP
#define GEOPRO_IO_GPR_GPSTRACK_HPP
#include <string>
#include <vector>
namespace geopro::io::gpr {
// 一个 RTK 轨迹点(度,度,米)。
struct GpsPt {
double lat = 0; // 纬度(度)
double lon = 0; // 经度(度)
double elev = 0; // 高程(米)
};
// 一条测线的 RTK 轨迹。
struct GpsTrack {
std::vector<GpsPt> pts;
};
// 解析 .gps 文本。每行 tab/空白分隔:
// 日期 \t 时间 \t 纬 \t N \t 经 \t E \t 高 \t M \t 卫星
// 取 纬(col2)/经(col4)/高(col6)。列数不足或非数字行跳过。文件打不开抛 std::runtime_error。
GpsTrack parseGps(const std::string& path);
// 局部米坐标(等距投影,绕给定原点 lat0/lon0
// x_east = (lon-lon0)*111320*cos(lat0°)
// y_north = (lat-lat0)*111320
struct XY {
double x = 0; // 东向米
double y = 0; // 北向米
};
XY lonLatToLocalM(double lat, double lon, double lat0, double lon0);
// 沿轨迹按里程插值frac∈[0,1] 返回该里程分数处的局部米坐标 + 该处航向(单位向量)。
// frac<=0 → 起点frac>=1 → 终点;空/单点轨迹航向 (1,0)。
struct PosHeading {
XY pos;
double hx = 1; // 航向单位向量 x
double hy = 0; // 航向单位向量 y
};
PosHeading interpAlongTrack(const std::vector<XY>& trackM, double frac);
} // namespace geopro::io::gpr
#endif // GEOPRO_IO_GPR_GPSTRACK_HPP