| 170 | } |
| 171 | |
| 172 | static int parse (struct GMT_CTRL *GMT, struct GRDVECTOR_CTRL *Ctrl, struct GMT_OPTION *options) { |
| 173 | /* This parses the options provided to grdvector and sets parameters in Ctrl. |
| 174 | * Note Ctrl has already been initialized and non-zero default values set. |
| 175 | * Any GMT common options will override values set previously by other commands. |
| 176 | * It also replaces any file names specified as input or output with the data ID |
| 177 | * returned when registering these sources/destinations with the API. |
| 178 | */ |
| 179 | |
| 180 | unsigned int n_errors = 0, n_files = 0; |
| 181 | int j; |
| 182 | size_t len; |
| 183 | char txt_a[GMT_LEN256] = {""}, txt_b[GMT_LEN256] = {""}, txt_c[GMT_LEN256] = {""}, *c = NULL; |
| 184 | struct GMT_OPTION *opt = NULL; |
| 185 | struct GMTAPI_CTRL *API = GMT->parent; |
| 186 | |
| 187 | /* First determine what type of vector to plot */ |
| 188 | for (opt = options; opt; opt = opt->next) { |
| 189 | if (opt->option != 'S') continue; /* Skip until we find -S */ |
| 190 | j = (strchr ("li", opt->arg[0])) ? 1 : 0; /* Possibly skip leading -Si or -Sl */ |
| 191 | while (opt->arg[j] && strchr (GMT_LEN_UNITS GMT_DIM_UNITS, opt->arg[j]) == NULL) j++; /* Skip digits etc until we hit first unit or end of string */ |
| 192 | if (opt->arg[j] && strchr (GMT_LEN_UNITS, opt->arg[j]) && gmt_M_is_geographic (GMT, GMT_IN)) |
| 193 | Ctrl->S.symbol = '='; /* Selected a geo-vector */ |
| 194 | else if (opt->arg[j] && strchr (GMT_DIM_UNITS, opt->arg[j])) |
| 195 | Ctrl->S.symbol = 'v'; /* Selected a Cartesian vector */ |
| 196 | else { /* No useful info, select Cartesian with a warning */ |
| 197 | GMT_Report (API, GMT_MSG_WARNING, "No units specified in -S. Selecting Cartesian vector symbol\n"); |
| 198 | Ctrl->S.symbol = 'v'; /* Selected a Cartesian vector */ |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | for (opt = options; opt; opt = opt->next) { /* Process all the options given */ |
| 203 | |
| 204 | switch (opt->option) { |
| 205 | case '<': /* Input file (only two are accepted) */ |
| 206 | Ctrl->In.active = true; |
| 207 | if (n_files >= 2) {n_errors++; continue; } |
| 208 | n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_GRID, GMT_IN, GMT_FILE_REMOTE, &(Ctrl->In.file[n_files])); |
| 209 | n_files++; |
| 210 | break; |
| 211 | |
| 212 | /* Processes program-specific parameters */ |
| 213 | |
| 214 | case 'A': /* Polar data grids */ |
| 215 | n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active); |
| 216 | n_errors += gmt_get_no_argument (GMT, opt->arg, opt->option, 0); |
| 217 | break; |
| 218 | case 'C': /* Vary symbol color with z */ |
| 219 | n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active); |
| 220 | gmt_M_str_free (Ctrl->C.file); |
| 221 | if (opt->arg[0]) Ctrl->C.file = strdup (opt->arg); |
| 222 | gmt_cpt_interval_modifier (GMT, &(Ctrl->C.file), &(Ctrl->C.dz)); |
| 223 | break; |
| 224 | case 'E': /* Center vectors [OBSOLETE; use modifier +jc in -Q ] */ |
| 225 | if (gmt_M_compat_check (GMT, 4)) { |
| 226 | GMT_Report (API, GMT_MSG_COMPAT, "Option -E is deprecated; use modifier +jc in -Q instead.\n"); |
| 227 | Ctrl->Q.S.v.status |= PSL_VEC_JUST_C; |
| 228 | } |
| 229 | else |
no test coverage detected