#include "io/gpr/NormalizedRadarVolumeBridge.hpp" #include #include #include #include #include #include #include "io/gpr/LocalPath.hpp" #include "io/gpr/NormalizedRadarReader.hpp" #include "io/gpr/RadarVolumeAssembler.hpp" namespace geopro::io::gpr { geopro::core::BuiltI16 buildLineVolumeFromNormalized(const std::string& lineDir, const std::string& linePrefix, int coarse, double targetDy) { const std::string head = lineDir + "/" + linePrefix + ".head"; const std::string data = lineDir + "/" + linePrefix + ".data"; std::string headText; { std::ifstream f(localPath(head)); if (!f) throw std::runtime_error("打开 .head 失败: " + head); std::stringstream ss; ss << f.rdbuf(); headText = ss.str(); } const RadarHeader h = parseRadarHead(headText); const std::vector cube = readRadarDataCube(data, h); const int M = h.channels; const int N = h.samples; RadarCubeDesc d; d.channels = M; d.traces = h.traces; d.samples = N; d.chXOffsets = h.chXOffsets; d.dxBase = h.distanceInterval > 1e-9 ? h.distanceInterval : 1.0; d.dyWhenNotInterpolated = (h.chXOffsets.size() >= 2 && M > 1) ? (h.chXOffsets.back() - h.chXOffsets.front()) / (M - 1) : 1.0; d.dz = depthSpacingZ(h) > 1e-12 ? depthSpacingZ(h) : 1.0; // position-major 立方体索引 ((t*M + c)*N + s),与 readRadarDataCube 一致。 CubeSampler sample = [&cube, M, N](int c, int t, int s) { return static_cast(cube[(static_cast(t) * M + c) * N + s]); }; return assembleRadarVolume(d, sample, coarse, targetDy); } } // namespace geopro::io::gpr