diff --git a/src/data/GprVolumeRepository.cpp b/src/data/GprVolumeRepository.cpp index a1b1277..b256969 100644 --- a/src/data/GprVolumeRepository.cpp +++ b/src/data/GprVolumeRepository.cpp @@ -5,6 +5,7 @@ #include "core/model/ScalarVolumeI16.hpp" #include "io/gpr/Gpr3dvVolumeBridge.hpp" +#include "io/gpr/NormalizedRadarVolumeBridge.hpp" namespace geopro::data { @@ -47,4 +48,15 @@ VolumeGrid createGprVolumeGrid(const std::string& lineDir, return builtI16ToVolumeGrid(built); } +VolumeGrid createRadarVolumeGrid(const std::string& lineDir, + const std::string& linePrefix, int coarse, + double targetDy) { + // 走规范化测线链(io::gpr) 读 .head/.data → int16 量化体 → 反量化为 app 的 float 体。 + // 与 createGprVolumeGrid 同适配器(builtI16ToVolumeGrid),仅上游数据源不同。 + const geopro::core::BuiltI16 built = + geopro::io::gpr::buildLineVolumeFromNormalized(lineDir, linePrefix, coarse, + targetDy); + return builtI16ToVolumeGrid(built); +} + } // namespace geopro::data diff --git a/src/data/GprVolumeRepository.hpp b/src/data/GprVolumeRepository.hpp index 59f7ff8..0f576d1 100644 --- a/src/data/GprVolumeRepository.hpp +++ b/src/data/GprVolumeRepository.hpp @@ -33,6 +33,17 @@ VolumeGrid createGprVolumeGrid(const std::string& lineDir, const std::string& linePrefix, int coarse = 4, double targetDy = 0.025); +// 走【规范化测线链】(io::gpr::buildLineVolumeFromNormalized) 建逐线雷达体并适配 +// 成 app 的 VolumeGrid。读 {lineDir}/{linePrefix}.head + .data(轴 X=道/Y=通道/ +// Z=采样)→ BuiltI16(int16+Quant) → builtI16ToVolumeGrid 反量化 → VolumeGrid。 +// 与 createGprVolumeGrid(P1/P2 链)同输出格式,下游 addVolume 无需改动;区别仅是 +// 上游数据源走规范化 .head/.data 而非 .iprh/.iprb。 +// coarse(≥1)沿测线下采样;targetDy(米,>0 启用)线内通道插值(读 .head CH_X_OFFSETS)。 +// 失败(加载失败/解析失败)→ 抛 std::runtime_error(由 io::gpr 链抛出,原样透传)。 +VolumeGrid createRadarVolumeGrid(const std::string& lineDir, + const std::string& linePrefix, int coarse = 4, + double targetDy = 0.025); + } // namespace geopro::data #endif // GEOPRO_DATA_GPRVOLUMEREPOSITORY_HPP diff --git a/tests/data/test_gpr_volume_repository.cpp b/tests/data/test_gpr_volume_repository.cpp index 58b8006..a2e05e7 100644 --- a/tests/data/test_gpr_volume_repository.cpp +++ b/tests/data/test_gpr_volume_repository.cpp @@ -153,4 +153,24 @@ TEST_F(GprVolumeRepositoryChainTest, ThrowsOnMissingLine) { std::runtime_error); } +// 规范化链(.head/.data → buildLineVolumeFromNormalized → 反量化)产 VolumeGrid。 +// 合成同 Task 5 桥接测试:SAMPLES=3/NUMBER_OF_CH=2/LAST_TRACE=8 → X=道(4 段)、 +// Y=通道(2)、Z=采样(3);coarse=1/targetDy=0 关下采样与通道插值,维度直读。 +TEST(GprVolumeRepository, CreateRadarVolumeGridFromNormalized) { + fs::path dir = fs::temp_directory_path() / "radar_repo_test"; + fs::create_directories(dir); + { std::ofstream f(dir / "L.head"); + f << "SAMPLES:3\nNUMBER_OF_CH:2\nLAST_TRACE:8\nBITS:16\nENDIAN_TYPE:1\n" + "DISTANCE_INTERVAL:0.1\nTIMEWINDOW:30\nDIELECTRIC:9\n"; } + { std::ofstream f(dir / "L.data", std::ios::binary); + for (int t = 0; t < 4; ++t) for (int c = 0; c < 2; ++c) for (int s = 0; s < 3; ++s) { + std::int16_t v = static_cast(t * 10 + c * 100 + s); + f.write(reinterpret_cast(&v), 2); } } + const auto grid = geopro::data::createRadarVolumeGrid(dir.string(), "L", 1, 0.0); + EXPECT_EQ(grid.vol.nx(), 4); + EXPECT_EQ(grid.vol.ny(), 2); + EXPECT_EQ(grid.vol.nz(), 3); + EXPECT_GT(grid.vmax, grid.vmin); +} + } // namespace