Skip to content
Merged
Show file tree
Hide file tree
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
27 changes: 24 additions & 3 deletions src/gmt_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -4695,7 +4695,7 @@ GMT_LOCAL bool gmtapi_expand_index_image (struct GMT_CTRL *GMT, struct GMT_IMAGE
for (c = 0; c < 3; c++, k++) data[k] = I->colormap[start_c+c]; /* Place r,g,b in separate bands */
}
/* If neither TRB or TRP we call for a changed layout, which may or may not have been implemented */
GMT_Change_Layout (GMT->parent, GMT_IS_IMAGE, GMT->parent->GMT->current.gdal_read_in.O.mem_layout, 0, I, NULL, NULL);
GMT_Change_Layout (GMT->parent, GMT_IS_IMAGE, GMT->parent->GMT->current.gdal_read_in.O.mem_layout, 0, I, NULL, NULL);
}
gmt_M_free_aligned (GMT, I->data); /* Free previous aligned image memory */
I->data = data; /* Pass the reallocated rgb TRB image back */
Expand Down Expand Up @@ -5151,7 +5151,7 @@ GMT_LOCAL struct GMT_GRID * gmtapi_import_grid (struct GMTAPI_CTRL *API, int obj
}
if ((mode & GMT_CONTAINER_ONLY) && S_obj->region) {
GMT_Report (API, GMT_MSG_ERROR, "Cannot request a subset when just inquiring about the grid header\n");
return_null (API, GMT_SUBSET_NOT_ALLOWED);
return_null (API, GMT_SUBSET_NOT_ALLOWED);
}

if (S_obj->region && grid) { /* See if this is really a subset or just the same region as the grid */
Expand Down Expand Up @@ -7563,6 +7563,27 @@ int GMT_Close_VirtualFile_ (unsigned int *family, char *string, int len) {
}
#endif

int gmtlib_delete_virtualfile (void *V_API, const char *string) {
/* Given a VirtualFile name, delete its record bu NULLing it */
int object_ID, item;
struct GMTAPI_DATA_OBJECT *S_obj = NULL;
struct GMTAPI_CTRL *API = NULL;
if (V_API == NULL) return_error (V_API, GMT_NOT_A_SESSION);
if (string == NULL) return_error (V_API, GMT_PTR_IS_NULL);
if ((object_ID = gmtapi_decode_id (string)) == GMT_NOTSET)
return_error (V_API, GMT_OBJECT_NOT_FOUND);
API = gmtapi_get_api_ptr (V_API);
if ((item = gmtlib_validate_id (API, GMT_NOTSET, object_ID, GMT_NOTSET, GMT_NOTSET)) == GMT_NOTSET)
return_error (API, GMT_OBJECT_NOT_FOUND);
S_obj = API->object[item]; /* Short-hand */
if (S_obj->family != S_obj->actual_family) /* Reset the un-masquerading that GMT_Open_VirtualFile did */
S_obj->family = S_obj->actual_family;
S_obj->no_longer_owner = true;
S_obj->resource = NULL;

return GMT_NOERROR;
}

void * GMT_Read_VirtualFile (void *V_API, const char *string) {
/* Given a VirtualFile name, retrieve the resulting object */
int object_ID;
Expand Down Expand Up @@ -13426,7 +13447,7 @@ int GMT_Get_FilePath (void *V_API, unsigned int family, unsigned int direction,
/* Nothing*/
}
else if (gmt_M_file_is_netcdf (file)) /* Meaning it specifies a layer etc via ?<args> */
c = strchr (file, '?');
c = strchr (file, '?');
else { /* Check for modifiers */
unsigned int nm = gmt_validate_modifiers (API->GMT, file, 0, "onsuU", GMT_MSG_QUIET);
if (nm) /* Found some valid modifiers, lets get to the first */
Expand Down
1 change: 1 addition & 0 deletions src/gmt_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ struct GMT_XINGS {
EXTERN_MSC char *dlerror (void);
#endif

EXTERN_MSC int gmtlib_delete_virtualfile (void *API, const char *string);
EXTERN_MSC int gmtlib_file_is_jpeg2000_tile (struct GMTAPI_CTRL *API, char *file);
EXTERN_MSC int gmtlib_download_remote_file (struct GMT_CTRL *GMT, const char* file_name, char *path, int k_data, unsigned int mode);
EXTERN_MSC int gmtlib_get_serverfile_index (struct GMTAPI_CTRL *API, const char *file);
Expand Down
13 changes: 9 additions & 4 deletions src/gmt_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ GMT_LOCAL struct GMT_DATA_INFO *gmtremote_data_load (struct GMTAPI_CTRL *API, in
else
GMT_Report (API, GMT_MSG_ERROR, "Unable to parse \"%s\" to extract GMT version\n", line);
return NULL;
}
}
if ((I = gmt_M_memory (GMT, NULL, *n, struct GMT_DATA_INFO)) == NULL) {
GMT_Report (API, GMT_MSG_ERROR, "Unable to allocated %d GMT_DATA_INFO structures!\n", *n);
return NULL;
Expand Down Expand Up @@ -748,7 +748,7 @@ GMT_LOCAL int gmtremote_refresh (struct GMTAPI_CTRL *API, unsigned int index) {
if (!access (old_indexpath, F_OK))
remove (old_indexpath); /* Remove old index file if it exists */
}
else
else
GMT->current.io.new_data_list = true; /* Flag that we wish to delete datasets older than entries in this file */
}
else
Expand Down Expand Up @@ -1351,7 +1351,7 @@ char ** gmt_get_dataset_tiles (struct GMTAPI_CTRL *API, double wesn_in[], int k_
XS = (lon < 0) ? 'W' : 'E';
/* Write remote tile name to list */
if (n >= n_alloc) {
n_alloc <<= 1;
n_alloc <<= 1;
if ((list = gmt_M_memory (API->GMT, list, n_alloc, char *)) == NULL) {
GMT_Report (API, GMT_MSG_ERROR, "gmt_get_dataset_tiles: Unable to reallocate memory.\n");
API->error = GMT_RUNTIME_ERROR;
Expand Down Expand Up @@ -1394,7 +1394,7 @@ char *gmtlib_get_tile_list (struct GMTAPI_CTRL *API, double wesn[], int k_data,
if (strcmp (Ip->filler, "-") && srtm_flag == 0) { /* Want background filler, except special case when srtm_relief is the given dataset name (srtm_flag == 1) */
if ((k_filler = gmt_remote_dataset_id (API, Ip->filler)) == GMT_NOTSET) {
GMT_Report (API, GMT_MSG_ERROR, "gmtlib_get_tile_list: Internal error - Filler grid %s is not a recognized remote data set.\n", Ip->filler);
return NULL;
return NULL;
}
Is = &API->remote_info[k_filler]; /* Pointer to secondary tiled dataset */
ocean = (strcmp (Is->inc, "15s") == 0);
Expand Down Expand Up @@ -1507,6 +1507,11 @@ struct GMT_GRID *gmtlib_assemble_tiles (struct GMTAPI_CTRL *API, double *region,
GMT_Report (API, GMT_MSG_ERROR, "ERROR - Unable to receive blended grid from grdblend\n");
return NULL;
}
if (gmtlib_delete_virtualfile (API, grid)) { /* Remove trace since passed upwards anyway */
GMT_Report (API, GMT_MSG_ERROR, "ERROR - Unable to destroy temporary object for assembled grid\n");
return NULL;
}

HH = gmt_get_H_hidden (G->header);
HH->orig_datatype = GMT_SHORT; /* Since we know this */
return (G);
Expand Down