From 5606bd6e185c50c25dafe493e79e88c532d8ab84 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 17 Jul 2020 23:54:55 -0400 Subject: [PATCH] Let psxy -T without -B skip the check for -R -J (#3672) (#3674) Since no projection is needed to iin this case (presumably to set -X -Y only) then we dont need to complain if -R -J are not set. Co-authored-by: Paul Wessel --- doc/rst/source/plot.rst | 1 + doc/rst/source/plot_common.rst_ | 6 ++++++ src/gmt_init.c | 2 ++ src/psxy.c | 12 +++++++++--- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/doc/rst/source/plot.rst b/doc/rst/source/plot.rst index b7539e3870a..864cb84c0c0 100644 --- a/doc/rst/source/plot.rst +++ b/doc/rst/source/plot.rst @@ -25,6 +25,7 @@ Synopsis [ |-L|\ [**+b**\|\ **d**\|\ **D**][**+xl**\|\ **r**\|\ *x0*][**+yl**\|\ **r**\|\ *y0*][**+p**\ *pen*] ] [ |-N|\ [**c**\|\ **r**] ] [ |-S|\ [*symbol*][*size* ] +[ |-T| ] [ |SYN_OPT-U| ] [ |SYN_OPT-V| ] [ |-W|\ [*pen*][*attr*] ] diff --git a/doc/rst/source/plot_common.rst_ b/doc/rst/source/plot_common.rst_ index 89fa7c41d9d..4930a010d25 100644 --- a/doc/rst/source/plot_common.rst_ +++ b/doc/rst/source/plot_common.rst_ @@ -162,6 +162,12 @@ Optional Arguments .. include:: explain_symbols.rst_ +.. _-T: + +**-T** + Ignore all input files. If **-B** is not used then **-R -J** are not required. + Typically used to move plot origin via **-X** and **-Y**. + .. _-U: .. include:: explain_-U.rst_ diff --git a/src/gmt_init.c b/src/gmt_init.c index 7751376b334..af190eb6591 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -13675,6 +13675,8 @@ struct GMT_CTRL *gmt_init_module (struct GMTAPI_CTRL *API, const char *lib_name, } if (options && strstr (mod_name, "mapproject") && (opt = GMT_Find_Option (API, 'W', *options))) /* Must turn on JR */ required = "JR"; + if (options && !strcmp (mod_name, "psxy") && (opt = GMT_Find_Option (API, 'T', *options)) && (opt = GMT_Find_Option (API, 'B', *options)) == NULL) /* Can turn off JR if -T and no -B */ + required = ""; if (options && strstr (mod_name, "grdflexure") && (opt = GMT_Find_Option (API, 'Q', *options))) /* Must turn of g */ required = ""; diff --git a/src/psxy.c b/src/psxy.c index d7715db61e6..9cb49568475 100644 --- a/src/psxy.c +++ b/src/psxy.c @@ -36,6 +36,7 @@ /* Control structure for psxy */ struct PSXY_CTRL { + bool no_RJ_needed; /* Special case of -T and no -B when -R -J is not required */ struct PSXY_A { /* -A[m|y|p|x|step] */ bool active; unsigned int mode; @@ -859,6 +860,9 @@ static int parse (struct GMT_CTRL *GMT, struct PSXY_CTRL *Ctrl, struct GMT_OPTIO /* Check that the options selected are mutually consistent */ + if (Ctrl->T.active && (GMT->common.B.active[GMT_PRIMARY] == false && GMT->common.B.active[GMT_SECONDARY] == false)) + Ctrl->no_RJ_needed = true; /* Not plotting any data or frame that needs -R -J */ + if (Ctrl->T.active && n_files) GMT_Report (API, GMT_MSG_WARNING, "Option -T ignores all input files\n"); n_errors += gmt_M_check_condition (GMT, Ctrl->Z.active && !Ctrl->C.active, "Option -Z: No CPT given via -C\n"); n_errors += gmt_M_check_condition (GMT, Ctrl->C.active && (Ctrl->C.file == NULL || Ctrl->C.file[0] == '\0'), "Option -C: No CPT given\n"); @@ -866,8 +870,10 @@ static int parse (struct GMT_CTRL *GMT, struct PSXY_CTRL *Ctrl, struct GMT_OPTIO n_errors += gmt_M_check_condition (GMT, Ctrl->E.active && (S->symbol == PSL_VECTOR || S->symbol == GMT_SYMBOL_GEOVECTOR || S->symbol == PSL_MARC \ || S->symbol == PSL_ELLIPSE || S->symbol == GMT_SYMBOL_FRONT || S->symbol == GMT_SYMBOL_QUOTED_LINE || S->symbol == GMT_SYMBOL_DECORATED_LINE || S->symbol == PSL_ROTRECT), "Option -E: Incompatible with -Se, -Sf, -Sj, -Sm|M, -Sq, -Sv|V, -S=\n"); - n_errors += gmt_M_check_condition (GMT, !GMT->common.R.active[RSET], "Must specify -R option\n"); - n_errors += gmt_M_check_condition (GMT, !GMT->common.J.active, "Must specify a map projection with the -J option\n"); + if (!Ctrl->no_RJ_needed) { + n_errors += gmt_M_check_condition (GMT, !GMT->common.R.active[RSET], "Must specify -R option\n"); + n_errors += gmt_M_check_condition (GMT, !GMT->common.J.active, "Must specify a map projection with the -J option\n"); + } n_errors += gmt_M_check_condition (GMT, GMT->common.b.active[GMT_IN] && S->symbol == GMT_SYMBOL_NOT_SET, "Binary input data cannot have symbol information\n"); n_errors += gmt_M_check_condition (GMT, Ctrl->E.active && Ctrl->E.mode && !Ctrl->C.active, "Option -E: +|- requires the -C option\n"); n_errors += gmt_M_check_condition (GMT, Ctrl->W.active && Ctrl->W.pen.cptmode && !Ctrl->C.active, "Option -W modifier +c requires the -C option\n"); @@ -1054,7 +1060,7 @@ EXTERN_MSC int GMT_psxy (void *V_API, int mode, void *args) { Return (GMT_RUNTIME_ERROR); GMT_Report (API, GMT_MSG_DEBUG, "Operation will require %d input columns [n_cols_start = %d]\n", n_needed, n_cols_start); - if (gmt_M_err_pass (GMT, gmt_map_setup (GMT, GMT->common.R.wesn), "")) + if (!Ctrl->no_RJ_needed && gmt_M_err_pass (GMT, gmt_map_setup (GMT, GMT->common.R.wesn), "")) Return (GMT_PROJECTION_ERROR); if (S.u_set) { /* When -Sc is given we temporarily reset the system unit to these units so conversions will work */ save_u = GMT->current.setting.proj_length_unit;