From 85694aab733c7efd0a72563f727f50e41468ddce Mon Sep 17 00:00:00 2001 From: Dengda98 Date: Thu, 15 May 2025 16:34:12 +0800 Subject: [PATCH 1/4] FIX: check whether -C and -E use different unit --- src/grdtrack.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/grdtrack.c b/src/grdtrack.c index 1a9fb7e2816..11a7b47fef7 100644 --- a/src/grdtrack.c +++ b/src/grdtrack.c @@ -816,6 +816,14 @@ EXTERN_MSC int GMT_grdtrack (void *V_API, int mode, void *args) { if (gmt_init_distaz (GMT, Ctrl->E.unit, Ctrl->E.mode, GMT_MAP_DIST) == GMT_NOT_A_VALID_TYPE) /* Initialize the distance unit and scaling */ Return (GMT_NOT_A_VALID_TYPE); + /* Check whether -C and -E use different unit */ + if (Ctrl->C.active && Ctrl->C.unit != Ctrl->E.unit){ + GMT_Report (API, GMT_MSG_ERROR, + "Option -C and -E shoule take the same unit, but received %c (-C) and %c (-E). " + "Recommend you explicitly set the same unit for -C and -E.\n", Ctrl->C.unit, Ctrl->E.unit); + Return (GMT_RUNTIME_ERROR); + } + /* Set default spacing to half the min grid spacing: */ Ctrl->E.step = 0.5 * MIN (GC[0].G->header->inc[GMT_X], GC[0].G->header->inc[GMT_Y]); if (gmt_M_is_geographic (GMT, GMT_IN)) { /* Convert to km if geographic or degrees if arc-units */ From be065cb9d52ba128e731377c6131f2f102c4aef1 Mon Sep 17 00:00:00 2001 From: Dengda98 Date: Fri, 16 May 2025 21:40:20 +0800 Subject: [PATCH 2/4] DOC: update annotation of checking -C and -E units --- src/grdtrack.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/grdtrack.c b/src/grdtrack.c index 11a7b47fef7..acb82767691 100644 --- a/src/grdtrack.c +++ b/src/grdtrack.c @@ -815,7 +815,9 @@ EXTERN_MSC int GMT_grdtrack (void *V_API, int mode, void *args) { } if (gmt_init_distaz (GMT, Ctrl->E.unit, Ctrl->E.mode, GMT_MAP_DIST) == GMT_NOT_A_VALID_TYPE) /* Initialize the distance unit and scaling */ Return (GMT_NOT_A_VALID_TYPE); - + + /* !!! TEMPORARY METHOD !!! */ + /* Currently we cannot use different units in -C and -E, we have to prevent this bug first. See PR #8728 */ /* Check whether -C and -E use different unit */ if (Ctrl->C.active && Ctrl->C.unit != Ctrl->E.unit){ GMT_Report (API, GMT_MSG_ERROR, From bacc85c3bfb7a6f0bda3aa372056a7a1c91e4481 Mon Sep 17 00:00:00 2001 From: Dengda98 Date: Fri, 16 May 2025 21:41:48 +0800 Subject: [PATCH 3/4] DOC: update grdtrack.rst about -C and -E units --- doc/rst/source/grdtrack.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/rst/source/grdtrack.rst b/doc/rst/source/grdtrack.rst index ec866692579..799aa7facf6 100644 --- a/doc/rst/source/grdtrack.rst +++ b/doc/rst/source/grdtrack.rst @@ -139,6 +139,8 @@ Optional Arguments counter-clockwise. Finally, you can use **+f** to set a fixed azimuth for all profiles. **Note**: If |-C| is set and *spacing* is given then that sampling scheme overrules any modifier set in |-E|. + Currently, there is a bug when |-C| and |-E| use different units. + If you use both, please manually specify the same unit for each. .. _-D: From 459889cc432658b35a38d82539f7d7618afb171c Mon Sep 17 00:00:00 2001 From: Dengda98 Date: Fri, 16 May 2025 21:45:56 +0800 Subject: [PATCH 4/4] DOC: update grdtrack.rst, add PR reference --- doc/rst/source/grdtrack.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/rst/source/grdtrack.rst b/doc/rst/source/grdtrack.rst index 799aa7facf6..3e8e8fc710d 100644 --- a/doc/rst/source/grdtrack.rst +++ b/doc/rst/source/grdtrack.rst @@ -139,7 +139,8 @@ Optional Arguments counter-clockwise. Finally, you can use **+f** to set a fixed azimuth for all profiles. **Note**: If |-C| is set and *spacing* is given then that sampling scheme overrules any modifier set in |-E|. - Currently, there is a bug when |-C| and |-E| use different units. + Currently, there is a bug when |-C| and |-E| use different units + (see PR `#8728 `_ ). If you use both, please manually specify the same unit for each. .. _-D: