! . */
| 5599 | |
| 5600 | /*! . */ |
| 5601 | GMT_LOCAL bool gmtinit_parse_J_option (struct GMT_CTRL *GMT, char *args_in) { |
| 5602 | /* gmtinit_parse_J_option scans the arguments given and extracts the parameters needed |
| 5603 | * for the specified map projection. These parameters are passed through the |
| 5604 | * GMT->current.proj structure. The function returns true if an error is encountered. |
| 5605 | */ |
| 5606 | |
| 5607 | int i, j, k = 0, n, slash, l_pos[3], p_pos[3], t_pos[3], d_pos[3], id, project; |
| 5608 | int n_slashes = 0, last_pos = 0, error = 0; |
| 5609 | unsigned int mod_flag = 0; |
| 5610 | double c, az, GMT_units[3] = {0.01, 0.0254, 1.0}; /* No of meters in a cm, inch, m */ |
| 5611 | char mod, args_cp[GMT_BUFSIZ] = {""}, txt_a[GMT_LEN256] = {""}, txt_b[GMT_LEN256] = {""}, txt_c[GMT_LEN256] = {""}; |
| 5612 | char txt_d[GMT_LEN256] = {""}, txt_e[GMT_LEN256] = {""}, last_char = 0, *dd = NULL, *d = NULL, *args; |
| 5613 | char args_buf[GMT_LEN128] = {""}; |
| 5614 | |
| 5615 | if (args_in == NULL) { |
| 5616 | GMT_Report (GMT->parent, GMT_MSG_ERROR, "Option -J: No argument for parsing\n"); |
| 5617 | return (true); |
| 5618 | } |
| 5619 | strncpy (args_buf, args_in, GMT_LEN128); /* Must duplicate since args_in may be a static string */ |
| 5620 | args = args_buf; /* Start of arguments */ |
| 5621 | gmt_M_memset (l_pos, 3, int); gmt_M_memset (p_pos, 3, int); |
| 5622 | gmt_M_memset (t_pos, 3, int); gmt_M_memset (d_pos, 3, int); |
| 5623 | if (!GMT->common.J.active) /* Down want to clobber this during -Jz/Z after the horizontal part has been set */ |
| 5624 | GMT->current.proj.lon0 = GMT->current.proj.central_meridian = GMT->current.proj.lat0 = GMT->session.d_NaN; /* Projection center, to be set via -J */ |
| 5625 | |
| 5626 | project = gmtinit_project_type (args, &i, &GMT->common.J.width_given); |
| 5627 | if (project == GMT_NO_PROJ) return (true); /* No valid projection specified */ |
| 5628 | |
| 5629 | if (project == GMT_ZAXIS) |
| 5630 | strncpy (GMT->common.J.zstring, args, GMT_LEN128-1); /* Verbatim copy of -Jz|Z */ |
| 5631 | else |
| 5632 | strncpy (GMT->common.J.string, args, GMT_LEN128-1); /* Verbatim copy or map -J */ |
| 5633 | |
| 5634 | args += i; /* Skip to first argument */ |
| 5635 | if (GMT->common.J.width_given) { /* If given size (not scale) then we may have modifiers */ |
| 5636 | mod_flag = 1; /* Default is that size meant width */ |
| 5637 | if ((dd = strstr (args, "+d"))) { /* Specify type of size argument via modifier +d */ |
| 5638 | switch (dd[2]) { |
| 5639 | case 'l': mod_flag = 4; break; /* Want this to be the MIN (lower) dimension of map */ |
| 5640 | case 'u': mod_flag = 3; break; /* Want this to be the MAX (upper) dimension of map */ |
| 5641 | case 'h': mod_flag = 2; break; /* Want map HEIGHT instead of width */ |
| 5642 | case 'w': mod_flag = 1; break; /* Want map width [Default] */ |
| 5643 | default: |
| 5644 | GMT_Report (GMT->parent, GMT_MSG_ERROR, "Option -J: Invalid modifier %s\n", d); |
| 5645 | return (true); |
| 5646 | break; |
| 5647 | } |
| 5648 | if (project == GMT_OBLIQUE_MERC && strstr (args, "+v")) /* To guard against -JOa120W/25N/150/6i+dh+v and losing the +v */ |
| 5649 | GMT->current.proj.obl_flip = true; |
| 5650 | dd[0] = '\0'; /* Chop off this modifier */ |
| 5651 | } |
| 5652 | else { /* Backwards compatibility for trailing +,-,h */ |
| 5653 | last_pos = (int)strlen (args) - 1; /* Position of last character in this string */ |
| 5654 | last_char = args[last_pos]; |
| 5655 | if (last_pos > 0) { /* Examine trailing character for modifying behavior */ |
| 5656 | switch (last_char) { /* Check for what kind of width is given (only used if upper case is given below */ |
| 5657 | case 'h': mod_flag = 2; break; /* Want map HEIGHT instead */ |
| 5658 | case '+': mod_flag = 3; break; /* Want this to be the MAX dimension of map */ |
no test coverage detected