fix(core): GeoVolumeBuilder 外部文件打开走 localPath,支持中文路径

readHeaderFor() 的 .iprh 路径构造、totalTracesOf() 的 fs::file_size、
buildGeoVolume() 的 .ord ifstream,三处均改走 geopro::io::gpr::localPath,
与 io/gpr 层已修路径保持一致,消除含中文目录时打开失败的同类缺口。
parseGps / readIprbRange 已在各自实现层包裹,无需重包。
This commit is contained in:
gaozheng 2026-07-01 08:22:31 +08:00
parent 995c511240
commit a6ade4939f
1 changed files with 4 additions and 3 deletions

View File

@ -22,6 +22,7 @@
#include "io/gpr/GpsTrack.hpp" #include "io/gpr/GpsTrack.hpp"
#include "io/gpr/IprHeader.hpp" #include "io/gpr/IprHeader.hpp"
#include "io/gpr/IprbReader.hpp" #include "io/gpr/IprbReader.hpp"
#include "io/gpr/LocalPath.hpp"
namespace fs = std::filesystem; namespace fs = std::filesystem;
@ -33,7 +34,7 @@ constexpr double kPi = 3.14159265358979323846;
// 读 .iprh 文本 → 解析头(与 .iprb 同名)。 // 读 .iprh 文本 → 解析头(与 .iprb 同名)。
geopro::io::gpr::IprHeader readHeaderFor(const std::string& iprbPath) { geopro::io::gpr::IprHeader readHeaderFor(const std::string& iprbPath) {
fs::path h = fs::path(iprbPath).replace_extension(".iprh"); fs::path h = geopro::io::gpr::localPath(iprbPath).replace_extension(".iprh");
std::ifstream f(h); std::ifstream f(h);
if (!f) throw std::runtime_error("GeoVolumeBuilder: 打不开 iprh " + h.string()); if (!f) throw std::runtime_error("GeoVolumeBuilder: 打不开 iprh " + h.string());
std::string text((std::istreambuf_iterator<char>(f)), std::string text((std::istreambuf_iterator<char>(f)),
@ -55,7 +56,7 @@ std::int64_t totalTracesOf(const std::vector<std::string>& iprb, int samples) {
const std::int64_t per = static_cast<std::int64_t>(samples) * 2; const std::int64_t per = static_cast<std::int64_t>(samples) * 2;
if (per <= 0) throw std::runtime_error("samples<=0"); if (per <= 0) throw std::runtime_error("samples<=0");
for (const auto& p : iprb) { for (const auto& p : iprb) {
const std::int64_t bytes = static_cast<std::int64_t>(fs::file_size(p)); const std::int64_t bytes = static_cast<std::int64_t>(fs::file_size(geopro::io::gpr::localPath(p)));
minTr = std::min(minTr, bytes / per); minTr = std::min(minTr, bytes / per);
} }
return minTr; return minTr;
@ -137,7 +138,7 @@ GeoBuildResult buildGeoVolume(const std::vector<GeoLineInput>& lines,
for (const auto& p : tracks[i].pts) for (const auto& p : tracks[i].pts)
sc.trackM.push_back(lonLatToLocalM(p.lat, p.lon, minLat, minLon)); sc.trackM.push_back(lonLatToLocalM(p.lat, p.lon, minLat, minLon));
std::ifstream ordF(lines[i].ord); std::ifstream ordF(geopro::io::gpr::localPath(lines[i].ord));
if (!ordF) throw std::runtime_error("buildGeoVolume: 打不开 ord " + lines[i].ord); if (!ordF) throw std::runtime_error("buildGeoVolume: 打不开 ord " + lines[i].ord);
std::string ordText((std::istreambuf_iterator<char>(ordF)), std::string ordText((std::istreambuf_iterator<char>(ordF)),
std::istreambuf_iterator<char>()); std::istreambuf_iterator<char>());