| 472 | } |
| 473 | |
| 474 | static int parse(struct GMT_CTRL *GMT, struct MAPPROJECT_CTRL *Ctrl, struct GMT_OPTION *options) { |
| 475 | /* This parses the options provided to mapproject and sets parameters in CTRL. |
| 476 | * Any GMT common options will override values set previously by other commands. |
| 477 | * It also replaces any file names specified as input or output with the data ID |
| 478 | * returned when registering these sources/destinations with the API. |
| 479 | */ |
| 480 | |
| 481 | unsigned int n_slash, k, n_errors = 0, pos; |
| 482 | int n; |
| 483 | bool geodetic_calc = false, will_need_RJ = false, isoldL = false, no_JR_needed; |
| 484 | char txt_a[GMT_LEN256] = {""}, txt_b[GMT_LEN256] = {""}, from[GMT_LEN256] = {""}, to[GMT_LEN256] = {""}; |
| 485 | char c, *p = NULL, *q = NULL; |
| 486 | struct GMT_OPTION *opt = NULL; |
| 487 | struct GMTAPI_CTRL *API = GMT->parent; |
| 488 | |
| 489 | for (opt = options; opt; opt = opt->next) { |
| 490 | switch (opt->option) { |
| 491 | |
| 492 | case '<': /* Skip input files */ |
| 493 | if (GMT_Get_FilePath (API, GMT_IS_DATASET, GMT_IN, GMT_FILE_REMOTE, &(opt->arg))) n_errors++; |
| 494 | break; |
| 495 | case '>': /* Got named output file */ |
| 496 | n_errors += gmt_M_repeated_module_option (API, Ctrl->Out.active); |
| 497 | n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_DATASET, GMT_OUT, GMT_FILE_LOCAL, &(Ctrl->Out.file)); |
| 498 | break; |
| 499 | |
| 500 | /* Processes program-specific parameters */ |
| 501 | |
| 502 | case 'A': |
| 503 | n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active); |
| 504 | if ((p = strstr(opt->arg, "+v"))) { /* Expect two pairs of coordinates per line for azim calculations */ |
| 505 | Ctrl->A.mode = GMT_MP_PAIR_DIST; |
| 506 | p[0] = '\0'; /* Chop off the +v string */ |
| 507 | } |
| 508 | n = sscanf (opt->arg, "%c%[^/]/%s", &c, txt_a, txt_b); |
| 509 | if (n < 1) { |
| 510 | GMT_Report (API, GMT_MSG_ERROR, "Option -A: Expected -Ab|B|f|F|o|O[<lon0>/<lat0>][+v]\n"); |
| 511 | n_errors++; |
| 512 | } |
| 513 | else { |
| 514 | switch (c) { |
| 515 | case 'B': |
| 516 | Ctrl->A.geodesic = true; |
| 517 | /* Intentionally fall through - to 'b' */ |
| 518 | case 'b': |
| 519 | Ctrl->A.reverse = true; |
| 520 | break; |
| 521 | case 'F': |
| 522 | Ctrl->A.geodesic = true; |
| 523 | /* Intentionally fall through - to 'f' */ |
| 524 | case 'f': |
| 525 | break; |
| 526 | case 'O': |
| 527 | Ctrl->A.geodesic = true; |
| 528 | /* Intentionally fall through - to 'o' */ |
| 529 | case 'o': |
| 530 | Ctrl->A.orient = true; |
| 531 | break; |
no test coverage detected