aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-10-05 14:56:41 +0200
committerEven Rouault <even.rouault@spatialys.com>2020-10-06 23:48:52 +0200
commit2cfdd6f7fc683517a62147feace1b98b3f587abc (patch)
tree695468cff547ebdba0d575e77a65d0ac292c85af
parent4c992038ea01ead56df12f468f29325f7ca9e43d (diff)
downloadPROJ-2cfdd6f7fc683517a62147feace1b98b3f587abc.tar.gz
PROJ-2cfdd6f7fc683517a62147feace1b98b3f587abc.zip
Database: instanciate DynamicGeodeticReferenceFrame (things like ITRFxxx, WGS 84 (Gxxxx), etc.) when possible
-rw-r--r--src/iso19111/factory.cpp16
-rw-r--r--test/unit/test_factory.cpp22
2 files changed, 32 insertions, 6 deletions
diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp
index f98e5cc8..79419d73 100644
--- a/src/iso19111/factory.cpp
+++ b/src/iso19111/factory.cpp
@@ -2011,7 +2011,8 @@ AuthorityFactory::createGeodeticDatum(const std::string &code) const {
auto res =
d->runWithCodeParam("SELECT name, ellipsoid_auth_name, ellipsoid_code, "
"prime_meridian_auth_name, prime_meridian_code, "
- "publication_date, deprecated FROM geodetic_datum "
+ "publication_date, frame_reference_epoch, "
+ "deprecated FROM geodetic_datum "
"WHERE "
"auth_name = ? AND code = ?",
code);
@@ -2027,7 +2028,8 @@ AuthorityFactory::createGeodeticDatum(const std::string &code) const {
const auto &prime_meridian_auth_name = row[3];
const auto &prime_meridian_code = row[4];
const auto &publication_date = row[5];
- const bool deprecated = row[6] == "1";
+ const auto &frame_reference_epoch = row[6];
+ const bool deprecated = row[7] == "1";
auto ellipsoid = d->createFactory(ellipsoid_auth_name)
->createEllipsoid(ellipsoid_code);
auto pm = d->createFactory(prime_meridian_auth_name)
@@ -2039,7 +2041,15 @@ AuthorityFactory::createGeodeticDatum(const std::string &code) const {
props.set("PUBLICATION_DATE", publication_date);
}
auto datum =
- datum::GeodeticReferenceFrame::create(props, ellipsoid, anchor, pm);
+ frame_reference_epoch.empty()
+ ? datum::GeodeticReferenceFrame::create(props, ellipsoid,
+ anchor, pm)
+ : util::nn_static_pointer_cast<datum::GeodeticReferenceFrame>(
+ datum::DynamicGeodeticReferenceFrame::create(
+ props, ellipsoid, anchor, pm,
+ common::Measure(c_locale_stod(frame_reference_epoch),
+ common::UnitOfMeasure::YEAR),
+ util::optional<std::string>()));
d->context()->d->cache(cacheKey, datum);
return datum;
} catch (const std::exception &ex) {
diff --git a/test/unit/test_factory.cpp b/test/unit/test_factory.cpp
index 90990a96..6950c88e 100644
--- a/test/unit/test_factory.cpp
+++ b/test/unit/test_factory.cpp
@@ -246,6 +246,8 @@ TEST(factory, AuthorityFactory_createGeodeticDatum) {
EXPECT_THROW(factory->createGeodeticDatum("-1"),
NoSuchAuthorityCodeException);
auto grf = factory->createGeodeticDatum("6326");
+ EXPECT_TRUE(nn_dynamic_pointer_cast<DynamicGeodeticReferenceFrame>(grf) ==
+ nullptr);
ASSERT_EQ(grf->identifiers().size(), 1U);
EXPECT_EQ(grf->identifiers()[0]->code(), "6326");
EXPECT_EQ(*(grf->identifiers()[0]->codeSpace()), "EPSG");
@@ -266,10 +268,22 @@ TEST(factory, AuthorityFactory_createGeodeticDatum) {
TEST(factory, AuthorityFactory_createGeodeticDatum_with_publication_date) {
auto factory = AuthorityFactory::create(DatabaseContext::create(), "EPSG");
- //'World Geodetic System 1984 (G1762)
- auto grf = factory->createGeodeticDatum("1156");
+ // North American Datum 1983
+ auto grf = factory->createGeodeticDatum("6269");
+ EXPECT_TRUE(nn_dynamic_pointer_cast<DynamicGeodeticReferenceFrame>(grf) ==
+ nullptr);
EXPECT_TRUE(grf->publicationDate().has_value());
- EXPECT_EQ(grf->publicationDate()->toString(), "2005-01-01");
+ EXPECT_EQ(grf->publicationDate()->toString(), "1986-01-01");
+}
+
+// ---------------------------------------------------------------------------
+
+TEST(factory, AuthorityFactory_createDynamicGeodeticDatum) {
+ auto factory = AuthorityFactory::create(DatabaseContext::create(), "EPSG");
+ auto grf = factory->createGeodeticDatum("1165"); // ITRF 2014
+ auto dgrf = nn_dynamic_pointer_cast<DynamicGeodeticReferenceFrame>(grf);
+ ASSERT_TRUE(dgrf != nullptr);
+ EXPECT_EQ(dgrf->frameReferenceEpoch().value(), 2010.0);
}
// ---------------------------------------------------------------------------
@@ -747,6 +761,8 @@ TEST(factory, AuthorityFactory_createCoordinateOperation_helmert_15_CF) {
" VERSION[\"GA-Aus 2010\"],\n"
" SOURCECRS[\n"
" GEODCRS[\"ITRF2008\",\n"
+ " DYNAMIC[\n"
+ " FRAMEEPOCH[2005]],\n"
" DATUM[\"International Terrestrial Reference Frame "
"2008\",\n"
" ELLIPSOID[\"GRS 1980\",6378137,298.257222101,\n"