aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-10-04 00:22:40 +0200
committerEven Rouault <even.rouault@spatialys.com>2019-10-04 00:22:40 +0200
commit109f75c74ee9e251b9507aeb5f3add109042bd5f (patch)
tree2671c74c859558efce190c22fa078884abcba6b1 /src
parentc45855b38f701a66a96cbd3fe4534f6a52c393b1 (diff)
downloadPROJ-109f75c74ee9e251b9507aeb5f3add109042bd5f.tar.gz
PROJ-109f75c74ee9e251b9507aeb5f3add109042bd5f.zip
proj_normalize_for_visualization(): make it work with CRS objects
Diffstat (limited to 'src')
-rw-r--r--src/iso19111/c_api.cpp27
1 files changed, 21 insertions, 6 deletions
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:
+ * <ul>
+ * <li>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.</li>
+ * <li>or a CRS. The axis order of geographic CRS will be longitude, latitude
+ * [,height], and the one of projected CRS will be easting, northing
+ * [, height]</li>
+ * </ul>
*
* @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<const CRS *>(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<const CoordinateOperation *>(obj->iso_obj.get());
if (!co) {
proj_log_error(ctx, __FUNCTION__, "Object is not a CoordinateOperation "