Skip to content

Commit

Permalink
Let psxy -N be usable with binary input.
Browse files Browse the repository at this point in the history
Fix issue #8606
  • Loading branch information
joa-quim committed Jan 3, 2025
1 parent 7764c3a commit e4b83fb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/gmt_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ struct GMT_COMMON {
char string[GMT_LEN256];
} a;
struct b { /* -b[i][o][s|S][d|D][#cols][cvar1/var2/...] */
bool active[2]; /* true if current input/output is in native binary format */
bool active[3]; /* true if current input/output is in native binary format */
bool nc[2]; /* True if netcdf i/o */
bool o_delay; /* true if we don't know number of output columns until we have read at least one input record */
bool bin_primary; /* true if we need to switch back to binary after reading a secondary file in ascii */
Expand Down
2 changes: 1 addition & 1 deletion src/gmt_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -4835,7 +4835,7 @@ int gmtlib_process_binary_input (struct GMT_CTRL *GMT, uint64_t n_read) {
gmtio_adjust_periodic_lon (GMT, &GMT->current.io.curr_rec[col_no]);
break;
case GMT_IS_LAT:
if (GMT->current.io.curr_rec[col_no] < -90.0 || GMT->current.io.curr_rec[col_no] > +90.0) {
if (!GMT->common.b.active[2] && (GMT->current.io.curr_rec[col_no] < -90.0 || GMT->current.io.curr_rec[col_no] > +90.0)) {
GMT_Report (GMT->parent, GMT_MSG_WARNING, "Latitude (%g) at line # %" PRIu64 " exceeds -|+ 90! - set to NaN\n", GMT->current.io.curr_rec[col_no], GMT->current.io.rec_no);
GMT->current.io.curr_rec[col_no] = GMT->session.d_NaN;
}
Expand Down
7 changes: 6 additions & 1 deletion src/psxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,8 @@ 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 (Ctrl->N.active && GMT->common.b.active[GMT_IN]) GMT->common.b.active[2] = true; /* To signal gmtlib_process_binary_input that lats may be of |90| */

if (GMT->common.R.active[RSET] && GMT->common.J.active && 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 */
Expand Down Expand Up @@ -2430,7 +2432,10 @@ EXTERN_MSC int GMT_psxy (void *V_API, int mode, void *args) {
gmt_M_rgb_copy (current_pen.rgb, save_pen.rgb);
if (Ctrl->H.active) current_pen = nominal_pen;
} while (true);
if (GMT->common.t.variable) { /* Reset the transparencies */

GMT->common.b.active[2] = false; /* Reset this because externals have long memory and -N may not be used in a future call */

if (GMT->common.t.variable) { /* Reset the transparencies */
double transp[2] = {0.0, 0.0}; /* None selected */
PSL_settransparencies (PSL, transp);
}
Expand Down

0 comments on commit e4b83fb

Please sign in to comment.