Good Day,
My name is David and I recently joined this community forum. Very appreciative of the GMT toolset capabilities.
I have a few questions regarding the API in regards to differences between v5.4.5 and v6.5
We currently utilize 5.4.5 as part of a larger C++ application and it has been stable for quite some time. I am currently trying to upgrade to 6.5 due to some new requirements and have run into some problems that I cannot quite understand.
Here is a snippet of the implementation in question:
gmt_api = GMT_Create_Session("GMT Surface", 2U, GMT_SESSION_NORMAL, &logger);
if (!gmt_api)
GENERROR(ERR_GENERAL, "Unable to create the external surface session.\n");
//call GMT_Create_Data() to create an empty vector object
uint64_t par[2];
par[0] = 3;
par[1] = m_sizeOfInputData;
GMT_VECTOR *gmt_vector = static_cast<GMT_VECTOR *>(GMT_Create_Data(gmt_api, GMT_IS_VECTOR, GMT_IS_PLP,
GMT_CONTAINER_ONLY, par, nullptr, nullptr,
GMT_GRID_NODE_REG, 2, nullptr));
//then call GMT_Put_Vector() to put my allocated float arrays into this empty vector.
GMT_Put_Vector(gmt_api, gmt_vector, 0, GMT_DOUBLE, m_inputDataX);
GMT_Put_Vector(gmt_api, gmt_vector, 1, GMT_DOUBLE, m_inputDataY);
GMT_Put_Vector(gmt_api, gmt_vector, 2, GMT_DOUBLE, m_inputDataZ);
// Create virtual input file struct
int val = GMT_Open_VirtualFile(gmt_api, GMT_IS_VECTOR, GMT_IS_PLP, GMT_IN, gmt_vector, input);
There have been no code changes, only upgrading to 6.5.
My two questions are
Question 1:
The Create_Session API now seems to fail and return out a null gmt session. I traced this to a code difference between 5.4.5 and 6.5 in gmt_init.c at the following lines:
#ifdef _WIN32
/* Set all I/O to binary mode */
if ( _setmode(_fileno(stdin), _O_BINARY) == -1 ) {
if (API->external)
GMT_Report (API, GMT_MSG_WARNING, "Could not set binary mode for stdin. This may no be a fatal error but...\n");
else {
GMT_Report (API, GMT_MSG_WARNING, "Could not set binary mode for stdin.\n");
return NULL;
}
}
I noticed that now, if we are not an external session (which documentation shows C++ application does not need to be), then it will fail and return NULL. We are calling this in the context of a winMain application so _setmode would fail because there is no console.
However, the code in 5.4.5 did still call _setmode
but, did not return out like it does now. So our application would work then but, will not now. Could you help me understand if we need to make a change to how our session is configured to deal with this issue?
Question 2:
If I temporarily work around the session issue by changing the session type to GMT_SESSION_EXTERNAL
, then I run into a problem with GMT_VECTOR and GMT_Open_VirtualFile API. Here it now fails in gmt_api.c in the Open_VirtualFile
api at line 9275.
if (direction == GMT_IN && !gmtapi_valid_input_family (family)) return GMT_NOT_A_VALID_FAMILY;
However, this used to work as well in 5.4.5.
So, is there a change in how we should used GMT_VECTOR or did I miss something? The API documentation seems to indicate it is still a valid data structure to use.
Question 3:
We are only using the surface tool functionality in GMT. Is there a minimal list of dependencies from GDAL, PROJ, etc that are needed to only run that tool?
Thanks for your reply,
David