Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add longoptions support for gmtspatial. #8065

Merged
merged 8 commits into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/rst/source/gmtspatial.rst
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ Synopsis
**gmt spatial** [ *table* ]
[ |-A|\ [**a**\ *min_dist*][*unit*]]
[ |-C| ]
[ |-D|\ [**+a**\ *amax*][**+c\|C**\ *cmax*][**+d**\ *dmax*][**+f**\ *file*][**+p**][**+s**\ *fact*] ]
[ |-D|\ [**+a**\ *amax*][**+c\|C**\ *cmax*][**+d**\ *dmax*][**+f**\ *file*][**+p**][**+s**\ *factor*] ]
[ |-E|\ **+p**\|\ **n** ]
[ |-F|\ [**l**] ]
[ |-I|\ [**e**\|\ **i**] ]
6 changes: 3 additions & 3 deletions src/gmtspatial.c
Original file line number Diff line number Diff line change
@@ -766,7 +766,7 @@ GMT_LOCAL struct NN_INFO *gmtspatial_NNA_update_info (struct GMT_CTRL *GMT, stru
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[+c|C<cmax>][+d<dmax>][+f<file>][+p][+s<sfact>]] [-E+n|p] "
GMT_Usage (API, 0, "usage: %s [<table>] [-A[a<min_dist>]] [-C] [-D[+a<amax>][+c|C<cmax>][+d<dmax>][+f<file>][+p][+s<factor>]] [-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] "
"[-Sb<width>|h|s] [-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);
@@ -783,7 +783,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
"Considers 3rd column as z (if present) and 4th as w, if present [weight = 1].");
GMT_Usage (API, 1, "\n-C Clip polygons to the given region box (requires -R), possibly yielding new closed polygons. "
"For truncation instead (possibly yielding open polygons, i.e., lines), see -T.");
GMT_Usage (API, 1, "\n-D[+c|C<cmax>][+d<dmax>][+f<file>][+p][+s<sfact>]");
GMT_Usage (API, 1, "\n-D[+a<amax>][+c|C<cmax>][+d<dmax>][+f<file>][+p][+s<factor>]");
GMT_Usage (API, -2, "Look for (near-)duplicate lines or polygons. Duplicate lines have a minimum point separation less than <dmax> and a closeness "
"ratio (mean separation/length) less than <cmax>. "
"If near-duplicates have lengths that differ by <sfact> or more then they are subsets or supersets. "
@@ -795,7 +795,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
GMT_Usage (API, 3, "+d Set minimum mean point separation [0].");
GMT_Usage (API, 3, "+f Compare <table> against <file> instead of itself.");
GMT_Usage (API, 3, "+p limit comparison to points that project perpendicularly on to the other line [all points].");
GMT_Usage (API, 3, "+s Set length ratio difference threshold [2].");
GMT_Usage (API, 3, "+s Set length ratio difference threshold factor [2].");
GMT_Usage (API, 1, "\n-E+n|p");
GMT_Usage (API, -2, "Orient all polygons to have the same handedness:");
GMT_Usage (API, 3, "+n Impose clockwise (negative) handedness.");
51 changes: 21 additions & 30 deletions src/longopt/gmtspatial_inc.h
Original file line number Diff line number Diff line change
@@ -25,53 +25,44 @@ static struct GMT_KEYWORD_DICTIONARY module_kw[] = {
short_directives, long_directives,
short_modifiers, long_modifiers,
transproc_mask */
{ 0, 'A', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'C', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'D', "",
"", "",
"", "",
GMT_TP_STANDARD },
{ 0, 'E', "",
"", "",
{ 0, 'A', "nn|nearest_neighbor",
"a", "min_dist",
"", "",
GMT_TP_STANDARD },
{ 0, 'F', "",
"", "",
{ 0, 'C', "clip", "", "", "", "", GMT_TP_STANDARD },
{ 0, 'D', "duplicates",
"", "",
"a,c,C,d,f,p,s", "amax,cmax,cmin,dmax,file,perpendicular,factor",
GMT_TP_STANDARD },
{ 0, 'I', "",
"", "",
{ 0, 'E', "handedness",
"", "",
"p,n", "positive|counterclockwise,negative|clockwise",
GMT_TP_STANDARD },
{ 0, 'L', "",
"", "",
{ 0, 'F', "force_polygons",
"l", "lines",
"", "",
GMT_TP_STANDARD },
{ 0, 'N', "",
"", "",
{ 0, 'I', "intersections",
"e,i", "external,internal",
"", "",
GMT_TP_STANDARD },
{ 0, 'Q', "",
"", "",
{ 0, 'L', "no_tile_lines", "", "", "", "", GMT_TP_STANDARD },
{ 0, 'N', "in_polygons",
"", "",
"a,i,p,r,z", "all,individual,start,report,addcolumn",
GMT_TP_STANDARD },
{ 0, 'S', "",
"", "",
{ 0, 'Q', "centroid|area|length",
"", "",
"c,h,l,p,s", "range|limits,header,lines,close,sort",
GMT_TP_STANDARD },
{ 0, 'T', "",
"", "",
{ 0, 'S', "spatial",
"b,h,i,j,s,u", "buffer,hole|holes,intersection,join,dateline,union",
"", "",
GMT_TP_STANDARD },
{ 0, 'W', "",
"", "",
{ 0, 'T', "truncate", "", "", "", "", GMT_TP_STANDARD },
{ 0, 'W', "extend",
"", "",
"f,l", "first,last",
GMT_TP_STANDARD },
{ 0, '\0', "", "", "", "", "", 0 } /* End of list marked with empty option and strings */
};