From 748c1a5d2fd2d2d325b2784f85acd74e84d7762e Mon Sep 17 00:00:00 2001 From: DelazJ Date: Fri, 14 Feb 2025 12:15:23 +0100 Subject: [PATCH] Add expression functions to create CRS from string definition and to get CRS authid Fixes #9641 --- .../expressions/expression_help/CRS.rst | 49 +++++++++++++++++++ .../expression_help/GeometryGroup.rst | 6 +-- .../expressions/functions_list.rst | 14 ++++++ 3 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 docs/user_manual/expressions/expression_help/CRS.rst diff --git a/docs/user_manual/expressions/expression_help/CRS.rst b/docs/user_manual/expressions/expression_help/CRS.rst new file mode 100644 index 00000000000..f24c9bf1f16 --- /dev/null +++ b/docs/user_manual/expressions/expression_help/CRS.rst @@ -0,0 +1,49 @@ +:orphan: + +.. DO NOT EDIT THIS FILE DIRECTLY. It is generated automatically by + populate_expressions_list.py in the scripts folder. + Changes should be made in the function help files + in the resources/function_help/json/ folder in the + qgis/QGIS repository. + +.. _expression_function_CRS_crs_from_text: + +crs_from_text +............. + +Creates a coordinate reference system from a string definition. The string can represent an auth:id code, a WKT definition, or a PROJ string definition of the CRS. + +.. list-table:: + :widths: 15 85 + + * - Syntax + - crs_from_text(definition) + * - Arguments + - * **definition** - CRS definition + * - Examples + - * ``crs_from_text('EPSG:3857')`` → crs value 'EPSG:3857 - WGS 84 / Pseudo-Mercator' + * ``crs_from_text('PROJ:+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs')`` → crs value 'EPSG:3857 - WGS 84 / Pseudo-Mercator' + + +.. end_crs_from_text_section + +.. _expression_function_CRS_crs_to_authid: + +crs_to_authid +............. + +Returns the authority:id identifier string for a coordinate reference system. + +.. list-table:: + :widths: 15 85 + + * - Syntax + - crs_to_authid(crs) + * - Arguments + - * **crs** - crs value + * - Examples + - * ``crs_to_authid(crs_from_text('PROJ:+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs'))`` → 'EPSG:3857' + + +.. end_crs_to_authid_section + diff --git a/docs/user_manual/expressions/expression_help/GeometryGroup.rst b/docs/user_manual/expressions/expression_help/GeometryGroup.rst index 1d8261aed9d..a1ec31326b7 100644 --- a/docs/user_manual/expressions/expression_help/GeometryGroup.rst +++ b/docs/user_manual/expressions/expression_help/GeometryGroup.rst @@ -170,7 +170,7 @@ Returns the north-based bearing as the angle in radians measured clockwise on th * - Arguments - * **point_a** - point geometry * **point_b** - point geometry - * **source_crs** - an optional string representing the source CRS of the points. By default the current layer's CRS is used. + * **source_crs** - an optional string or CRS object representing the source CRS of the points. By default the current layer's CRS is used. * **ellipsoid** - an optional string representing the acronym or the authority:ID (eg 'EPSG:7030') of the ellipsoid on which the bearing should be measured. By default the current project's ellipsoid setting is used. * - Examples - * ``degrees( bearing( make_point(16198544, -4534850), make_point(18736872, -1877769), 'EPSG:3857', 'EPSG:7030') )`` → 49.980071 @@ -3198,8 +3198,8 @@ Returns the geometry transformed from a source CRS to a destination CRS. - transform(geometry, source_auth_id, dest_auth_id) * - Arguments - * **geometry** - a geometry - * **source_auth_id** - the source auth CRS ID - * **dest_auth_id** - the destination auth CRS ID + * **source_auth_id** - the source CRS definition or CRS object + * **dest_auth_id** - the destination CRS definition or CRS object * - Examples - * ``geom_to_wkt( transform( make_point(488995.53240249, 7104473.38600835), 'EPSG:2154', 'EPSG:4326' ) )`` → 'POINT(0 51)' diff --git a/docs/user_manual/expressions/functions_list.rst b/docs/user_manual/expressions/functions_list.rst index dd381161f4c..b5a853ea069 100644 --- a/docs/user_manual/expressions/functions_list.rst +++ b/docs/user_manual/expressions/functions_list.rst @@ -176,6 +176,20 @@ Further reading: :ref:`expression_function_Date_and_Time_format_date` .. include:: expression_help/Conversions.rst :start-after: .. end_to_time_section + +CRS Functions +----------------- + +This group contains functions to operate on coordinate reference system objects. + +.. include:: text_include.rst + :start-after: .. functions_group_toc + :end-before: .. end_functions_group_toc + +.. include:: expression_help/CRS.rst + :start-after: :orphan: + + Custom Functions -----------------