@@ -3097,10 +3097,21 @@ WKTParser::Private::buildCS(const WKTNodeNNPtr &node, /* maybe null */
30973097 }
30983098 } else if (ci_equal(csType, CartesianCS::WKT2_TYPE)) {
30993099 if (axisCount == 2) {
3100- return CartesianCS::create(csMap, axisList[0], axisList[1]);
3100+ if (axisList[0]->unit() != axisList[1]->unit()) {
3101+ emitRecoverableWarning(
3102+ "All axis of a CartesianCS must have the same unit");
3103+ }
3104+ return CartesianCS::create(csMap, axisList[0], axisList[1],
3105+ /* enforceSameUnit = */ false);
31013106 } else if (axisCount == 3) {
3107+ if (axisList[0]->unit() != axisList[1]->unit() ||
3108+ axisList[0]->unit() != axisList[2]->unit()) {
3109+ emitRecoverableWarning(
3110+ "All axis of a CartesianCS must have the same unit");
3111+ }
31023112 return CartesianCS::create(csMap, axisList[0], axisList[1],
3103- axisList[2]);
3113+ axisList[2],
3114+ /* enforceSameUnit = */ false);
31043115 }
31053116 } else if (ci_equal(csType, AffineCS::WKT2_TYPE)) {
31063117 if (axisCount == 2) {
@@ -5943,6 +5954,7 @@ BaseObjectNNPtr WKTParser::Private::build(const WKTNodeNNPtr &node) {
59435954class JSONParser {
59445955 DatabaseContextPtr dbContext_{};
59455956 std::string deformationModelName_{};
5957+ PJ_CONTEXT *ctx_ = nullptr;
59465958
59475959 static std::string getString(const json &j, const char *key);
59485960 static json getObject(const json &j, const char *key);
@@ -6053,6 +6065,16 @@ class JSONParser {
60536065 NN_NO_CHECK(csCast));
60546066 }
60556067
6068+ void emitRecoverableWarning(const std::string &warningMsg) {
6069+ if (ctx_) {
6070+ proj_context_log_debug(ctx_, "PROJJSON parsing: %s",
6071+ warningMsg.c_str());
6072+ }
6073+ }
6074+
6075+ JSONParser(const JSONParser &) = delete;
6076+ JSONParser &operator=(const JSONParser &) = delete;
6077+
60566078 public:
60576079 JSONParser() = default;
60586080
@@ -6061,6 +6083,11 @@ class JSONParser {
60616083 return *this;
60626084 }
60636085
6086+ JSONParser &attachContext(PJ_CONTEXT *ctx) {
6087+ ctx_ = ctx;
6088+ return *this;
6089+ }
6090+
60646091 BaseObjectNNPtr create(const json &j);
60656092};
60666093
@@ -7113,11 +7140,22 @@ CoordinateSystemNNPtr JSONParser::buildCS(const json &j) {
71137140 }
71147141 if (subtype == CartesianCS::WKT2_TYPE) {
71157142 if (axisCount == 2) {
7116- return CartesianCS::create(csMap, axisList[0], axisList[1]);
7143+ if (axisList[0]->unit() != axisList[1]->unit()) {
7144+ emitRecoverableWarning(
7145+ "All axis of a CartesianCS must have the same unit");
7146+ }
7147+ return CartesianCS::create(csMap, axisList[0], axisList[1],
7148+ /* enforceSameUnit = */ false);
71177149 }
71187150 if (axisCount == 3) {
7151+ if (axisList[0]->unit() != axisList[1]->unit() ||
7152+ axisList[0]->unit() != axisList[2]->unit()) {
7153+ emitRecoverableWarning(
7154+ "All axis of a CartesianCS must have the same unit");
7155+ }
71197156 return CartesianCS::create(csMap, axisList[0], axisList[1],
7120- axisList[2]);
7157+ axisList[2],
7158+ /* enforceSameUnit = */ false);
71217159 }
71227160 throw ParsingException("Expected 2 or 3 axis");
71237161 }
@@ -7721,7 +7759,10 @@ static BaseObjectNNPtr createFromUserInput(const std::string &text,
77217759 } catch (const std::exception &e) {
77227760 throw ParsingException(e.what());
77237761 }
7724- return JSONParser().attachDatabaseContext(dbContext).create(j);
7762+ return JSONParser()
7763+ .attachContext(ctx)
7764+ .attachDatabaseContext(dbContext)
7765+ .create(j);
77257766 }
77267767
77277768 if (!ci_starts_with(text, "step proj=") &&
@@ -12330,9 +12371,11 @@ PROJStringParser::Private::buildProjectedCRS(int iStep,
1233012371
1233112372 auto csGeodCRS = geodCRS->coordinateSystem();
1233212373 auto cs = csGeodCRS->axisList().size() == 2
12333- ? CartesianCS::create(emptyPropertyMap, axis[0], axis[1])
12374+ ? CartesianCS::create(emptyPropertyMap, axis[0], axis[1],
12375+ /* enforceSameUnit = */ false)
1233412376 : CartesianCS::create(emptyPropertyMap, axis[0], axis[1],
12335- csGeodCRS->axisList()[2]);
12377+ csGeodCRS->axisList()[2],
12378+ /* enforceSameUnit = */ false);
1233612379 if (isTopocentricStep(step.name)) {
1233712380 cs = CartesianCS::create(
1233812381 emptyPropertyMap,
0 commit comments