diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-10-06 19:26:09 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-10-06 19:26:09 +0200 |
| commit | f28d36cee9ec099ae5fea3873988204a7ebda520 (patch) | |
| tree | 9adde1d0f8936b3439bb2b42e5c075f9d8df6362 /src/iso19111/io.cpp | |
| parent | 3a67ea87fac5b835df7966fa801881eaf7503e78 (diff) | |
| download | PROJ-f28d36cee9ec099ae5fea3873988204a7ebda520.tar.gz PROJ-f28d36cee9ec099ae5fea3873988204a7ebda520.zip | |
CRS::_isEquivalentTo(): be tolerant to different order of PROJ step options (fixes #2886)
Diffstat (limited to 'src/iso19111/io.cpp')
| -rw-r--r-- | src/iso19111/io.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index 1f193559..24201ee1 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -7436,6 +7436,7 @@ struct PROJStringFormatter::Private { bool crsExport_ = false; bool legacyCRSToCRSContext_ = false; bool multiLine_ = false; + bool normalizeOutput_ = false; int indentWidth_ = 2; int indentLevel_ = 0; int maxLineLength_ = 80; @@ -7535,6 +7536,17 @@ const std::string &PROJStringFormatter::toString() const { d->result_.clear(); auto &steps = d->steps_; + + if (d->normalizeOutput_) { + // Sort +key=value options of each step in lexicographic order. + for (auto &step : steps) { + std::sort(step.paramValues.begin(), step.paramValues.end(), + [](const Step::KeyValue &a, const Step::KeyValue &b) { + return a.key < b.key; + }); + } + } + for (auto iter = steps.begin(); iter != steps.end();) { // Remove no-op helmert auto &step = *iter; @@ -8689,6 +8701,19 @@ bool PROJStringFormatter::getLegacyCRSToCRSContext() const { // --------------------------------------------------------------------------- +/** Asks for a "normalized" output during toString(), aimed at comparing two + * strings for equivalence. + * + * This consists for now in sorting the +key=value option in lexicographic + * order. + */ +PROJStringFormatter &PROJStringFormatter::setNormalizeOutput() { + d->normalizeOutput_ = true; + return *this; +} + +// --------------------------------------------------------------------------- + const DatabaseContextPtr &PROJStringFormatter::databaseContext() const { return d->dbContext_; } |
