| 219 | } |
| 220 | |
| 221 | static int parse (struct GMT_CTRL *GMT, struct GMTREGRESS_CTRL *Ctrl, struct GMT_OPTION *options) { |
| 222 | /* This parses the options provided to gmtregress and sets parameters in CTRL. |
| 223 | * Any GMT common options will override values set previously by other commands. |
| 224 | * It also replaces any file names specified as input or output with the data ID |
| 225 | * returned when registering these sources/destinations with the API. |
| 226 | */ |
| 227 | |
| 228 | char *c = NULL; |
| 229 | bool scan_slopes = false; |
| 230 | unsigned int n_errors = 0, j, k, n, col; |
| 231 | struct GMT_OPTION *opt = NULL; |
| 232 | struct GMTAPI_CTRL *API = GMT->parent; |
| 233 | |
| 234 | for (opt = options; opt; opt = opt->next) { |
| 235 | switch (opt->option) { |
| 236 | |
| 237 | case '<': /* Skip input files after checking they exist */ |
| 238 | if (GMT_Get_FilePath (API, GMT_IS_DATASET, GMT_IN, GMT_FILE_REMOTE, &(opt->arg))) n_errors++; |
| 239 | break; |
| 240 | case '>': /* Got named output file */ |
| 241 | n_errors += gmt_M_repeated_module_option (API, Ctrl->Out.active); |
| 242 | n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_DATASET, GMT_OUT, GMT_FILE_LOCAL, &(Ctrl->Out.file)); |
| 243 | break; |
| 244 | |
| 245 | /* Processes program-specific parameters */ |
| 246 | |
| 247 | case 'A': /* Explore E vs slope or force a limited angle range */ |
| 248 | n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active); |
| 249 | if ((c = strstr (opt->arg, "+f"))) { |
| 250 | Ctrl->A.force = true; |
| 251 | if (c[2] == 'n') Ctrl->A.max = 0.0; /* -90 to 0 */ |
| 252 | if (c[2] == 'p') Ctrl->A.min = 0.0; /* 0 to +90 */ |
| 253 | } |
| 254 | else |
| 255 | scan_slopes = true; |
| 256 | if (strchr (opt->arg, '/')) { |
| 257 | n = sscanf (opt->arg, "%lf/%lf/%lf", &Ctrl->A.min, &Ctrl->A.max, &Ctrl->A.inc); |
| 258 | n_errors += gmt_M_check_condition (GMT, n < 2, "Option -A: Must specify min/max/inc\n"); |
| 259 | } |
| 260 | break; |
| 261 | case 'C': /* Set confidence level in %, convert to fraction */ |
| 262 | n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active); |
| 263 | n_errors += gmt_get_required_double (GMT, opt->arg, opt->option, 0, &Ctrl->C.value); |
| 264 | Ctrl->C.value *= 0.01; |
| 265 | break; |
| 266 | case 'E': /* Select regression type */ |
| 267 | n_errors += gmt_M_repeated_module_option (API, Ctrl->E.active); |
| 268 | switch (opt->arg[0]) { |
| 269 | case 'x': Ctrl->E.mode = GMTREGRESS_X; break; /* Regress on x */ |
| 270 | case 'y': Ctrl->E.mode = GMTREGRESS_Y; break; /* Regress on y */ |
| 271 | case 'o': Ctrl->E.mode = GMTREGRESS_XY; break; /* Orthogonal Regression*/ |
| 272 | case 'r': Ctrl->E.mode = GMTREGRESS_RMA; break; /* RMA Regression*/ |
| 273 | default: |
| 274 | GMT_Report (API, GMT_MSG_ERROR, "Option -E: Unrecognized type %c\n", opt->arg[0]); |
| 275 | n_errors++; |
| 276 | break; |
| 277 | } |
| 278 | break; |
no test coverage detected