Skip to content

Commit

Permalink
Let psxy -T without -B skip the check for -R -J (#3672) (#3674)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
github-actions[bot] and PaulWessel authored Jul 18, 2020
1 parent 61a10fd commit 5606bd6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/rst/source/plot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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*] ]
Expand Down
6 changes: 6 additions & 0 deletions doc/rst/source/plot_common.rst_
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down
2 changes: 2 additions & 0 deletions src/gmt_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down
12 changes: 9 additions & 3 deletions src/psxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -859,15 +860,20 @@ 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");
n_errors += gmt_M_check_condition (GMT, Ctrl->S.active && gmt_parse_symbol_option (GMT, Ctrl->S.arg, S, 0, true), "Option -S: Parsing failure\n");
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: +|-<pen> 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");
Expand Down Expand Up @@ -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<unit> is given we temporarily reset the system unit to these units so conversions will work */
save_u = GMT->current.setting.proj_length_unit;
Expand Down

0 comments on commit 5606bd6

Please sign in to comment.