aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-12-25 18:44:45 +0100
committerEven Rouault <even.rouault@spatialys.com>2019-12-27 11:14:16 +0100
commitc4589fbe42e5fea07a03919d3484164f5fb70dd3 (patch)
tree37d526da7460deead544ebcfd0ed37db1945a0fc /test
parent0a1f1fe469029ae31591dc8b51d20f5617496128 (diff)
downloadPROJ-c4589fbe42e5fea07a03919d3484164f5fb70dd3.tar.gz
PROJ-c4589fbe42e5fea07a03919d3484164f5fb70dd3.zip
Network: automatically use CDN resources when local resources not available, and networking enabled
Diffstat (limited to 'test')
-rw-r--r--test/unit/Makefile.am2
-rw-r--r--test/unit/test_factory.cpp58
-rw-r--r--test/unit/test_network.cpp86
-rw-r--r--test/unit/test_operation.cpp18
4 files changed, 127 insertions, 37 deletions
diff --git a/test/unit/Makefile.am b/test/unit/Makefile.am
index 23ff5076..ce11ae4e 100644
--- a/test/unit/Makefile.am
+++ b/test/unit/Makefile.am
@@ -68,6 +68,6 @@ test_network_CXXFLAGS = @CURL_CFLAGS@ @CURL_ENABLED_FLAGS@
test_network_LDADD = ../../src/libproj.la @GTEST_LIBS@ @CURL_LIBS@
test_network-check: test_network
- PROJ_SOURCE_DATA=$(PROJ_LIB) ./test_network
+ PROJ_LIB=$(PROJ_LIB) PROJ_SOURCE_DATA=$(PROJ_LIB) ./test_network
check-local: pj_transform_test-check pj_phi2_test-check proj_errno_string_test-check proj_angular_io_test-check proj_context_test-check test_cpp_api-check gie_self_tests-check test_network-check
diff --git a/test/unit/test_factory.cpp b/test/unit/test_factory.cpp
index 93b2ef34..e342dad9 100644
--- a/test/unit/test_factory.cpp
+++ b/test/unit/test_factory.cpp
@@ -1617,34 +1617,34 @@ class FactoryWithTmpDatabase : public ::testing::Test {
DatabaseContext::create(m_ctxt), "OTHER");
auto res = factoryOTHER->createFromCRSCodesWithIntermediates(
"NS_SOURCE", "SOURCE", "NS_TARGET", "TARGET", false, false,
- false, {});
+ false, false, {});
EXPECT_EQ(res.size(), 1U);
EXPECT_TRUE(res.empty() ||
nn_dynamic_pointer_cast<ConcatenatedOperation>(res[0]));
res = factoryOTHER->createFromCRSCodesWithIntermediates(
"NS_SOURCE", "SOURCE", "NS_TARGET", "TARGET", false, false,
- false, {std::make_pair(std::string("NS_PIVOT"),
- std::string("PIVOT"))});
+ false, false, {std::make_pair(std::string("NS_PIVOT"),
+ std::string("PIVOT"))});
EXPECT_EQ(res.size(), 1U);
EXPECT_TRUE(res.empty() ||
nn_dynamic_pointer_cast<ConcatenatedOperation>(res[0]));
res = factoryOTHER->createFromCRSCodesWithIntermediates(
"NS_SOURCE", "SOURCE", "NS_TARGET", "TARGET", false, false,
- false, {std::make_pair(std::string("NS_PIVOT"),
- std::string("NOT_EXISTING"))});
+ false, false, {std::make_pair(std::string("NS_PIVOT"),
+ std::string("NOT_EXISTING"))});
EXPECT_EQ(res.size(), 0U);
res = factoryOTHER->createFromCRSCodesWithIntermediates(
"NS_SOURCE", "SOURCE", "NS_TARGET", "TARGET", false, false,
- false,
+ false, false,
{std::make_pair(std::string("BAD_NS"), std::string("PIVOT"))});
EXPECT_EQ(res.size(), 0U);
res = factoryOTHER->createFromCRSCodesWithIntermediates(
"NS_TARGET", "TARGET", "NS_SOURCE", "SOURCE", false, false,
- false, {});
+ false, false, {});
EXPECT_EQ(res.size(), 1U);
EXPECT_TRUE(res.empty() ||
nn_dynamic_pointer_cast<ConcatenatedOperation>(res[0]));
@@ -1654,7 +1654,7 @@ class FactoryWithTmpDatabase : public ::testing::Test {
DatabaseContext::create(m_ctxt), std::string());
auto res = factory->createFromCRSCodesWithIntermediates(
"NS_SOURCE", "SOURCE", "NS_TARGET", "TARGET", false, false,
- false, {});
+ false, false, {});
EXPECT_EQ(res.size(), 1U);
EXPECT_TRUE(res.empty() ||
nn_dynamic_pointer_cast<ConcatenatedOperation>(res[0]));
@@ -1833,7 +1833,7 @@ TEST(factory, AuthorityFactory_createFromCoordinateReferenceSystemCodes) {
{
// Test removal of superseded transform
auto list = factory->createFromCoordinateReferenceSystemCodes(
- "EPSG", "4179", "EPSG", "4258", false, false, true);
+ "EPSG", "4179", "EPSG", "4258", false, false, false, true);
ASSERT_EQ(list.size(), 2U);
// Romania has a larger area than Poland (given our approx formula)
EXPECT_EQ(list[0]->getEPSGCode(), 15994); // Romania - 3m
@@ -1851,12 +1851,12 @@ TEST(
{
auto res = factory->createFromCoordinateReferenceSystemCodes(
- "EPSG", "4326", "EPSG", "32631", false, false, false);
+ "EPSG", "4326", "EPSG", "32631", false, false, false, false);
ASSERT_EQ(res.size(), 1U);
}
{
auto res = factory->createFromCoordinateReferenceSystemCodes(
- "EPSG", "4209", "EPSG", "4326", false, false, false);
+ "EPSG", "4209", "EPSG", "4326", false, false, false, false);
EXPECT_TRUE(!res.empty());
for (const auto &conv : res) {
EXPECT_TRUE(conv->sourceCRS()->getEPSGCode() == 4209);
@@ -1889,7 +1889,8 @@ TEST_F(FactoryWithTmpDatabase,
DatabaseContext::create(m_ctxt), std::string());
{
auto res = factoryGeneral->createFromCoordinateReferenceSystemCodes(
- "OTHER", "OTHER_4326", "OTHER", "OTHER_32631", false, false, false);
+ "OTHER", "OTHER_4326", "OTHER", "OTHER_32631", false, false, false,
+ false);
ASSERT_EQ(res.size(), 1U);
}
@@ -1897,7 +1898,8 @@ TEST_F(FactoryWithTmpDatabase,
AuthorityFactory::create(DatabaseContext::create(m_ctxt), "EPSG");
{
auto res = factoryEPSG->createFromCoordinateReferenceSystemCodes(
- "OTHER", "OTHER_4326", "OTHER", "OTHER_32631", false, false, false);
+ "OTHER", "OTHER_4326", "OTHER", "OTHER_32631", false, false, false,
+ false);
ASSERT_EQ(res.size(), 1U);
}
@@ -1919,17 +1921,17 @@ TEST_F(FactoryWithTmpDatabase,
<< last_error();
{
auto res = factoryGeneral->createFromCoordinateReferenceSystemCodes(
- "EPSG", "4326", "OTHER", "OTHER_4326", false, false, false);
+ "EPSG", "4326", "OTHER", "OTHER_4326", false, false, false, false);
ASSERT_EQ(res.size(), 1U);
}
{
auto res = factoryEPSG->createFromCoordinateReferenceSystemCodes(
- "EPSG", "4326", "OTHER", "OTHER_4326", false, false, false);
+ "EPSG", "4326", "OTHER", "OTHER_4326", false, false, false, false);
ASSERT_EQ(res.size(), 0U);
}
{
auto res = factoryOTHER->createFromCoordinateReferenceSystemCodes(
- "EPSG", "4326", "OTHER", "OTHER_4326", false, false, false);
+ "EPSG", "4326", "OTHER", "OTHER_4326", false, false, false, false);
ASSERT_EQ(res.size(), 1U);
}
}
@@ -1982,7 +1984,7 @@ TEST_F(FactoryWithTmpDatabase,
auto factoryOTHER =
AuthorityFactory::create(DatabaseContext::create(m_ctxt), "OTHER");
auto res = factoryOTHER->createFromCoordinateReferenceSystemCodes(
- "EPSG", "4326", "EPSG", "4326", false, false, false);
+ "EPSG", "4326", "EPSG", "4326", false, false, false, false);
ASSERT_EQ(res.size(), 3U);
EXPECT_EQ(*(res[0]->name()->description()), "TRANSFORMATION_1M");
EXPECT_EQ(*(res[1]->name()->description()), "TRANSFORMATION_10M");
@@ -2001,7 +2003,7 @@ TEST_F(
auto factory = AuthorityFactory::create(DatabaseContext::create(m_ctxt),
std::string());
auto res = factory->createFromCRSCodesWithIntermediates(
- "EPSG", "4326", "EPSG", "4326", false, false, false, {});
+ "EPSG", "4326", "EPSG", "4326", false, false, false, false, {});
EXPECT_EQ(res.size(), 0U);
}
@@ -2085,7 +2087,7 @@ TEST_F(FactoryWithTmpDatabase, AuthorityFactory_proj_based_transformation) {
auto factoryOTHER =
AuthorityFactory::create(DatabaseContext::create(m_ctxt), "OTHER");
auto res = factoryOTHER->createFromCoordinateReferenceSystemCodes(
- "EPSG", "4326", "EPSG", "4326", false, false, false);
+ "EPSG", "4326", "EPSG", "4326", false, false, false, false);
ASSERT_EQ(res.size(), 1U);
EXPECT_EQ(res[0]->nameStr(), "My PROJ string based op");
EXPECT_EQ(res[0]->exportToPROJString(PROJStringFormatter::create().get()),
@@ -2146,7 +2148,7 @@ TEST_F(FactoryWithTmpDatabase, AuthorityFactory_wkt_based_transformation) {
auto factoryOTHER =
AuthorityFactory::create(DatabaseContext::create(m_ctxt), "OTHER");
auto res = factoryOTHER->createFromCoordinateReferenceSystemCodes(
- "EPSG", "4326", "EPSG", "4326", false, false, false);
+ "EPSG", "4326", "EPSG", "4326", false, false, false, false);
ASSERT_EQ(res.size(), 1U);
EXPECT_EQ(res[0]->nameStr(), "My WKT string based op");
EXPECT_EQ(res[0]->exportToPROJString(PROJStringFormatter::create().get()),
@@ -2180,9 +2182,10 @@ TEST_F(FactoryWithTmpDatabase,
auto factoryOTHER =
AuthorityFactory::create(DatabaseContext::create(m_ctxt), "OTHER");
- EXPECT_THROW(factoryOTHER->createFromCoordinateReferenceSystemCodes(
- "EPSG", "4326", "EPSG", "4326", false, false, false),
- FactoryException);
+ EXPECT_THROW(
+ factoryOTHER->createFromCoordinateReferenceSystemCodes(
+ "EPSG", "4326", "EPSG", "4326", false, false, false, false),
+ FactoryException);
}
// ---------------------------------------------------------------------------
@@ -2207,9 +2210,10 @@ TEST_F(FactoryWithTmpDatabase,
auto factoryOTHER =
AuthorityFactory::create(DatabaseContext::create(m_ctxt), "OTHER");
- EXPECT_THROW(factoryOTHER->createFromCoordinateReferenceSystemCodes(
- "EPSG", "4326", "EPSG", "4326", false, false, false),
- FactoryException);
+ EXPECT_THROW(
+ factoryOTHER->createFromCoordinateReferenceSystemCodes(
+ "EPSG", "4326", "EPSG", "4326", false, false, false, false),
+ FactoryException);
}
// ---------------------------------------------------------------------------
@@ -2262,7 +2266,7 @@ TEST_F(FactoryWithTmpDatabase, lookForGridInfo) {
bool openLicense = false;
bool gridAvailable = false;
EXPECT_TRUE(DatabaseContext::create(m_ctxt)->lookForGridInfo(
- "PROJ_fake_grid", fullFilename, packageName, url, directDownload,
+ "PROJ_fake_grid", false, fullFilename, packageName, url, directDownload,
openLicense, gridAvailable));
EXPECT_TRUE(fullFilename.empty());
EXPECT_TRUE(packageName.empty());
diff --git a/test/unit/test_network.cpp b/test/unit/test_network.cpp
index ba592da4..c3372ca9 100644
--- a/test/unit/test_network.cpp
+++ b/test/unit/test_network.cpp
@@ -598,4 +598,90 @@ TEST(networking, getfilesize) {
proj_context_destroy(ctx);
}
+// ---------------------------------------------------------------------------
+
+#ifdef CURL_ENABLED
+
+TEST(networking, curl_hgridshift) {
+ auto ctx = proj_context_create();
+ proj_context_set_enable_network(ctx, true);
+
+ // NAD83 to NAD83(HARN) in West-Virginia. Using wvhpgn.tif
+ auto P = proj_create_crs_to_crs(ctx, "EPSG:4269", "EPSG:4152", nullptr);
+ ASSERT_NE(P, nullptr);
+
+ PJ_COORD c;
+ c.xyz.x = 40; // lat
+ c.xyz.y = -80; // lon
+ c.xyz.z = 0;
+ c = proj_trans(P, PJ_FWD, c);
+
+ proj_destroy(P);
+ proj_context_destroy(ctx);
+
+ EXPECT_NEAR(c.xyz.x, 39.99999839, 1e-8);
+ EXPECT_NEAR(c.xyz.y, -79.99999807, 1e-8);
+ EXPECT_NEAR(c.xyz.z, 0, 1e-2);
+}
+
+#endif
+
+// ---------------------------------------------------------------------------
+
+#ifdef CURL_ENABLED
+
+TEST(networking, curl_vgridshift) {
+ auto ctx = proj_context_create();
+ proj_context_set_enable_network(ctx, true);
+
+ // WGS84 to EGM2008 height. Using egm08_25.tif
+ auto P =
+ proj_create_crs_to_crs(ctx, "EPSG:4326", "EPSG:4326+3855", nullptr);
+ ASSERT_NE(P, nullptr);
+
+ PJ_COORD c;
+ c.xyz.x = -30; // lat
+ c.xyz.y = 150; // lon
+ c.xyz.z = 0;
+ c = proj_trans(P, PJ_FWD, c);
+
+ proj_destroy(P);
+ proj_context_destroy(ctx);
+
+ EXPECT_NEAR(c.xyz.x, -30, 1e-8);
+ EXPECT_NEAR(c.xyz.y, 150, 1e-8);
+ EXPECT_NEAR(c.xyz.z, -31.89, 1e-2);
+}
+
+#endif
+
+// ---------------------------------------------------------------------------
+
+#ifdef CURL_ENABLED
+
+TEST(networking, curl_vgridshift_vertcon) {
+ auto ctx = proj_context_create();
+ proj_context_set_enable_network(ctx, true);
+
+ // NGVD29 to NAVD88 height. Using vertcone.tif
+ auto P = proj_create_crs_to_crs(ctx, "EPSG:4269+7968", "EPSG:4269+5703",
+ nullptr);
+ ASSERT_NE(P, nullptr);
+
+ PJ_COORD c;
+ c.xyz.x = 40; // lat
+ c.xyz.y = -80; // lon
+ c.xyz.z = 0;
+ c = proj_trans(P, PJ_FWD, c);
+
+ proj_destroy(P);
+ proj_context_destroy(ctx);
+
+ EXPECT_NEAR(c.xyz.x, 40, 1e-8);
+ EXPECT_NEAR(c.xyz.y, -80, 1e-8);
+ EXPECT_NEAR(c.xyz.z, -0.15, 1e-2);
+}
+
+#endif
+
} // namespace
diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp
index 9cde8822..753878c5 100644
--- a/test/unit/test_operation.cpp
+++ b/test/unit/test_operation.cpp
@@ -4789,7 +4789,7 @@ TEST(operation, geogCRS_to_geogCRS_context_concatenated_operation) {
EXPECT_TRUE(nn_dynamic_pointer_cast<ConcatenatedOperation>(list[0]) !=
nullptr);
- auto grids = list[0]->gridsNeeded(DatabaseContext::create());
+ auto grids = list[0]->gridsNeeded(DatabaseContext::create(), false);
EXPECT_EQ(grids.size(), 1U);
}
@@ -6402,7 +6402,7 @@ TEST(operation, transformation_height_to_PROJ_string) {
EXPECT_EQ(transf->exportToPROJString(PROJStringFormatter::create().get()),
"+proj=vgridshift +grids=egm08_25.gtx +multiplier=1");
- auto grids = transf->gridsNeeded(DatabaseContext::create());
+ auto grids = transf->gridsNeeded(DatabaseContext::create(), false);
ASSERT_EQ(grids.size(), 1U);
auto gridDesc = *(grids.begin());
EXPECT_EQ(gridDesc.shortName, "egm08_25.gtx");
@@ -6702,7 +6702,7 @@ TEST(operation, compoundCRS_with_boundGeogCRS_and_boundVerticalCRS_to_geogCRS) {
"+step +proj=unitconvert +xy_in=rad +xy_out=deg "
"+step +proj=axisswap +order=2,1");
- auto grids = op->gridsNeeded(DatabaseContext::create());
+ auto grids = op->gridsNeeded(DatabaseContext::create(), false);
EXPECT_EQ(grids.size(), 1U);
auto opInverse = CoordinateOperationFactory::create()->createOperation(
@@ -8128,8 +8128,8 @@ TEST(operation, isPROJInstantiable) {
auto transformation = Transformation::createGeocentricTranslations(
PropertyMap(), GeographicCRS::EPSG_4269, GeographicCRS::EPSG_4326,
1.0, 2.0, 3.0, {});
- EXPECT_TRUE(
- transformation->isPROJInstantiable(DatabaseContext::create()));
+ EXPECT_TRUE(transformation->isPROJInstantiable(
+ DatabaseContext::create(), false));
}
// Missing grid
@@ -8137,8 +8137,8 @@ TEST(operation, isPROJInstantiable) {
auto transformation = Transformation::createNTv2(
PropertyMap(), GeographicCRS::EPSG_4807, GeographicCRS::EPSG_4326,
"foo.gsb", std::vector<PositionalAccuracyNNPtr>());
- EXPECT_FALSE(
- transformation->isPROJInstantiable(DatabaseContext::create()));
+ EXPECT_FALSE(transformation->isPROJInstantiable(
+ DatabaseContext::create(), false));
}
// Unsupported method
@@ -8149,8 +8149,8 @@ TEST(operation, isPROJInstantiable) {
PropertyMap(), std::vector<OperationParameterNNPtr>{}),
std::vector<GeneralParameterValueNNPtr>{},
std::vector<PositionalAccuracyNNPtr>{});
- EXPECT_FALSE(
- transformation->isPROJInstantiable(DatabaseContext::create()));
+ EXPECT_FALSE(transformation->isPROJInstantiable(
+ DatabaseContext::create(), false));
}
}