aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/iso19111/io.cpp10
-rw-r--r--test/unit/test_io.cpp32
2 files changed, 41 insertions, 1 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp
index f047ef3e..02bcf3b0 100644
--- a/src/iso19111/io.cpp
+++ b/src/iso19111/io.cpp
@@ -9907,10 +9907,16 @@ PROJStringParser::Private::buildProjectedCRS(int iStep,
if (mappings.size() >= 2) {
// To distinguish for example +ortho from +ortho +f=0
+ bool allMappingsHaveAuxParam = true;
+ bool foundStrictlyMatchingMapping = false;
for (const auto *mappingIter : mappings) {
+ if (mappingIter->proj_name_aux == nullptr) {
+ allMappingsHaveAuxParam = false;
+ }
if (mappingIter->proj_name_aux != nullptr &&
strchr(mappingIter->proj_name_aux, '=') == nullptr &&
hasParamValue(step, mappingIter->proj_name_aux)) {
+ foundStrictlyMatchingMapping = true;
mapping = mappingIter;
break;
} else if (mappingIter->proj_name_aux != nullptr &&
@@ -9918,11 +9924,15 @@ PROJStringParser::Private::buildProjectedCRS(int iStep,
const auto tokens = split(mappingIter->proj_name_aux, '=');
if (tokens.size() == 2 &&
getParamValue(step, tokens[0]) == tokens[1]) {
+ foundStrictlyMatchingMapping = true;
mapping = mappingIter;
break;
}
}
}
+ if (allMappingsHaveAuxParam && !foundStrictlyMatchingMapping) {
+ mapping = nullptr;
+ }
}
if (mapping) {
diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp
index 33f4c731..69cab65c 100644
--- a/test/unit/test_io.cpp
+++ b/test/unit/test_io.cpp
@@ -9963,7 +9963,7 @@ TEST(io, projparse_ortho_spherical_on_sphere) {
// ---------------------------------------------------------------------------
-TEST(io, projparse_peirce_q) {
+TEST(io, projparse_peirce_q_square) {
std::string input("+proj=peirce_q +shape=square +type=crs");
auto obj = PROJStringParser().createFromPROJString(input);
auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj);
@@ -9978,6 +9978,36 @@ TEST(io, projparse_peirce_q) {
// ---------------------------------------------------------------------------
+TEST(io, projparse_peirce_q_diamond) {
+ std::string input("+proj=peirce_q +shape=diamond +type=crs");
+ auto obj = PROJStringParser().createFromPROJString(input);
+ auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj);
+ ASSERT_TRUE(crs != nullptr);
+ EXPECT_EQ(
+ crs->exportToPROJString(
+ PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4)
+ .get()),
+ "+proj=peirce_q +shape=diamond +lat_0=90 +lon_0=0 +k_0=1 +x_0=0 +y_0=0 "
+ "+datum=WGS84 +units=m +no_defs +type=crs");
+}
+
+// ---------------------------------------------------------------------------
+
+TEST(io, projparse_peirce_q_horizontal) {
+ std::string input("+proj=peirce_q +shape=horizontal +datum=WGS84 +units=m "
+ "+no_defs +type=crs");
+ auto obj = PROJStringParser().createFromPROJString(input);
+ auto crs = nn_dynamic_pointer_cast<ProjectedCRS>(obj);
+ ASSERT_TRUE(crs != nullptr);
+ EXPECT_EQ(
+ crs->exportToPROJString(
+ PROJStringFormatter::create(PROJStringFormatter::Convention::PROJ_4)
+ .get()),
+ input);
+}
+
+// ---------------------------------------------------------------------------
+
TEST(io, projparse_peirce_q_invalid_lat_0) {
std::string input("+proj=peirce_q +lat_0=0 +shape=square +type=crs");
auto obj = PROJStringParser().createFromPROJString(input);