You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since last century, the grid header strings title, history and remake (as well as units) have been defined as
char x_units[GMT_GRID_UNIT_LEN80]; /* units in x-direction */
char y_units[GMT_GRID_UNIT_LEN80]; /* units in y-direction */
char z_units[GMT_GRID_UNIT_LEN80]; /* grid value units */
char title[GMT_GRID_TITLE_LEN80]; /* name of data set */
char command[GMT_GRID_COMMAND_LEN320]; /* name of generating command */
char remark[GMT_GRID_REMARK_LEN160]; /* comments re this data set */
Hence, any GMT native binary grids are limited to those lengths. However, there is no good reasons to limit these strings for the more typical format such as netCDF. I am currently trying to set a remark to contain a citation and running into the 160 limit, which is silly. Also, many netCDF files have a series of concatenated command histories and even 320 becomes too small.
I think this is a backwards compatible change:
Replace the above fixed length char arrays with char pointers.
Let GMT->session.readinfo[] be the places where we allocate these strings based on what we find in the file
When writing native grids and any other format with a limit on string length, ensure we max write the length as indicated above.
When a grid header is freed, we free these strings as well.
Any unforeseen consequences with this, @GenericMappingTools/gmt-team?
Yes true. Just thought of an alternative solution. When we detect longer strings that can be held, we truncate then as we do now but store the full version in new pointers in either the grid header or the hidden grid header. I understand this may also mean an update to the Julia structs but this is where some sort of versioning must come in, right? There must be a way to address upgrades when necessary.
When these strings get increased length, would it be possible to keep a history of e.g. commands that the grid has been through? As it is now, only the last command will be 'saved' in command[], I think?
Basically; append to the string; don't replace it.
Anything that changes the structures starting at is a breaking change. But the C struct GMT_GRID_HEADER { ends with a non-public void *hidden; that could eventually be used to add/read new attributes in the nc files with extended info. Doing it this way would not break anything.
Activity
SHorten the remarks in the grids
SHorten the remarks in the grids (#130)
joa-quim commentedon Dec 2, 2021
Will break Julia and MEX that have fixed sizes in the GRID_HEADER structs
PaulWessel commentedon Dec 2, 2021
Yes true. Just thought of an alternative solution. When we detect longer strings that can be held, we truncate then as we do now but store the full version in new pointers in either the grid header or the hidden grid header. I understand this may also mean an update to the Julia structs but this is where some sort of versioning must come in, right? There must be a way to address upgrades when necessary.
joa-quim commentedon Dec 2, 2021
Following the semantic version that breaking change alone, that also breaks the
API, would imply a GMT7PaulWessel commentedon Dec 2, 2021
That is a valid point. We will wait for GMT 7 on that.
anbj commentedon Dec 2, 2021
When these strings get increased length, would it be possible to keep a history of e.g. commands that the grid has been through? As it is now, only the last command will be 'saved' in command[], I think?
Basically; append to the string; don't replace it.
anbj commentedon Dec 2, 2021
Also, converting a netcdf file to .e.g. geotiff strips off this information:
It would be nice if this information was kept.
maxrjones commentedon Dec 2, 2021
Would adding a new element to the header to store the citation history also be a breaking change?
joa-quim commentedon Dec 2, 2021
Anything that changes the structures starting at is a breaking change. But the C
struct GMT_GRID_HEADER {ends with a non-publicvoid *hidden;that could eventually be used to add/read new attributes in the nc files with extended info. Doing it this way would not break anything.PaulWessel commentedon Dec 2, 2021
Yes, I was going to ask you if you were also wrapping the HIDDEN structs, but if you don't then that gives me wiggle room to add things there. OK?
joa-quim commentedon Dec 2, 2021
No wrapping of that void pointer. It just lays there wasting the 8 bytes of the pointer address. Feel free to stuff in that hidden jungle.
PaulWessel commentedon Dec 2, 2021
Oh boy, I will add in a link to a 2 Gb hidden grid just to bring your laptop to a halt.
joa-quim commentedon Dec 2, 2021
Ah, that's a dwarf. Nothing like a good 3.6 GB Docker that wraps the monstrous (mini)Conda
PaulWessel commentedon Dec 5, 2021
In the spirit of Christmas I did not add any hidden grids, this time.
maxrjones commentedon Mar 18, 2022
Longer history and remark strings were implemented in #6084, so I am closing this issue. Please reopen if there is more to be done.