Skip to content

Commit 49e57ae

Browse files
authored
FIX: check whether -C and -E use different unit in grdtrack (#8728)
* FIX: check whether -C and -E use different unit * DOC: update annotation of checking -C and -E units * DOC: update grdtrack.rst about -C and -E units * DOC: update grdtrack.rst, add PR reference
1 parent e53628a commit 49e57ae

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

doc/rst/source/grdtrack.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ Optional Arguments
139139
counter-clockwise. Finally, you can use **+f** to set a fixed azimuth
140140
for all profiles. **Note**: If |-C| is set and *spacing* is given then
141141
that sampling scheme overrules any modifier set in |-E|.
142+
Currently, there is a bug when |-C| and |-E| use different units
143+
(see PR `#8728 <https://github.com/GenericMappingTools/gmt/pull/8728>`_ ).
144+
If you use both, please manually specify the same unit for each.
142145

143146
.. _-D:
144147

src/grdtrack.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,16 @@ EXTERN_MSC int GMT_grdtrack (void *V_API, int mode, void *args) {
815815
}
816816
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 */
817817
Return (GMT_NOT_A_VALID_TYPE);
818+
819+
/* !!! TEMPORARY METHOD !!! */
820+
/* Currently we cannot use different units in -C and -E, we have to prevent this bug first. See PR #8728 */
821+
/* Check whether -C and -E use different unit */
822+
if (Ctrl->C.active && Ctrl->C.unit != Ctrl->E.unit){
823+
GMT_Report (API, GMT_MSG_ERROR,
824+
"Option -C and -E shoule take the same unit, but received %c (-C) and %c (-E). "
825+
"Recommend you explicitly set the same unit for -C and -E.\n", Ctrl->C.unit, Ctrl->E.unit);
826+
Return (GMT_RUNTIME_ERROR);
827+
}
818828

819829
/* Set default spacing to half the min grid spacing: */
820830
Ctrl->E.step = 0.5 * MIN (GC[0].G->header->inc[GMT_X], GC[0].G->header->inc[GMT_Y]);

0 commit comments

Comments
 (0)