diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp index f734913673..7c565bb385 100644 --- a/src/apps/cs2cs.cpp +++ b/src/apps/cs2cs.cpp @@ -352,7 +352,8 @@ static bool is3DCRS(const PJ* crs) { return true; if( type == PJ_TYPE_GEOGRAPHIC_3D_CRS ) return true; - if( type == PJ_TYPE_GEODETIC_CRS || type == PJ_TYPE_PROJECTED_CRS ) + if( type == PJ_TYPE_GEODETIC_CRS || type == PJ_TYPE_PROJECTED_CRS || + type == PJ_TYPE_DERIVED_PROJECTED_CRS) { auto cs = proj_crs_get_coordinate_system(nullptr, crs); assert(cs); diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index 8df0db51bb..117474d09b 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -1052,6 +1052,10 @@ convertPJObjectTypeToObjectType(PJ_TYPE type, bool &valid) { cppType = AuthorityFactory::ObjectType::PROJECTED_CRS; break; + case PJ_TYPE_DERIVED_PROJECTED_CRS: + valid = false; + break; + case PJ_TYPE_COMPOUND_CRS: cppType = AuthorityFactory::ObjectType::COMPOUND_CRS; break; @@ -1201,25 +1205,19 @@ PJ_TYPE proj_get_type(const PJ *obj) { return PJ_TYPE_PARAMETRIC_DATUM; } - { - auto crs = dynamic_cast(ptr); - if (crs) { - if (crs->coordinateSystem()->axisList().size() == 2) { - return PJ_TYPE_GEOGRAPHIC_2D_CRS; - } else { - return PJ_TYPE_GEOGRAPHIC_3D_CRS; - } + if (auto crs = dynamic_cast(ptr)) { + if (crs->coordinateSystem()->axisList().size() == 2) { + return PJ_TYPE_GEOGRAPHIC_2D_CRS; + } else { + return PJ_TYPE_GEOGRAPHIC_3D_CRS; } } - { - auto crs = dynamic_cast(ptr); - if (crs) { - if (crs->isGeocentric()) { - return PJ_TYPE_GEOCENTRIC_CRS; - } else { - return PJ_TYPE_GEODETIC_CRS; - } + if (auto crs = dynamic_cast(ptr)) { + if (crs->isGeocentric()) { + return PJ_TYPE_GEOCENTRIC_CRS; + } else { + return PJ_TYPE_GEODETIC_CRS; } } @@ -1229,6 +1227,9 @@ PJ_TYPE proj_get_type(const PJ *obj) { if (dynamic_cast(ptr)) { return PJ_TYPE_PROJECTED_CRS; } + if (dynamic_cast(ptr)) { + return PJ_TYPE_DERIVED_PROJECTED_CRS; + } if (dynamic_cast(ptr)) { return PJ_TYPE_COMPOUND_CRS; } diff --git a/src/proj.h b/src/proj.h index 60465a7807..25828f9e9c 100644 --- a/src/proj.h +++ b/src/proj.h @@ -803,6 +803,8 @@ typedef enum PJ_TYPE_TEMPORAL_DATUM, PJ_TYPE_ENGINEERING_DATUM, PJ_TYPE_PARAMETRIC_DATUM, + + PJ_TYPE_DERIVED_PROJECTED_CRS, } PJ_TYPE; /** Comparison criterion. */ diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index 5362505b07..c401486b74 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -105,6 +105,20 @@ class CApi : public ::testing::Test { CartesianCS::createEastingNorthing(UnitOfMeasure::METRE)); } + static DerivedProjectedCRSNNPtr createDerivedProjectedCRS() { + auto derivingConversion = Conversion::create( + PropertyMap().set(IdentifiedObject::NAME_KEY, "unnamed"), + PropertyMap().set(IdentifiedObject::NAME_KEY, "PROJ unimplemented"), + std::vector{}, + std::vector{}); + + return DerivedProjectedCRS::create( + PropertyMap().set(IdentifiedObject::NAME_KEY, + "derived projectedCRS"), + createProjectedCRS(), derivingConversion, + CartesianCS::createEastingNorthing(UnitOfMeasure::METRE)); + } + static VerticalCRSNNPtr createVerticalCRS() { PropertyMap propertiesVDatum; propertiesVDatum.set(Identifier::CODESPACE_KEY, "EPSG") @@ -820,6 +834,19 @@ TEST_F(CApi, proj_get_type) { ASSERT_NE(obj, nullptr); EXPECT_EQ(proj_get_type(obj), PJ_TYPE_PROJECTED_CRS); } + { + auto obj = proj_create_from_wkt( + m_ctxt, + createDerivedProjectedCRS() + ->exportToWKT( + WKTFormatter::create(WKTFormatter::Convention::WKT2_2019) + .get()) + .c_str(), + nullptr, nullptr, nullptr); + ObjectKeeper keeper(obj); + ASSERT_NE(obj, nullptr); + EXPECT_EQ(proj_get_type(obj), PJ_TYPE_DERIVED_PROJECTED_CRS); + } { auto obj = proj_create_from_wkt(m_ctxt,