#include #include #include "algo/IdwInterpolator.hpp" using namespace geopro::core; TEST(Idw, ReproducesSampleAtNode) { PointSet pts; pts.x = {0.0, 10.0}; pts.y = {0.0, 0.0}; pts.z = {0.0, 0.0}; pts.v = {100.0, 200.0}; GridSpec spec{ /*nx*/3, /*ny*/1, /*nz*/1, /*ox*/0, /*oy*/0, /*oz*/0, /*dx*/5, /*dy*/1, /*dz*/1, /*power*/2.0, /*maxDist*/1e9 }; IdwInterpolator idw; ScalarVolume vol = idw.interpolate(pts, spec); EXPECT_NEAR(vol.at(0, 0, 0), 100.0, 1e-6); // x=0 命中点1 EXPECT_NEAR(vol.at(2, 0, 0), 200.0, 1e-6); // x=10 命中点2 EXPECT_GT(vol.at(1, 0, 0), 100.0); EXPECT_LT(vol.at(1, 0, 0), 200.0); } TEST(Idw, BlanksOutsideMaxDist) { PointSet pts; pts.x = {0.0}; pts.y = {0.0}; pts.z = {0.0}; pts.v = {50.0}; GridSpec spec{2,1,1, 0,0,0, 100,1,1, 2.0, /*maxDist*/1.0}; IdwInterpolator idw; ScalarVolume vol = idw.interpolate(pts, spec); EXPECT_NEAR(vol.at(0,0,0), 50.0, 1e-6); // 命中 EXPECT_TRUE(std::isnan(vol.at(1,0,0))); // 超距 -> NaN(blank) }