aboutsummaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorJavier Jimenez Shaw <j1@jimenezshaw.com>2021-04-24 10:37:19 +0200
committerGitHub <noreply@github.com>2021-04-24 10:37:19 +0200
commit93dc8422c4cddf5fa52824222143effa6bb4d67f (patch)
tree53f8aba4764a68887e50e6d59fa2ec7162b93144 /test/unit
parenta002a3e9da175228494faca7219bce4e7e9effe6 (diff)
downloadPROJ-93dc8422c4cddf5fa52824222143effa6bb4d67f.tar.gz
PROJ-93dc8422c4cddf5fa52824222143effa6bb4d67f.zip
Add proj_get_geoid_models_from_database() (#2681)
to list all geoid model names that apply to a vertical CRS
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/test_c_api.cpp20
-rw-r--r--test/unit/test_factory.cpp56
2 files changed, 76 insertions, 0 deletions
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp
index 8fa1b228..dfc92139 100644
--- a/test/unit/test_c_api.cpp
+++ b/test/unit/test_c_api.cpp
@@ -5619,5 +5619,25 @@ TEST_F(CApi, proj_get_insert_statements) {
proj_insert_object_session_destroy(m_ctxt, session);
}
}
+// ---------------------------------------------------------------------------
+
+TEST_F(CApi, proj_get_geoid_models_from_database) {
+ auto findInList = [](PROJ_STRING_LIST list, const std::string &ref) {
+ while (list && *list) {
+ if (std::string(*list) == ref) {
+ return true;
+ }
+ list++;
+ }
+ return false;
+ };
+
+ auto list =
+ proj_get_geoid_models_from_database(m_ctxt, "EPSG", "5703", nullptr);
+ ListFreer freer(list);
+ EXPECT_TRUE(findInList(list, "GEOID12B"));
+ EXPECT_TRUE(findInList(list, "GEOID18"));
+ EXPECT_FALSE(findInList(list, "OSGM15"));
+}
} // namespace
diff --git a/test/unit/test_factory.cpp b/test/unit/test_factory.cpp
index c10c4697..37013775 100644
--- a/test/unit/test_factory.cpp
+++ b/test/unit/test_factory.cpp
@@ -2139,6 +2139,62 @@ TEST(
}
}
+TEST(factory, AuthorityFactory_getAvailableGeoidmodels) {
+
+ const std::string OSGM15{"OSGM15"};
+ const std::string GEOID12B{"GEOID12B"};
+ const std::string GEOID18{"GEOID18"};
+
+ auto checkNavd88 = [&](const std::list<std::string> &res) {
+ EXPECT_TRUE(res.end() != std::find(res.begin(), res.end(), GEOID12B));
+ EXPECT_TRUE(res.end() != std::find(res.begin(), res.end(), GEOID18));
+ EXPECT_FALSE(res.end() != std::find(res.begin(), res.end(), OSGM15));
+ };
+
+ auto checkOdn = [&](const std::list<std::string> &res) {
+ EXPECT_FALSE(res.end() != std::find(res.begin(), res.end(), GEOID12B));
+ EXPECT_FALSE(res.end() != std::find(res.begin(), res.end(), GEOID18));
+ EXPECT_TRUE(res.end() != std::find(res.begin(), res.end(), OSGM15));
+ };
+
+ auto factory = AuthorityFactory::create(DatabaseContext::create(), "EPSG");
+
+ {
+ auto res = factory->getGeoidModels("4326");
+ ASSERT_TRUE(res.empty());
+ }
+
+ {
+ auto res = factory->getGeoidModels("5703"); // "NAVD88 height"
+ checkNavd88(res);
+ }
+ {
+ auto res = factory->getGeoidModels("6360"); // "NAVD88 height (ftUS)"
+ checkNavd88(res);
+ }
+ {
+ auto res = factory->getGeoidModels("8228"); // "NAVD88 height (ft)"
+ checkNavd88(res);
+ }
+ {
+ auto res = factory->getGeoidModels("6357"); // "NAVD88 depth"
+ checkNavd88(res);
+ }
+ {
+ auto res = factory->getGeoidModels("6358"); // "NAVD88 depth (ftUS)"
+ checkNavd88(res);
+ }
+
+ {
+ auto res = factory->getGeoidModels("5701"); // "ODN height"
+ checkOdn(res);
+ }
+ {
+ auto res = factory->getGeoidModels("5732"); // "Belfast height"
+ checkOdn(res);
+ }
+}
+
// ---------------------------------------------------------------------------
TEST_F(FactoryWithTmpDatabase,