! . */
| 10177 | |
| 10178 | /*! . */ |
| 10179 | unsigned int gmt_parse_segmentize (struct GMT_CTRL *GMT, char option, char *in_arg, unsigned int mode, struct GMT_SEGMENTIZE *S) { |
| 10180 | /* Parse segmentizing options in gmt convert (mode == 0) or psxy (mode == 1). |
| 10181 | * Syntax is given below (assuming option = -F here): |
| 10182 | * -F<scheme><method: i.e., -F[c|n|p[<origin>|v][a|r|s|t] or -Fp<origin> |
| 10183 | * where <scheme> is c = continuous [Default], n = network, r = reference point, and v = vectors. |
| 10184 | * and impact is a = all tables, t = per table, s = per segment [Default], r = per record. |
| 10185 | * Four different segmentizing schemes: |
| 10186 | * 1) -Fc: Continuous lines. By default, lines are drawn on a segment by segment basis. |
| 10187 | * Thus, -F or -Fc or -Fcs or -Fs is the standard default. However, if we use |
| 10188 | * -Fcf or -Ff then we ignore segment headers WITHIN each file, except for the first header |
| 10189 | * in each file. In other words, all points in a file will be considered continuous. |
| 10190 | * Finally, using -Fca or -Fa then all points in all fields are considered continuous and |
| 10191 | * only the first segment header in the first file is considered. So only a|f|r is allowed. |
| 10192 | * 2) -Fn: Network. For each group of points we connect each point with every other point. |
| 10193 | * The modifiers a,f,s control what the "group" is. With s, we construct a separate |
| 10194 | * network for each segment, with f we group all segments in a file and construct a |
| 10195 | * network for all those points, while with a with consider all points in the dataset |
| 10196 | * to be one group. So only a|t|s is allowed. |
| 10197 | * 3) -Fp: Ref point. Here, we construct line segments from the given reference point to |
| 10198 | * each of the points in the file. If refpoint is given as two slash-separated coordinates |
| 10199 | * then the refpoint is fixed throughout this construction. However, refpoint may also be |
| 10200 | * given as a, f, s and if so we pick the first point in the dataset, or first point in each |
| 10201 | * file, or the first point in each segment to update the actual reference point. |
| 10202 | * 4) -Fv: Vectorize. Here, consecutive points are turned into vector segments such as used |
| 10203 | * by gmt plot -Sv+s or external applications. Again, appending a|s|t controls if we should |
| 10204 | * honor the segment headers [Default is -Fvs if -Fv is given]. Only a|t|s is allowed in plot. |
| 10205 | */ |
| 10206 | |
| 10207 | unsigned int k, errors = 0; |
| 10208 | switch (in_arg[0]) { /* First set method */ |
| 10209 | case 'c': k = 1; S->method = SEGM_CONTINUOUS; break; |
| 10210 | case 'n': k = 1; S->method = SEGM_NETWORK; break; |
| 10211 | case 'p': case 'r': k = 1; S->method = SEGM_REFPOINT; break; /* Backwards support for r for refpoint, now p for point */ |
| 10212 | case 'v': k = 1; S->method = SEGM_VECTOR; break; |
| 10213 | default: k = 0; S->method = SEGM_CONTINUOUS; break; |
| 10214 | } |
| 10215 | |
| 10216 | switch (in_arg[k]) { /* Now set level */ |
| 10217 | case 's': case '\0': S->level = SEGM_SEGMENT; break; /* Default is segment */ |
| 10218 | case 'a': S->level = SEGM_DATASET; break; |
| 10219 | case 't': case 'f': S->level = SEGM_TABLE; break; /* Backwards compatibility for f(ile) */ |
| 10220 | case 'r': S->level = SEGM_RECORD; break; |
| 10221 | default: /* Must be a reference point but only if method is refpoint */ |
| 10222 | if (S->method == SEGM_REFPOINT && strchr (in_arg, '/')) { /* Gave arguments for an origin */ |
| 10223 | S->level = SEGM_ORIGIN; |
| 10224 | if ((k = gmt_get_pair (GMT, &in_arg[k], GMT_PAIR_COORD, S->origin)) < 2) errors++; |
| 10225 | } |
| 10226 | else { |
| 10227 | GMT_Report (GMT->parent, GMT_MSG_ERROR, "Option -%c: Expected reference point coordinates but got this: %s\n", option, &in_arg[k]); |
| 10228 | errors++; |
| 10229 | } |
| 10230 | break; |
| 10231 | } |
| 10232 | if (S->method == SEGM_CONTINUOUS && S->level == SEGM_SEGMENT) { |
| 10233 | GMT_Report (GMT->parent, GMT_MSG_ERROR, "Option -%c: Selecting -Fc, -Fs, or -Fcs yields no change\n", option); |
| 10234 | errors++; |
| 10235 | } |
| 10236 | if (S->method != SEGM_REFPOINT && S->level == SEGM_RECORD) { |
no test coverage detected