diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-09-14 22:03:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-14 22:03:48 +0200 |
| commit | 47fb85bdf0e45bf5660e0b1dbde7b76f8824a87a (patch) | |
| tree | 29373bee072524c43091b0b0597d9bd1a74d3006 /src/iso19111/metadata.cpp | |
| parent | 92ca1a9455cdd136aaaeb1dbb0d8d867020e70c6 (diff) | |
| parent | bca0a82921594c675ed1212f54e032f19004ee82 (diff) | |
| download | PROJ-47fb85bdf0e45bf5660e0b1dbde7b76f8824a87a.tar.gz PROJ-47fb85bdf0e45bf5660e0b1dbde7b76f8824a87a.zip | |
Merge pull request #2850 from rouault/projjson_0_4
PROJJSON: support additional properties allowed in id object (version, authority_citation, uri) for parity with WKT2:2019
Diffstat (limited to 'src/iso19111/metadata.cpp')
| -rw-r--r-- | src/iso19111/metadata.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/iso19111/metadata.cpp b/src/iso19111/metadata.cpp index e8ce37c6..fc1b103f 100644 --- a/src/iso19111/metadata.cpp +++ b/src/iso19111/metadata.cpp @@ -41,6 +41,7 @@ #include "proj_json_streaming_writer.hpp" #include <algorithm> +#include <limits> #include <memory> #include <string> #include <vector> @@ -1114,6 +1115,31 @@ void Identifier::_exportToJSON(JSONFormatter *formatter) const { } catch (const std::exception &) { writer->Add(l_code); } + + if (version().has_value()) { + const auto l_version = *(version()); + writer->AddObjKey("version"); + try { + const double dblVersion = c_locale_stod(l_version); + if (dblVersion >= std::numeric_limits<int>::min() && + dblVersion <= std::numeric_limits<int>::max() && + static_cast<int>(dblVersion) == dblVersion) { + writer->Add(static_cast<int>(dblVersion)); + } else { + writer->Add(dblVersion); + } + } catch (const std::exception &) { + writer->Add(l_version); + } + } + if (authority().has_value() && *(authority()->title()) != l_codeSpace) { + writer->AddObjKey("authority_citation"); + writer->Add(*(authority()->title())); + } + if (uri().has_value()) { + writer->AddObjKey("uri"); + writer->Add(*(uri())); + } } } |
