Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psconvert should ignore writing world file if geotiff output is requested #7865

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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