From 109f75c74ee9e251b9507aeb5f3add109042bd5f Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 4 Oct 2019 00:22:40 +0200 Subject: proj_normalize_for_visualization(): make it work with CRS objects --- src/iso19111/c_api.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/iso19111/c_api.cpp') diff --git a/src/iso19111/c_api.cpp b/src/iso19111/c_api.cpp index 27a727dc..ac3a5f11 100644 --- a/src/iso19111/c_api.cpp +++ b/src/iso19111/c_api.cpp @@ -7434,14 +7434,19 @@ int proj_cs_get_axis_info(PJ_CONTEXT *ctx, const PJ *cs, int index, /** \brief Returns a PJ* object whose axis order is the one expected for * visualization purposes. * - * The input object must be a coordinate operation, that has been created with - * proj_create_crs_to_crs(). - * If the axis order of its source or target CRS is northing,easting, then an - * axis swap operation will be inserted. + * The input object must be either: + * * * @param ctx PROJ context, or NULL for default context - * @param obj Object of type CoordinateOperation, - * created with proj_create_crs_to_crs() (must not be NULL) + * @param obj Object of type CRS, or CoordinateOperation created with + * proj_create_crs_to_crs() (must not be NULL) * @return a new PJ* object to free with proj_destroy() in case of success, or * nullptr in case of error */ @@ -7499,6 +7504,16 @@ PJ *proj_normalize_for_visualization(PJ_CONTEXT *ctx, const PJ *obj) { } } + auto crs = dynamic_cast(obj->iso_obj.get()); + if (crs) { + try { + return pj_obj_create(ctx, crs->normalizeForVisualization()); + } catch (const std::exception &e) { + proj_log_debug(ctx, __FUNCTION__, e.what()); + return nullptr; + } + } + auto co = dynamic_cast(obj->iso_obj.get()); if (!co) { proj_log_error(ctx, __FUNCTION__, "Object is not a CoordinateOperation " -- cgit v1.2.3