Skip to content

Allow for longer history and remark strings #6078

@PaulWessel

Description

@PaulWessel

Description of the desired feature

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:

  1. Replace the above fixed length char arrays with char pointers.
  2. Let GMT->session.readinfo[] be the places where we allocate these strings based on what we find in the file
  3. When writing native grids and any other format with a limit on string length, ensure we max write the length as indicated above.
  4. When a grid header is freed, we free these strings as well.

Any unforeseen consequences with this, @GenericMappingTools/gmt-team?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions