aboutsummaryrefslogtreecommitdiff
path: root/src/iso19111/io.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-09-30 13:37:40 +0200
committerGitHub <noreply@github.com>2020-09-30 13:37:40 +0200
commit1cd25bb01d7a703b9556abdf57035ee0424faa26 (patch)
tree0b34f0a8f5517708baa0107d8210c77c00dfecc8 /src/iso19111/io.cpp
parent48c3a9a225b197d2462c4c03b18088fcc4f68c62 (diff)
parent016e8e60747a2def2dfd7ffc7f6ad2e6aa8ba009 (diff)
downloadPROJ-1cd25bb01d7a703b9556abdf57035ee0424faa26.tar.gz
PROJ-1cd25bb01d7a703b9556abdf57035ee0424faa26.zip
Merge pull request #2361 from rouault/ortho_ellipsoidal
Implement ellipsoidal formulation of +proj=ortho (fixes #397)
Diffstat (limited to 'src/iso19111/io.cpp')
-rw-r--r--src/iso19111/io.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp
index 6680ab00..16ab22f7 100644
--- a/src/iso19111/io.cpp
+++ b/src/iso19111/io.cpp
@@ -3290,7 +3290,7 @@ ConversionNNPtr WKTParser::Private::buildProjectionFromESRI(
}
// Compare parameters present with the ones expected in the mapping
- const ESRIMethodMapping *esriMapping = esriMappings[0];
+ const ESRIMethodMapping *esriMapping = nullptr;
int bestMatchCount = -1;
for (const auto &mapping : esriMappings) {
int matchCount = 0;
@@ -3298,12 +3298,20 @@ ConversionNNPtr WKTParser::Private::buildProjectionFromESRI(
auto iter = mapParamNameToValue.find(param->esri_name);
if (iter != mapParamNameToValue.end()) {
if (param->wkt2_name == nullptr) {
+ bool ok = true;
try {
if (io::asDouble(param->fixed_value) ==
io::asDouble(iter->second)) {
matchCount++;
+ } else {
+ ok = false;
}
} catch (const std::exception &) {
+ ok = false;
+ }
+ if (!ok) {
+ matchCount = -1;
+ break;
}
} else {
matchCount++;
@@ -3317,6 +3325,10 @@ ConversionNNPtr WKTParser::Private::buildProjectionFromESRI(
bestMatchCount = matchCount;
}
}
+ if (esriMapping == nullptr) {
+ return buildProjectionStandard(baseGeodCRS, projCRSNode, projectionNode,
+ defaultLinearUnit, defaultAngularUnit);
+ }
std::map<std::string, const char *> mapWKT2NameToESRIName;
for (const auto *param = esriMapping->params; param->esri_name; ++param) {
@@ -8898,8 +8910,29 @@ static bool is_in_stringlist(const std::string &str, const char *stringlist) {
CRSNNPtr PROJStringParser::Private::buildProjectedCRS(
int iStep, GeographicCRSNNPtr geogCRS, int iUnitConvert, int iAxisSwap) {
auto &step = steps_[iStep];
- auto mappings = getMappingsFromPROJName(step.name);
+ const auto mappings = getMappingsFromPROJName(step.name);
const MethodMapping *mapping = mappings.empty() ? nullptr : mappings[0];
+
+ if (mappings.size() >= 2) {
+ // To distinguish for example +ortho from +ortho +f=0
+ for (const auto *mappingIter : mappings) {
+ if (mappingIter->proj_name_aux != nullptr &&
+ strchr(mappingIter->proj_name_aux, '=') == nullptr &&
+ hasParamValue(step, mappingIter->proj_name_aux)) {
+ mapping = mappingIter;
+ break;
+ } else if (mappingIter->proj_name_aux != nullptr &&
+ strchr(mappingIter->proj_name_aux, '=') != nullptr) {
+ const auto tokens = split(mappingIter->proj_name_aux, '=');
+ if (tokens.size() == 2 &&
+ getParamValue(step, tokens[0]) == tokens[1]) {
+ mapping = mappingIter;
+ break;
+ }
+ }
+ }
+ }
+
if (mapping) {
mapping = selectSphericalOrEllipsoidal(mapping, geogCRS);
}