1 /*-------------------------------------------------------------------- 2 * 3 * Copyright (c) 1991-2021 by the GMT Team (https://www.generic-mapping-tools.org/team.html) 4 * See LICENSE.TXT file for copying and redistribution conditions. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU Lesser General Public License as published by 8 * the Free Software Foundation; version 3 or any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * Contact info: www.generic-mapping-tools.org 16 *--------------------------------------------------------------------*/ 17 18 /* 19 * Holds current selections for the family of common GMT options. 20 * 21 * Author: Paul Wessel 22 * Date: 01-JAN-2011 23 * Version: 6 API 24 */ 25 26 /*! 27 * \file gmt_common.h 28 * \brief Holds current selections for the family of common GMT options 29 */ 30 31 #ifndef GMT_COMMON_H 32 #define GMT_COMMON_H 33 34 /*! Constants related to detecting data gaps which should be treated as segment boundaries */ 35 enum GMT_enum_gaps {GMT_NEGGAP_IN_COL = 0, /* Check if previous minus current column value exceeds <gap> */ 36 GMT_POSGAP_IN_COL, /* Check if current minus previous column value exceeds <gap> */ 37 GMT_ABSGAP_IN_COL, /* Check if |current minus previous column value| exceeds <gap> */ 38 GMT_NEGGAP_IN_MAP_COL, /* Check if previous minus current column value exceeds <gap> after map projection */ 39 GMT_POSGAP_IN_MAP_COL, /* Check if current minus previous column value exceeds <gap> after map projection */ 40 GMT_ABSGAP_IN_MAP_COL, /* Check if |current minus previous column value| exceeds <gap> after map projection */ 41 GMT_GAP_IN_GDIST, /* Check if great-circle distance between successive points exceeds <gap> (in km,m,nm, etc)*/ 42 GMT_GAP_IN_CDIST, /* Check if Cartesian distance between successive points exceeds <gap> */ 43 GMT_GAP_IN_PDIST, /* Check if Cartesian distance between successive points exceeds <gap> after map projection */ 44 GMT_GAP_IN_DDIST, /* Check if great-circle distance between successive points exceeds <gap> (in arc degrees,min,sec) */ 45 GMT_N_GAP_METHODS}; 46 47 #define MAX_ASPATIAL 64 /* No more than 64 aspatial options in -a */ 48 49 #define GMT_SHORTHAND_OPTIONS "BJRXYp" /* All of the shorthand options */ 50 #define GMT_CRITICAL_OPT_ORDER "V-JfrRbi" /* If given options among these must be parsed first and in this order */ 51 52 #define RSET 0 /* Index into R.active[] for -R */ 53 #define ISET 1 /* Index into R.active[] for -I (or similar option) */ 54 #define GSET 2 /* Index into R.active[] for -r */ 55 #define FSET 3 /* Index into R.active[] for "got -R -I -r from a grid file" */ 56 57 struct GMT_LEGEND_ITEM { /* Information about one item in a legend */ 58 char label[GMT_LEN128]; /* The symbol label */ 59 char header[GMT_LEN128]; /* Header for the whole legend H */ 60 char subheader[GMT_LEN128]; /* Subheader, i.e., line label L*/ 61 char font[GMT_LEN32]; /* Fontsize to use for current H or L */ 62 char fill[GMT_LEN32]; /* Fill of the canvas behind the legend */ 63 char gap[GMT_LEN32]; /* Move this much down before placing symbol entry */ 64 char off[GMT_LEN32]; /* Offset of anchor point for frame */ 65 char pen[3][GMT_LEN32]; /* Pens to use with +d and +v and +p */ 66 int draw; /* 0 no draw, 1 draw horizontal +d, 2 draw vertical +v */ 67 int just; /* Legend placement [TR] */ 68 int label_type; /* 0 if static string, 1 if integer format statement, 2 if list of labels, 3 if nothing (use segment header) */ 69 char code; /* Label justification code (L|C|R) [L] */ 70 double size; /* Fixed symbol size when otherwise cannot set it */ 71 double size2; /* 2nd size (height) for 2-D symbols */ 72 double scale; /* Scale all given sizes, including +s<length> of a line */ 73 double width; /* Override auto-width with a fixed legend width */ 74 unsigned int ncols; /* How many columns to use for symbols */ 75 unsigned int ID; /* ID to use if label contains C-format for integer */ 76 }; 77 78 /*! Structure with all information given via the common GMT command-line options -R -J .. */ 79 struct GMT_COMMON { 80 struct synopsis { /* \0 (zero) or ^ */ 81 bool active; 82 bool extended; /* + to also show non-common options */ 83 } synopsis; 84 struct B { /* -B<params> */ 85 bool active[2]; /* 0 = primary annotation, 1 = secondary annotations */ 86 int mode; /* 5 = GMT 5 syntax, 4 = GMT 4 syntax, 1 = Either, -1 = mix (error), 0 = not set yet */ 87 char string[2][GMT_LEN256]; 88 } B; 89 struct J { /* -J<params> */ 90 bool active, zactive; 91 unsigned int id; 92 char string[GMT_LEN128]; 93 char zstring[GMT_LEN128]; /* For -Jz|Z */ 94 char proj4string[GMT_LEN256]; 95 char WKTstring[GMT_LEN1024]; 96 double par[6]; 97 } J; 98 struct K { /* -K */ 99 bool active; 100 } K; 101 struct O { /* -O */ 102 bool active; 103 } O; 104 struct P { /* -P */ 105 bool active; 106 } P; 107 struct R { /* -Rw/e/s/n[/z_min/z_max][r] or -Rgridfile */ 108 bool active[4]; /* RSET = 0: -R, ISET = 1: inc, GSET = 2: -r, FSET = 3: read grid */ 109 bool oblique; /* true when -R...r was given (oblique map, probably), else false (map borders are meridians/parallels) */ 110 bool via_polygon; /* Got -R<countrycode> so w/e/s/n may not perfectly fit a grid spacing, for instance */ 111 uint32_t registration; /* Registration mode of a grid given via -r or -Rgrid */ 112 int row_order; /* Order of rows in NetCDF output: 0 (not set) or k_nc_start_north or k_nc_start_south */ 113 unsigned int mode; /* For modern mode only: 0 = get exact region from data, 1 = rounded region from data */ 114 double wesn[6]; /* Boundaries of west, east, south, north, low-z and hi-z */ 115 double wesn_orig[4]; /* Original Boundaries of west, east, south, north (oblique projection may reset wesn above) */ 116 double inc[2]; /* For grid increments set via -Idx/dy or implicitly via -Ggrid */ 117 char string[GMT_LEN256]; 118 } R; 119 struct U { /* -U */ 120 bool active; 121 unsigned int just; 122 double x, y; 123 char *label; /* Content not counted by sizeof (struct) */ 124 } U; 125 struct V { /* -V */ 126 bool active; 127 } V; 128 struct X { /* -X */ 129 bool active; 130 double off; 131 char mode; /* a, c, f, or r */ 132 } X; 133 struct Y { /* -Y */ 134 bool active; 135 double off; 136 char mode; /* a, c, f, or r */ 137 } Y; 138 struct a { /* -a<col>=<name>[:<type>][,col>=<name>[:<type>], etc][+g<geometry>] */ 139 bool active; 140 enum GMT_enum_ogr geometry; 141 unsigned int n_aspatial; 142 bool clip; /* true if we wish to clip lines/polygons at Dateline [false] */ 143 bool output; /* true when we wish to build OGR output */ 144 int col[MAX_ASPATIAL]; /* Col id, include negative items such as GMT_IS_T (-5) */ 145 int ogr[MAX_ASPATIAL]; /* Column order, or -1 if not set */ 146 enum GMT_enum_type type[MAX_ASPATIAL]; 147 char *name[MAX_ASPATIAL]; 148 char string[GMT_LEN256]; 149 } a; 150 struct b { /* -b[i][o][s|S][d|D][#cols][cvar1/var2/...] */ 151 bool active[2]; /* true if current input/output is in native binary format */ 152 bool nc[2]; /* True if netcdf i/o */ 153 bool o_delay; /* true if we don't know number of output columns until we have read at least one input record */ 154 bool bin_primary; /* true if we need to switch back to binary after reading a secondary file in ascii */ 155 enum GMT_swap_direction swab[2]; /* k_swap_in or k_swap_out if current binary input/output must be byte-swapped, else k_swap_none */ 156 uint64_t ncol[2]; /* Number of expected columns of input/output 157 0 means it will be determined by program */ 158 char type[2]; /* Default column type, if set [d for double] */ 159 char varnames[GMT_BUFSIZ]; /* List of variable names to be input/output in netCDF mode [GMT4 COMPATIBILITY ONLY] */ 160 char string[GMT_LEN256]; 161 } b; 162 struct d { /* -d[i][o]<nan_proxy> */ 163 bool active[2]; 164 bool is_zero[2]; 165 unsigned int first_col[2]; /* Only apply from this column onward */ 166 double nan_proxy[2]; 167 char string[GMT_LEN64]; 168 } d; 169 struct e { /* -e[~]\"search string\"] */ 170 bool active; 171 char string[GMT_LEN256]; 172 struct GMT_TEXT_SELECTION *select; 173 } e; 174 struct f { /* -f[i|o]<col>|<colrange>[t|T|g],.. */ 175 bool active[2]; /* For GMT_IN|OUT */ 176 char string[GMT_LEN64]; 177 } f; 178 struct g { /* -g[+]x|x|y|Y|d|Y<gap>[unit] */ 179 bool active; 180 bool selected; 181 unsigned int n_methods; /* How many different criteria to apply */ 182 uint64_t n_col; /* Largest column-number needed to be read */ 183 bool match_all; /* If true then all specified criteria must be met to be a gap [default is any of them] */ 184 enum GMT_enum_gaps method[GMT_N_GAP_METHODS]; /* How distances are computed for each criteria */ 185 int64_t col[GMT_N_GAP_METHODS]; /* Which column to use (-1 for x,y distance) */ 186 double gap[GMT_N_GAP_METHODS]; /* The critical distances for each criteria */ 187 double (*get_dist[GMT_N_GAP_METHODS]) (struct GMT_CTRL *GMT, uint64_t); /* Pointers to functions that compute those distances */ 188 char string[GMT_LEN64]; 189 } g; 190 struct h { /* -h[i|o][<nrecs>][+d][+c][+m[<text>]][+r<remark>][+t<title>] */ 191 bool active; 192 bool add_colnames; 193 unsigned int mode; 194 unsigned int n_recs; 195 char *title; 196 char *remark; 197 char *colnames; /* Not set by -h but maintained here */ 198 char *multi_segment; /* To hold a multi-segment string */ 199 char string[GMT_LEN256]; 200 } h; 201 struct i { /* -i[<col>|<colrange>,...][t[<word>]] */ 202 bool active, select, orig, word, end; 203 uint64_t n_cols, w_col; 204 uint64_t n_actual_cols; 205 char string[GMT_LEN64]; 206 } i; 207 struct j { /* -je|f|g [g] */ 208 bool active; 209 enum GMT_enum_mdist mode; /* Defaults to GMT_GREATCIRCLE */ 210 char string[GMT_LEN8]; 211 } j; 212 struct l { /* -l[<label>][+s<size>][+t<title>][+n<ncols>][+d<gap>/<pen>] */ 213 bool active; 214 struct GMT_LEGEND_ITEM item; 215 } l; 216 struct n { /* -n[b|c|l|n][+a][+b<BC>][+c][+t<threshold>] (and +A for debugging) */ 217 bool active; 218 bool antialias; /* Defaults to true, if supported */ 219 bool save_debug; /* Write antialias counters to tmp grid */ 220 bool truncate; /* Defaults to false */ 221 unsigned int interpolant; /* Defaults to BCR_BICUBIC */ 222 bool bc_set; /* true if +b was parsed */ 223 bool periodic[2]; /* For periodic non-geographic grids */ 224 char BC[4]; /* For BC settings via +bg|n[x|y]|p[x|y] */ 225 double threshold; /* Defaults to 0.5 */ 226 double range[2], half_range[2]; /* For periodic non-geographic grids */ 227 char string[GMT_LEN64]; /* Copy of argument */ 228 } n; 229 struct o { /* -o[<col>|<colrange>,...][t[<word>]] */ 230 bool active, select, orig, word, end, text; 231 uint64_t n_cols, w_col; 232 char string[GMT_LEN64]; 233 } o; 234 struct p { /* -p<az>[/<el>[/<z0>]]+wlon0/lat0[/z0]][+vx0[cip]/y0[cip]] */ 235 bool active; 236 bool do_z_rotation; /* true if rotating plot about a vertical axis */ 237 double z_rotation; /* Rotation of <angle> about vertical axis */ 238 } p; 239 struct q { /* -q[i|o]<rows>,...[+c<col>][+a|f|s] */ 240 bool active[2]; 241 bool inverse[2]; 242 char string[2][GMT_LEN64]; 243 unsigned int col; /* When +c<col> sets a specific data column */ 244 unsigned int mode; /* 1 for in row-range check, 2 for in time check, 3 for out-row check, 4 for out-time check */ 245 uint64_t *rec; /* POinter to the relevant record counter (dataset, table, segment) */ 246 } q; 247 struct s { /* -s[r] */ 248 bool active; 249 char string[GMT_LEN64]; 250 } s; 251 struct t { /* -t[<filltransparency>[/<stroketransparency>]][+f][+s] */ 252 bool active; 253 bool variable; 254 unsigned int mode; /* 1 = fill, 2 = stroke, 3 for both */ 255 unsigned int n_transparencies; /* How many to read from file if no values given */ 256 double value[2]; 257 } t; 258 struct w { /* -w[<col>]y|m|w|d|p<period>[/<phase>] */ 259 bool active; 260 char string[GMT_LEN64]; 261 } w; 262 struct x { /* -x[[-]<n>] */ 263 bool active; 264 int n_threads; 265 } x; 266 struct colon { /* -:[i|o] */ 267 bool active; 268 bool toggle[2]; 269 char string[2][GMT_LEN16]; 270 } colon; 271 }; 272 273 #endif /* GMT_COMMON_H */ 274