Skip to content

Commit

Permalink
Allow +p as per docs (#8039)
Browse files Browse the repository at this point in the history
Also clarify that +p takes optional argument [0] and allow +p with no args for setting the default.  See #7746.
  • Loading branch information
PaulWessel authored Nov 14, 2023
1 parent a9e2f39 commit 5737716
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
6 changes: 3 additions & 3 deletions doc/rst/source/gmtspatial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Synopsis
[ |-F|\ [**l**] ]
[ |-I|\ [**e**\|\ **i**] ]
[ |-L|\ *dist*\ /*noise*\ /*offset* ]
[ |-N|\ *pfile*\ [**+a**][**+i**][**+p**\ *start*][**+r**][**+z**] ]
[ |-N|\ *pfile*\ [**+a**][**+i**][**+p**\ [*start*]][**+r**][**+z**] ]
[ |-Q|\ [*unit*][**+c**\ *min*\ [/*max*]][**+h**][**+l**][**+p**][**+s**\ [**a**\|\ **d**]] ]
[ |SYN_OPT-R| ]
[ |-S|\ **b**\ *width*\|\ **h**\|\ **i**\|\ **u**\|\ **s**\|\ **j** ]
Expand Down Expand Up @@ -143,13 +143,13 @@ Optional Arguments

.. _-N:

**-N**\ *pfile*\ [**+a**][**+i**][**+p**\ *start*][**+r**][**+z**]
**-N**\ *pfile*\ [**+a**][**+i**][**+p**\ [*start*]][**+r**][**+z**]
Lines and polygons: Determine if one (or all, with **+a**) points of each feature in the
input data are inside any of the polygons given in the *pfile*. If
inside, then report which polygon it is; the polygon ID is either
taken from the aspatial value assigned to Z, the segment header
(first |-Z|, then |-L| are scanned), or it is assigned the
running number that is initialized to *start* [0]. By default the
running number that is initialized via **+p** to *start* [0]. By default the
input segments that are found to be inside a polygon are written to
standard output with the polygon ID encoded in the segment header as
**-Z**\ *ID*. Alternatively, append **+r** to just report which
Expand Down
15 changes: 6 additions & 9 deletions src/gmtspatial.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
const char *name = gmt_show_name_and_purpose (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_PURPOSE);
if (level == GMT_MODULE_PURPOSE) return (GMT_NOERROR);
GMT_Usage (API, 0, "usage: %s [<table>] [-A[a<min_dist>]] [-C] [-D[+a<amax>][+c|C<cmax>][+d<dmax>][+f<file>][+p][+s<sfact>]] [-E+n|p] "
"[-F[l]] [-I[i|e]] [-L%s/<noise>/<offset>] [-N<pfile>[+a][+i][+p<ID>][+r][+z]] [-Q[<unit>][+c<min>[/<max>]][+h][+l][+p][+s[a|d]]] [%s] "
"[-F[l]] [-I[i|e]] [-L%s/<noise>/<offset>] [-N<pfile>[+a][+i][+p[<ID>]][+r][+z]] [-Q[<unit>][+c<min>[/<max>]][+h][+l][+p][+s[a|d]]] [%s] "
"[-Sb<width>|h|i|j|s|u] [-T[<cpol>]] [-W<dist>[<unit>][+f|l]] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s]\n", name, GMT_DIST_OPT, GMT_Rgeo_OPT,
GMT_V_OPT, GMT_a_OPT, GMT_b_OPT, GMT_d_OPT, GMT_e_OPT, GMT_f_OPT, GMT_g_OPT, GMT_h_OPT, GMT_i_OPT, GMT_j_OPT, GMT_o_OPT, GMT_q_OPT, GMT_s_OPT, GMT_colon_OPT, GMT_PAR_OPT);

Expand Down Expand Up @@ -811,7 +811,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
GMT_Usage (API, 1, "\n-L%s/<noise>/<offset>", GMT_DIST_OPT);
GMT_Usage (API, -2, "Remove tile Lines. These are superfluous lines along the -R border. "
"Append <dist> (in m) [0], coordinate noise [1e-10], and max offset from gridline [1e-10].");
GMT_Usage (API, 1, "\n-N<pfile>[+a][+i][+p<ID>][+r][+z]");
GMT_Usage (API, 1, "\n-N<pfile>[+a][+i][+p[<ID>]][+r][+z]");
GMT_Usage (API, -2, "Determine ID of polygon (in <pfile>) enclosing each input feature (or point if +i). By default, "
"the ID starts at 0 and auto-increments. Alternatively, the ID is set as follows:");
GMT_Usage (API, 3, "%s If shapefile or OGR/GMT polygons, get polygon ID via -a for Z column.", GMT_LINE_BULLET);
Expand Down Expand Up @@ -1006,14 +1006,11 @@ static int parse (struct GMT_CTRL *GMT, struct GMTSPATIAL_CTRL *Ctrl, struct GMT
got_i = true; got_n++;
break;
case 'p': /* Set start of running numbers [0] */
if (txt_a[1]) {
Ctrl->N.p_set = true;
if (txt_a[1])
Ctrl->N.ID = atoi (&txt_a[1]);
Ctrl->N.p_set = true;
}
else {
GMT_Report (API, GMT_MSG_ERROR, "Option -N: Modifier +p given no value\n");
n_errors++;
}
else /* Set the default value of 0 */
Ctrl->N.ID = 0;
break;
case 'r': /* Just give a report */
Ctrl->N.mode = GMT_N_MODE_REPORT; got_n++;
Expand Down

0 comments on commit 5737716

Please sign in to comment.