Skip to content

Commit

Permalink
Convert to use a local VRT file
Browse files Browse the repository at this point in the history
* Add a VRT test file
* Add a zipped VRT test file
* Don't rely on internet for tests to pass

Signed-off-by: Ryan Friedman <[email protected]>
  • Loading branch information
Ryanf55 committed Apr 28, 2024
1 parent 9026234 commit c001ba1
Show file tree
Hide file tree
Showing 3 changed files with 192,001 additions and 6 deletions.
24 changes: 18 additions & 6 deletions geospatial/src/Dem_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,21 +283,33 @@ TEST_F(DemTest, LunarDemLoad)
EXPECT_NEAR(dem.WorldHeight(), 80.0417, 1e-2);
}

TEST_F(DemTest, LargeVRTWithZipAndCurl)
TEST_F(DemTest, LargeVRTWithLimits)
{
// Load a large VRT DEM from another server (used by ArduPilot).
// Load a large VRT DEM using GDAL but set limits on the size.
common::Dem dem;
dem.SetXSizeLimit(100);
dem.SetYSizeLimit(50);
//! @todo Make a really large VRT locally
auto const res = dem.Load("/vsizip/vsicurl/https://terrain.ardupilot.org/SRTM1/ap_srtm1.zip/ap_srtm1.vrt");
auto const path = common::testing::TestFile("data", "ap_srtm1.vrt");
auto const res = dem.Load(path);
EXPECT_EQ(res, 0);
}

TEST_F(DemTest, LargeVRTWithVSIZIPAndLimits)
{
// Load a large vzizip VRT DEM using GDAL but set limits on the size.
common::Dem dem;
dem.SetXSizeLimit(100);
dem.SetYSizeLimit(50);
auto const path = common::testing::TestFile("data", "ap_srtm1.zip");
auto const res = dem.Load("/vsizip/" + path + "/ap_srtm1.vrt");
EXPECT_EQ(res, 0);
}

TEST_F(DemTest, LargeVRTWithoutLimitsThrows)
{
// Load a large VRT DEM from another server (used by ArduPilot).
// Load a large VRT DEM without limits.
common::Dem dem;
auto const path = common::testing::TestFile("data", "ap_srtm1.vrt");
// We expect not to be able to allocate the data, so ensure we throw instead of segfault.
EXPECT_THROW(dem.Load("/vsizip/vsicurl/https://terrain.ardupilot.org/SRTM1/ap_srtm1.zip/ap_srtm1.vrt"), std::bad_alloc);
EXPECT_THROW(dem.Load(path), std::bad_alloc);
}
Loading

0 comments on commit c001ba1

Please sign in to comment.