From ad80dc88a70032e1d96812b574b2d4d22e223394 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 11 Oct 2020 19:50:09 +0200 Subject: Database: add a frame_reference_epoch column in vertical_datum to be able to handle dynamic vertical datums, and instanciate them properly from database --- src/iso19111/factory.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp index 5f12273d..473aa254 100644 --- a/src/iso19111/factory.cpp +++ b/src/iso19111/factory.cpp @@ -2081,7 +2081,8 @@ AuthorityFactory::createGeodeticDatum(const std::string &code) const { datum::VerticalReferenceFrameNNPtr AuthorityFactory::createVerticalDatum(const std::string &code) const { auto res = - d->runWithCodeParam("SELECT name, deprecated FROM " + d->runWithCodeParam("SELECT name, publication_date, " + "frame_reference_epoch, deprecated FROM " "vertical_datum WHERE auth_name = ? AND code = ?", code); if (res.empty()) { @@ -2091,11 +2092,23 @@ AuthorityFactory::createVerticalDatum(const std::string &code) const { try { const auto &row = res.front(); const auto &name = row[0]; - const bool deprecated = row[1] == "1"; + const auto &publication_date = row[1]; + const auto &frame_reference_epoch = row[2]; + const bool deprecated = row[3] == "1"; auto props = d->createPropertiesSearchUsages("vertical_datum", code, name, deprecated); + if (!publication_date.empty()) { + props.set("PUBLICATION_DATE", publication_date); + } auto anchor = util::optional(); - return datum::VerticalReferenceFrame::create(props, anchor); + return frame_reference_epoch.empty() + ? datum::VerticalReferenceFrame::create(props, anchor) + : datum::DynamicVerticalReferenceFrame::create( + props, anchor, + util::optional(), + common::Measure(c_locale_stod(frame_reference_epoch), + common::UnitOfMeasure::YEAR), + util::optional()); } catch (const std::exception &ex) { throw buildFactoryException("vertical reference frame", code, ex); } -- cgit v1.2.3