aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/iso19111/io.cpp14
-rw-r--r--test/unit/test_io.cpp4
2 files changed, 14 insertions, 4 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp
index ccfc4488..323888b4 100644
--- a/src/iso19111/io.cpp
+++ b/src/iso19111/io.cpp
@@ -3469,6 +3469,7 @@ ConversionNNPtr WKTParser::Private::buildProjectionFromESRI(
int bestMatchCount = -1;
for (const auto &mapping : esriMappings) {
int matchCount = 0;
+ int unmatchCount = 0;
for (const auto *param = mapping->params; param->esri_name; ++param) {
auto iter = mapParamNameToValue.find(param->esri_name);
if (iter != mapParamNameToValue.end()) {
@@ -3493,9 +3494,12 @@ ConversionNNPtr WKTParser::Private::buildProjectionFromESRI(
}
} else if (param->is_fixed_value) {
mapParamNameToValue[param->esri_name] = param->fixed_value;
+ } else {
+ unmatchCount++;
}
}
- if (matchCount > bestMatchCount) {
+ if (matchCount > bestMatchCount &&
+ !(maybeEsriStyle_ && unmatchCount >= matchCount)) {
esriMapping = mapping;
bestMatchCount = matchCount;
}
@@ -3630,7 +3634,7 @@ ConversionNNPtr WKTParser::Private::buildProjection(
if (projectionNode->GP()->childrenSize() == 0) {
ThrowNotEnoughChildren(WKTConstants::PROJECTION);
}
- if (esriStyle_) {
+ if (esriStyle_ || maybeEsriStyle_) {
return buildProjectionFromESRI(baseGeodCRS, projCRSNode, projectionNode,
defaultLinearUnit, defaultAngularUnit);
}
@@ -7019,6 +7023,12 @@ BaseObjectNNPtr WKTParser::createFromWKT(const std::string &wkt) {
const auto dialect = guessDialect(wkt);
d->maybeEsriStyle_ = (dialect == WKTGuessedDialect::WKT1_ESRI);
+ if (d->maybeEsriStyle_) {
+ if (wkt.find("PARAMETER[\"X_Scale\",") != std::string::npos) {
+ d->esriStyle_ = true;
+ d->maybeEsriStyle_ = false;
+ }
+ }
const auto build = [this, &wkt]() -> BaseObjectNNPtr {
size_t indexEnd;
diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp
index 0235a0c1..a899482e 100644
--- a/test/unit/test_io.cpp
+++ b/test/unit/test_io.cpp
@@ -5929,8 +5929,8 @@ static const struct {
TEST(wkt_parse, esri_projcs) {
for (const auto &projDef : esriProjDefs) {
- std::string wkt("PROJCS[\"unnamed\",GEOGCS[\"GCS_WGS_1984\","
- "DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\","
+ std::string wkt("PROJCS[\"unnamed\",GEOGCS[\"unnamed\","
+ "DATUM[\"unnamed\",SPHEROID[\"unnamed\","
"6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],"
"UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"");
wkt += projDef.esriProjectionName;