From 7e11edaa2d1abc09478f3bd3fb9926cb0ef3fdda Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 22 Jan 2019 15:51:33 +0100 Subject: Coordinate operation computation with CRS with extension string: replace datum by ellps --- src/iso19111/io.cpp | 56 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'src/iso19111/io.cpp') diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index b3cd83d6..a82f24c7 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -5280,34 +5280,36 @@ PROJStringSyntaxParser(const std::string &projString, std::vector &steps, const char *c_str = projString.c_str(); std::vector tokens; - size_t i = 0; - while (true) { - for (; isspace(c_str[i]); i++) { - } - std::string token; - bool in_string = false; - for (; c_str[i]; i++) { - if (in_string) { - if (c_str[i] == '"' && c_str[i + 1] == '"') { + { + size_t i = 0; + while (true) { + for (; isspace(c_str[i]); i++) { + } + std::string token; + bool in_string = false; + for (; c_str[i]; i++) { + if (in_string) { + if (c_str[i] == '"' && c_str[i + 1] == '"') { + i++; + } else if (c_str[i] == '"') { + in_string = false; + continue; + } + } else if (c_str[i] == '=' && c_str[i + 1] == '"') { + in_string = true; + token += c_str[i]; i++; - } else if (c_str[i] == '"') { - in_string = false; continue; + } else if (isspace(c_str[i])) { + break; } - } else if (c_str[i] == '=' && c_str[i + 1] == '"') { - in_string = true; token += c_str[i]; - i++; - continue; - } else if (isspace(c_str[i])) { + } + if (token.empty()) { break; } - token += c_str[i]; + tokens.emplace_back(token); } - if (token.empty()) { - break; - } - tokens.emplace_back(token); } bool prevWasTitle = false; @@ -5356,10 +5358,20 @@ PROJStringSyntaxParser(const std::string &projString, std::vector &steps, auto key = word.substr(0, pos); if (!(dropEarlyBindingsTerms && (key == "towgs84" || key == "nadgrids" || - key == "geoidgrids" || key == "wktext"))) { + key == "geoidgrids"))) { auto pair = (pos != std::string::npos) ? Step::KeyValue(key, word.substr(pos + 1)) : Step::KeyValue(key); + if (dropEarlyBindingsTerms && key == "datum") { + const auto datums = pj_get_datums_ref(); + for (int i = 0; datums[i].id != nullptr; i++) { + if (pair.value == datums[i].id) { + pair.key = "ellps"; + pair.value = datums[i].ellipse_id; + break; + } + } + } if (steps.empty()) { globalParamValues.push_back(pair); } else { -- cgit v1.2.3