Skip to content

Commit 913f6b3

Browse files
authored
Fix the situation where mapproject -A was ignoring -je and uppercase directives. (#8760)
This PR also removes the F,B and O directives from documentation as way of setting ellipsoidal computations. It reminds that for it -je should be used. But code remains backward compatible. Fix #8759
1 parent 18e8e38 commit 913f6b3

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

doc/rst/source/mapproject.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Synopsis
1414

1515
**gmt mapproject** [ *table* ] |-J|\ *parameters*
1616
|SYN_OPT-R|
17-
[ |-A|\ **b**\|\ **B**\|\ **f**\|\ **F**\|\ **o**\|\ **O**\ [*lon0*/*lat0*][**+v**] ]
17+
[ |-A|\ **b**\|\ **f**\|\ **o**\ [*lon0*/*lat0*][**+v**] ]
1818
[ |-C|\ [*dx*/*dy*][**+m**] ]
1919
[ |-D|\ **c**\|\ **i**\|\ **p** ]
2020
[ |-E|\ [*datum*] ]
@@ -81,19 +81,17 @@ Optional Arguments
8181

8282
.. _-A:
8383

84-
**-Ab**\|\ **B**\|\ **f**\|\ **F**\|\ **o**\|\ **O**\ [*lon0*/*lat0*][**+v**]
84+
**-Ab**\|\ **f**\|\ **o**\ [*lon0*/*lat0*][**+v**]
8585
Calculate azimuth along track *or* to the optional *fixed* point set
8686
with *lon0/lat0*. Choose among several directives:
8787

8888
- **b** - Calculate the back-azimuth from data points to the fixed point.
8989
- **f** - Calculate the forward azimuth from the fixed point to each data point.
9090
- **o** - Get orientations (-90/90) rather than azimuths (0/360).
9191

92-
Upper case directives **F**, **B** or **O** will convert from
93-
geodetic to geocentric latitudes and estimate azimuth of geodesics
94-
(assuming the current ellipsoid is not a sphere). **Note**: If no fixed
95-
point is given then we compute the azimuth (or back-azimuth) from the
96-
previous point. One modifier is available:
92+
Use the **-je** option to compute azimuths on the ellipsoid instead of the sphere.
93+
**Note**: If no fixed point is given then we compute the azimuth (or back-azimuth) from the
94+
previous point. One modifier is available:
9795

9896
- **+v** - Obtain a *variable* 2nd point (*lon0*/*lat0*) via columns 3-4
9997
in the input file.

src/mapproject.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ static void Free_Ctrl (struct GMT_CTRL *GMT, struct MAPPROJECT_CTRL *C) { /* Dea
212212
static int usage (struct GMTAPI_CTRL *API, int level) {
213213
const char *name = gmt_show_name_and_purpose (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_PURPOSE);
214214
if (level == GMT_MODULE_PURPOSE) return (GMT_NOERROR);
215-
GMT_Usage (API, 0, "usage: %s <table> [-Ab|B|f|F|o|O[<lon0>/<lat0>][+v]] [-C[<dx></dy>][+m]] [-D%s] "
215+
GMT_Usage (API, 0, "usage: %s <table> [-Ab|f|o[<lon0>/<lat0>][+v]] [-C[<dx></dy>][+m]] [-D%s] "
216216
"[-E[<datum>]] [-F[<%s|%s>]] [-G[<lon0>/<lat0>][+a][+i][+u<unit>][+v]] [-I] [%s] [-L<table>[+p][+u<unit>]] "
217217
"[-N[a|c|g|m]] [-Q[d|e]] [%s] [-S] [-T[h]<from>[/<to>]] [%s] [-W[b|B|e|E|g|h|j|m|M|n|o|O|r|R|w|x]][+n[<nx>[/<ny>]]] [-Z[<speed>][+a][+i][+f][+t<epoch>]] "
218218
"[%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s]\n",
@@ -228,17 +228,15 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
228228
GMT_Option (API, "<");
229229

230230
GMT_Message (API, GMT_TIME_NONE, "\n OPTIONAL ARGUMENTS:\n");
231-
GMT_Usage (API, 1, "\n-Ab|B|f|F|o|O[<lon0>/<lat0>][+v]");
231+
GMT_Usage (API, 1, "\n-Ab|f|o[<lon0>/<lat0>][+v]");
232232
GMT_Usage (API, -2, "Calculate azimuths from previous point in the input data with -Af. If <lon0>/<lat0> "
233233
"is provided, then all azimuths are computed with respect to that point. Select directive:");
234234
GMT_Usage (API, 3, "b: Calculate back-azimuths from data to previous or the specified point on the sphere.");
235-
GMT_Usage (API, 3, "B: Calculate back-azimuths from data to previous or the specified point on the ellipsoid.");
236235
GMT_Usage (API, 3, "f: Calculate azimuths from data to previous or the specified point on the sphere.");
237-
GMT_Usage (API, 3, "F: Calculate back-azimuths from data to previous or the specified point on the ellipsoid.");
238236
GMT_Usage (API, 3, "o: Calculate orientations (-90/90) instead of azimuths (0/360) on the sphere.");
239-
GMT_Usage (API, 3, "O: Calculate orientations (-90/90) instead of azimuths (0/360) on the ellipsoid.");
240237
GMT_Usage (API, -2, "Append +v to obtain variable <lon0> <lat0> points from input columns 3-4 instead. "
241238
"If -R -J are given then we compute Cartesian angles after projecting the coordinates.");
239+
GMT_Usage (API, -2, "Use -je option to do the computations on the ellipsoid instead of the sphere.");
242240
GMT_Usage (API, 1, "\n-C[<dx></dy>][+m]");
243241
GMT_Usage (API, -2, "Get projected coordinates relative to projection center [Default is relative to lower left corner]. "
244242
"Optionally append <dx></dy> to add (or subtract if -I) (i.e., false easting and northing) [0/0]. "
@@ -473,7 +471,7 @@ GMT_LOCAL unsigned int mapproject_old_G_parser (struct GMT_CTRL *GMT, char *arg,
473471
return (n_errors);
474472
}
475473

476-
static int parse (struct GMT_CTRL *GMT, struct MAPPROJECT_CTRL *Ctrl, struct GMT_OPTION *options) {
474+
static int parse(struct GMT_CTRL *GMT, struct MAPPROJECT_CTRL *Ctrl, struct GMT_OPTION *options) {
477475
/* This parses the options provided to mapproject and sets parameters in CTRL.
478476
* Any GMT common options will override values set previously by other commands.
479477
* It also replaces any file names specified as input or output with the data ID
@@ -811,6 +809,16 @@ static int parse (struct GMT_CTRL *GMT, struct MAPPROJECT_CTRL *Ctrl, struct GMT
811809

812810
if (n_errors) return GMT_PARSE_ERROR; /* Might as well return here since otherwise we may get some false warnings from below as well */
813811

812+
/* -AF|B will fail if input is not detected as geog (unfortunally easy happens). On the other hand,
813+
it ignores the -j option. This patch will force the input to be recognized as geographic. And allows
814+
as to drop the upper case directives (old stuff?) in favor of -j alone.
815+
*/
816+
if (Ctrl->A.active && (Ctrl->A.geodesic || (GMT->common.j.active && GMT->common.j.mode >= GMT_GREATCIRCLE))) {
817+
GMT->current.io.col_type[GMT_IN][GMT_X] = GMT_IS_LON;
818+
GMT->current.io.col_type[GMT_IN][GMT_Y] = GMT_IS_LAT;
819+
if (GMT->common.j.mode == GMT_GEODESIC) Ctrl->A.geodesic = true; /* If -je set Ctrl->A.geodesic to avoid annoying warning */
820+
}
821+
814822
geodetic_calc = (Ctrl->G.mode || Ctrl->A.active || Ctrl->L.active);
815823
no_JR_needed = (Ctrl->A.active || Ctrl->E.active || Ctrl->G.active || Ctrl->L.active || Ctrl->N.active || Ctrl->Z.active);
816824
if (GMT->common.J.width_given) will_need_RJ = true; /* Need -R -J to convert width to scale */

0 commit comments

Comments
 (0)