Skip to content

Commit

Permalink
When using -D do not try to check the gmt_raster_type(). (#7741)
Browse files Browse the repository at this point in the history
Fixes #7570

Co-authored-by: Paul Wessel <pwessel@hawaii.edu>
  • Loading branch information
joa-quim and PaulWessel authored Aug 20, 2023
1 parent 0dcf60d commit 345274a
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/grdcut.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,20 +294,22 @@ static int parse (struct GMT_CTRL *GMT, struct GRDCUT_CTRL *Ctrl, struct GMT_OPT
n_errors += gmt_M_check_condition (GMT, !Ctrl->G.file && !Ctrl->D.active, "Option -G: Must specify output grid file\n");
n_errors += gmt_M_check_condition (GMT, !Ctrl->In.active, "Must specify one input grid file\n");
if (n_errors == 0) {
int ftype = gmt_raster_type (GMT, Ctrl->In.file, true);
if (ftype == GMT_IS_IMAGE) /* Must read file as an image */
Ctrl->In.type = GMT_IS_IMAGE;
else if (ftype == GMT_IS_GRID) { /* Check extension in case of special case */
if (strstr (Ctrl->G.file, ".tif")) /* Want to write a single band (normally written as a grid) to geotiff instead */
if (!Ctrl->D.quit) {
int ftype = gmt_raster_type(GMT, Ctrl->In.file, true);
if (ftype == GMT_IS_IMAGE) /* Must read file as an image */
Ctrl->In.type = GMT_IS_IMAGE;
else
else if (ftype == GMT_IS_GRID) { /* Check extension in case of special case */
if (strstr (Ctrl->G.file, ".tif")) /* Want to write a single band (normally written as a grid) to geotiff instead */
Ctrl->In.type = GMT_IS_IMAGE;
else
Ctrl->In.type = GMT_IS_GRID;
}
else /* Just have to assume it is a grid */
Ctrl->In.type = GMT_IS_GRID;
}
else /* Just have to assume it is a grid */
Ctrl->In.type = GMT_IS_GRID;
if (Ctrl->In.type == GMT_IS_IMAGE) {
n_errors += gmt_M_check_condition (GMT, Ctrl->Z.active, "Option -N: Cannot be used with an image\n");
n_errors += gmt_M_check_condition (GMT, Ctrl->Z.active, "Option -Z: Cannot be used with an image\n");
if (Ctrl->In.type == GMT_IS_IMAGE) {
n_errors += gmt_M_check_condition (GMT, Ctrl->Z.active, "Option -N: Cannot be used with an image\n");
n_errors += gmt_M_check_condition (GMT, Ctrl->Z.active, "Option -Z: Cannot be used with an image\n");
}
}
}

Expand Down

0 comments on commit 345274a

Please sign in to comment.