40 lines
1.7 KiB
C++
40 lines
1.7 KiB
C++
#include <gtest/gtest.h>
|
||
#include "core/algo/GprVolumeBuilder.hpp"
|
||
#include "io/gpr/RadarVolumeAssembler.hpp"
|
||
|
||
using geopro::io::gpr::RadarCubeDesc;
|
||
using geopro::io::gpr::assembleRadarVolume;
|
||
|
||
// 2 道 × 3 通道 × 4 采样,值 = 100*c + 10*t + s。不插值(chXOffsets 空)、coarse=1。
|
||
TEST(RadarVolumeAssembler, AxisMapAndQuantRoundTrip) {
|
||
RadarCubeDesc d;
|
||
d.channels = 3; d.traces = 2; d.samples = 4;
|
||
d.dxBase = 0.1; d.dyWhenNotInterpolated = 0.5; d.dz = 0.05;
|
||
auto sampler = [](int c, int t, int s) { return 100.0 * c + 10.0 * t + s; };
|
||
|
||
const geopro::core::BuiltI16 b = assembleRadarVolume(d, sampler, /*coarse=*/1, /*targetDy=*/0.0);
|
||
|
||
EXPECT_EQ(b.vol.nx(), 2); // 道
|
||
EXPECT_EQ(b.vol.ny(), 3); // 通道(未插值=原通道数)
|
||
EXPECT_EQ(b.vol.nz(), 4); // 采样
|
||
EXPECT_DOUBLE_EQ(b.spacing[0], 0.1);
|
||
EXPECT_DOUBLE_EQ(b.spacing[1], 0.5);
|
||
EXPECT_DOUBLE_EQ(b.spacing[2], 0.05);
|
||
EXPECT_NEAR(b.vminPhys, 0.0, 1e-9); // c0,t0,s0
|
||
EXPECT_NEAR(b.vmaxPhys, 213.0, 1e-9); // c2,t1,s3 = 200+10+3
|
||
// 反量化对位:体素(道 t=1, 通道 c=2, 采样 s=3) 应≈213(量化误差内)。
|
||
const double recon = b.quant.toPhys(b.vol.at(1, 2, 3));
|
||
EXPECT_NEAR(recon, 213.0, b.quant.scale);
|
||
}
|
||
|
||
// coarse=2:4 道 → nxOut=2,dx×2。
|
||
TEST(RadarVolumeAssembler, CoarseDownsamplesTracesAndScalesDx) {
|
||
RadarCubeDesc d;
|
||
d.channels = 1; d.traces = 4; d.samples = 2; d.dxBase = 0.1;
|
||
auto sampler = [](int, int t, int s) { return 10.0 * t + s; };
|
||
const geopro::core::BuiltI16 b = assembleRadarVolume(d, sampler, /*coarse=*/2, 0.0);
|
||
EXPECT_EQ(b.vol.nx(), 2);
|
||
EXPECT_DOUBLE_EQ(b.spacing[0], 0.2);
|
||
EXPECT_NEAR(b.quant.toPhys(b.vol.at(1, 0, 0)), 20.0, b.quant.scale); // 输出道1 = 源道2
|
||
}
|