diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-01-17 10:40:12 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-01-17 10:40:12 +0100 |
| commit | 3121d9bc309b439adcc2ab9743a3d2b3a8f48296 (patch) | |
| tree | 9c6bb780646a9f074373e0acb18414b91ffc61a9 /src/iso19111/io.cpp | |
| parent | 6d2af0904652baba69ec81261c914e9b68221dac (diff) | |
| download | PROJ-3121d9bc309b439adcc2ab9743a3d2b3a8f48296.tar.gz PROJ-3121d9bc309b439adcc2ab9743a3d2b3a8f48296.zip | |
import/export PROJ strings from ISO19111 code: require/output +type=crs for CRS objects (refs #1214)
Diffstat (limited to 'src/iso19111/io.cpp')
| -rw-r--r-- | src/iso19111/io.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index 5be02ffe..d403495b 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -3344,6 +3344,9 @@ ConversionNNPtr WKTParser::Private::buildProjectionStandard( ci_equal(stripQuotes(extensionChildren[0]), "PROJ4")) { std::string projString = stripQuotes(extensionChildren[1]); if (starts_with(projString, "+proj=")) { + if (projString.find(" +type=crs") == std::string::npos) { + projString += " +type=crs"; + } try { auto projObj = PROJStringParser().createFromPROJString(projString); @@ -4619,6 +4622,9 @@ std::string IPROJStringExportable::exportToPROJString( } } if (bIsCRS) { + if (!formatter->hasParam("type")) { + formatter->addParam("type", "crs"); + } formatter->setCRSExport(false); } return formatter->toString(); @@ -5303,6 +5309,9 @@ PROJStringSyntaxParser(const std::string &projString, std::vector<Step> &steps, vunits = word.substr(strlen("vunits=")); } else if (starts_with(word, "vto_meter=")) { vto_meter = word.substr(strlen("vto_meter=")); + } else if (word == "type=crs" && + (!vunits.empty() || !vto_meter.empty())) { + // ok } else if (starts_with(word, "title=")) { title = word.substr(strlen("title=")); prevWasTitle = true; @@ -6902,7 +6911,7 @@ CRSNNPtr PROJStringParser::Private::buildProjectedCRS( param.key == "towgs84" || param.key == "nadgrids" || param.key == "geoidgrids" || param.key == "units" || param.key == "to_meter" || param.key == "vunits" || - param.key == "vto_meter") { + param.key == "vto_meter" || param.key == "type") { continue; } if (param.value.empty()) { @@ -7252,6 +7261,10 @@ static const metadata::ExtentPtr &getExtent(const crs::CRS *crs) { // --------------------------------------------------------------------------- /** \brief Instantiate a sub-class of BaseObject from a PROJ string. + * + * The projString must contain +type=crs for the object to be detected as a + * CRS instead of a CoordinateOperation. + * * @throw ParsingException */ BaseObjectNNPtr @@ -7300,7 +7313,8 @@ PROJStringParser::createFromPROJString(const std::string &projString) { // +init=xxxx:yyyy syntax if (d->steps_.size() == 1 && d->steps_[0].isInit && - d->steps_[0].paramValues.size() == 0) { + (d->steps_[0].paramValues.size() == 0 || + d->getParamValue(d->steps_[0], "type") == "crs")) { // Those used to come from a text init file // We only support them in compatibility mode @@ -7483,6 +7497,11 @@ PROJStringParser::createFromPROJString(const std::string &projString) { } } + if (d->steps_.size() == 1 && iHelmert < 0 && iMolodensky < 0 && + d->getParamValue(d->steps_[0], "type") != "crs") { + unexpectedStructure = true; + } + if (!unexpectedStructure) { if (iFirstGeogStep == 0 && iSecondGeogStep < 0 && iProjStep < 0 && iHelmert < 0 && iFirstCart < 0 && iMolodensky < 0 && |
