Skip to content

Commit

Permalink
psconvert should ignore writing world file if geotiff output is reque…
Browse files Browse the repository at this point in the history
…sted (#7865)

* Ignore writing world file if geotiff output is requested

See #7844 for discussion.  Closes #7844. Note to @joa-quim : In messages that says

...the Proj4 command...

should that be PROJ or are these things still called proj4 even though we are at proj9?

* Update psconvert.c

Keep old world_file name so it can be deleted.
  • Loading branch information
PaulWessel authored Oct 4, 2023
1 parent e2782af commit 623a189
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/psconvert.c
Original file line number Diff line number Diff line change
Expand Up @@ -2686,7 +2686,7 @@ EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
Return (GMT_RUNTIME_ERROR);
}

if (Ctrl->W.active && found_proj && !Ctrl->W.kml) { /* Write a world file */
if (Ctrl->W.active && found_proj && !Ctrl->W.kml) { /* Write a world file unless KML [and Geotiff if -W+g] */
double x_inc, y_inc;
char world_file[PATH_MAX] = "", *wext = NULL, *s = NULL;

Expand Down Expand Up @@ -2740,12 +2740,12 @@ EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
if (proj4_cmd)
GMT_Report (API, GMT_MSG_INFORMATION, "Proj4 definition: %s\n", proj4_cmd);
}

gmt_M_str_free (wext);

if (Ctrl->W.warp && proj4_cmd && proj4_cmd[1] == 'p') { /* We got a usable Proj4 string. Run it (if gdal is around) */
/* The true geotiff file will have the same base name plus a .tiff extension.
We will reuse the world_file variable because all it is need is to replace the extension */
char *delete_world_file = strdup (world_file);
pos_ext = get_extension_period (world_file); /* Get beginning of file extension */
world_file[pos_ext] = '\0';
strcat (world_file, ".tiff");
Expand All @@ -2767,6 +2767,7 @@ EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
}
if (!Ctrl->T.active) /* Get rid of the intermediate JPG file if -T was not set */
gmt_remove_file (GMT, out_file);
if (delete_world_file) gmt_remove_file (GMT, delete_world_file); /* No longer needed now we have a Geotiff file */
}
else if (Ctrl->W.warp && !proj4_cmd)
GMT_Report (API, GMT_MSG_ERROR, "Could not find the Proj4 command in the PS file. No conversion performed.\n");
Expand Down

0 comments on commit 623a189

Please sign in to comment.