29 lines
1.4 KiB
C++
29 lines
1.4 KiB
C++
#include <gtest/gtest.h>
|
|
#include <cstdint>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include "core/algo/GprVolumeBuilder.hpp"
|
|
#include "io/gpr/NormalizedRadarVolumeBridge.hpp"
|
|
namespace fs = std::filesystem;
|
|
|
|
TEST(NormalizedRadarBridge, BuildsVolumeWithExpectedAxes) {
|
|
// K=4 道, M=2 通道, N=3 采样, 无通道偏移(不插值), coarse=1。
|
|
fs::path dir = fs::temp_directory_path() / "radar_bridge_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<std::int16_t>(t * 10 + c * 100 + s);
|
|
f.write(reinterpret_cast<const char*>(&v), 2); } }
|
|
const auto b = geopro::io::gpr::buildLineVolumeFromNormalized(
|
|
(dir).string(), "L", /*coarse=*/1, /*targetDy=*/0.0); // targetDy=0 不插值
|
|
EXPECT_EQ(b.vol.nx(), 4); // 道
|
|
EXPECT_EQ(b.vol.ny(), 2); // 通道
|
|
EXPECT_EQ(b.vol.nz(), 3); // 采样
|
|
EXPECT_DOUBLE_EQ(b.spacing[0], 0.1); // dx=DISTANCE_INTERVAL
|
|
EXPECT_GT(b.spacing[2], 0.0); // dz 由 timewindow/dielectric 求得 >0
|
|
EXPECT_NEAR(b.quant.toPhys(b.vol.at(3, 1, 2)), 132.0, b.quant.scale); // t3c1s2=30+100+2
|
|
}
|