From 0a3828443185d74642c6bc81c85cbeca1518b07e Mon Sep 17 00:00:00 2001 From: Esteban82 Date: Mon, 29 Jun 2026 19:03:54 -0300 Subject: [PATCH 1/2] Update docs --- doc/rst/source/inset.rst | 5 ++++- doc/rst/source/psbasemap.rst | 5 +++-- src/gmt_init.c | 1 + src/gmt_support.c | 16 +++++++++++++--- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/doc/rst/source/inset.rst b/doc/rst/source/inset.rst index d7e552e0cc3..0382145765b 100644 --- a/doc/rst/source/inset.rst +++ b/doc/rst/source/inset.rst @@ -48,11 +48,14 @@ Required Arguments (begin mode) .. _-D: -**-D**\ *xmin/xmax/ymin/ymax*\ [**+r**][**+u**\ *unit*]] \| **-D**\ [**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\ **+w**\ *width*\ [/*height*][**+j**\ *justify*][**+o**\ *dx*\ [/*dy*]] +**-D**\ *xmin/xmax/ymin/ymax*\ [**+r**][**+u**\ *unit*]] \| **-D**\ [**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ [*refpoint*]\ **+w**\ *width*\ [/*height*][**+j**\ *justify*][**+o**\ *dx*\ [/*dy*]] Define the map inset rectangle on the map. Specify the rectangle in one of three ways: .. include:: explain_refpoint.rst_ + If *refpoint* is omitted, the map inset is placed by default in the upper-left corner of the map + (using **jTL**). + Alternatively, Give *west/east/south/north* of geographic rectangle bounded by parallels and meridians; append **+r** if the coordinates instead are the lower left and upper right corners of the desired rectangle. (Or, give *xmin/xmax/ymin/ymax* diff --git a/doc/rst/source/psbasemap.rst b/doc/rst/source/psbasemap.rst index eb0a21ae2c9..07e217f81d1 100644 --- a/doc/rst/source/psbasemap.rst +++ b/doc/rst/source/psbasemap.rst @@ -41,7 +41,7 @@ Synopsis .. _-D: -**-D**\ *xmin/xmax/ymin/ymax*\ [**+r**][**+s**\ *file*][**+t**][**+u**\ *unit*]\ \| **-D**\ [**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\ **+w**\ *width*\ [/*height*][**+j**\ *justify*][**+o**\ *dx*\ [/*dy*]][**+s**\ *file*][**+t**] +**-D**\ *xmin/xmax/ymin/ymax*\ [**+r**][**+s**\ *file*][**+t**][**+u**\ *unit*]\ \| **-D**\ [**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ [*refpoint*]\ **+w**\ *width*\ [/*height*][**+j**\ *justify*][**+o**\ *dx*\ [/*dy*]][**+s**\ *file*][**+t**] Draw a simple map inset box on the map. Requires |-F|. Specify the box in one of three ways: (a) Give *west/east/south/north* of geographic rectangle bounded by parallels and meridians; append **r** if the coordinates instead are the lower left and @@ -51,7 +51,8 @@ Synopsis (1) Use **-Dg** for map (user) coordinates, (2) use **-Dj** or **-DJ** for setting *refpoint* via a 2-char justification code that refers to the (invisible) map domain rectangle, (3) use **-Dn** for normalized (0-1) coordinates, or (4) use **-Dx** for plot coordinates - (inches, cm, etc.). + (inches, cm, etc.). If *refpoint* is omitted, the map inset is placed by default in the + upper-left corner of the map (using **jTL**). Append **+w**\ *width*\ [/*height*] of bounding rectangle or box in plot coordinates (inches, cm, etc.). By default, the anchor point on the scale is assumed to be the bottom left corner (BL), but this can be changed by appending **+j** followed by a 2-char justification code *justify* (see :doc:`pstext`). diff --git a/src/gmt_init.c b/src/gmt_init.c index f78022483e5..e43be576f6c 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -8905,6 +8905,7 @@ void gmt_mapinset_syntax (struct GMT_CTRL *GMT, char option, char *string) { gmt_refpoint_syntax (GMT, "D", NULL, GMT_ANCHOR_INSET, 1); GMT_Usage (API, 3, "Append +w[]/[] of bounding rectangle ( is a unit from %s).", GMT_DIM_UNITS_DISPLAY); gmt_refpoint_syntax (GMT, "D", NULL, GMT_ANCHOR_INSET, 2); + GMT_Usage (API, -2, "If is omitted, the inset defaults to the top-left corner inside the map frame (using jTL)."); if (GMT->current.setting.run_mode == GMT_CLASSIC) { GMT_Usage (API, 2, "Append +s to save inset lower left corner and dimensions to ."); GMT_Usage (API, 2, "Append +t to translate plot origin to the lower left corner of the inset."); diff --git a/src/gmt_support.c b/src/gmt_support.c index 07ddd9f631c..7568db72b1a 100644 --- a/src/gmt_support.c +++ b/src/gmt_support.c @@ -13953,8 +13953,9 @@ bool gmt_x_is_outside (struct GMT_CTRL *GMT, double *x, double left, double righ int gmt_getinset (struct GMT_CTRL *GMT, char option, char *in_text, struct GMT_MAP_INSET *B) { /* Parse the map inset option, which comes in two flavors: * 1) -D[+r][+s][+u] - * 2) -Dg|j|J|n|x+w[][/[]][+j][+o[/]][+s] + * 2) -Dg|j|J|n|x[]+w[][/[]][+j][+o[/]][+s] * Note: the [+s] is only valid in classic mode (via psbasemap) + * If (and its g|j|J|n|x code) is entirely omitted, we default to jTL (Top-Left inside) * * For backwards compatibility we also check the deprecated form of (1): * [] @@ -13976,12 +13977,21 @@ int gmt_getinset (struct GMT_CTRL *GMT, char option, char *in_text, struct GMT_M /* Determine if we got an reference point or a region */ - if (strchr (GMT_REFPOINT_CODES, text[0])) { /* Did the reference point thing. */ + /* Inject default reference point (jTL) if omitted by user --- */ + char refpoint_str[GMT_LEN256]; + char *parse_text = text; + /* If the user omitted the reference point (e.g., -D+w5c), inject a default one (jTL = Top-Left inside) */ + if (text[0] == '+' || text[0] == '\0') { + snprintf (refpoint_str, GMT_LEN256-1, "jTL%s", text); + parse_text = refpoint_str; + } + + if (strchr (GMT_REFPOINT_CODES, parse_text[0])) { /* Did the reference point thing. */ /* Syntax is -Dg|j|J|n|x+w[/][+j][+o[/]][+s], with +s only in classic mode */ unsigned int last; char *q[2] = {NULL, NULL}; size_t len; - if ((B->refpoint = gmt_get_refpoint (GMT, text, option)) == NULL) { + if ((B->refpoint = gmt_get_refpoint (GMT, parse_text, option)) == NULL) { GMT_Report (GMT->parent, GMT_MSG_ERROR, "Option -%c: Map inset reference point was not accepted\n", option); gmt_refpoint_syntax (GMT, "D", NULL, GMT_ANCHOR_INSET, 1); return (1); /* Failed basic parsing */ From 438b57ecee15a396caa4b178295b31669ce29f57 Mon Sep 17 00:00:00 2001 From: Esteban82 Date: Tue, 30 Jun 2026 10:08:44 -0300 Subject: [PATCH 2/2] Change TL to TR --- doc/rst/source/inset.rst | 4 ++-- doc/rst/source/psbasemap.rst | 2 +- src/gmt_init.c | 2 +- src/gmt_support.c | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/rst/source/inset.rst b/doc/rst/source/inset.rst index 0382145765b..8e0138c41e5 100644 --- a/doc/rst/source/inset.rst +++ b/doc/rst/source/inset.rst @@ -53,8 +53,8 @@ Required Arguments (begin mode) .. include:: explain_refpoint.rst_ - If *refpoint* is omitted, the map inset is placed by default in the upper-left corner of the map - (using **jTL**). + If *refpoint* is omitted, the map inset is placed by default in the upper-right corner of the map + (using **jTR**). Alternatively, Give *west/east/south/north* of geographic rectangle bounded by parallels and meridians; append **+r** if the coordinates instead are the lower left and diff --git a/doc/rst/source/psbasemap.rst b/doc/rst/source/psbasemap.rst index 07e217f81d1..f63ec31785b 100644 --- a/doc/rst/source/psbasemap.rst +++ b/doc/rst/source/psbasemap.rst @@ -52,7 +52,7 @@ Synopsis a 2-char justification code that refers to the (invisible) map domain rectangle, (3) use **-Dn** for normalized (0-1) coordinates, or (4) use **-Dx** for plot coordinates (inches, cm, etc.). If *refpoint* is omitted, the map inset is placed by default in the - upper-left corner of the map (using **jTL**). + upper-right corner of the map (using **jTR**). Append **+w**\ *width*\ [/*height*] of bounding rectangle or box in plot coordinates (inches, cm, etc.). By default, the anchor point on the scale is assumed to be the bottom left corner (BL), but this can be changed by appending **+j** followed by a 2-char justification code *justify* (see :doc:`pstext`). diff --git a/src/gmt_init.c b/src/gmt_init.c index e43be576f6c..4bae4ac294c 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -8905,7 +8905,7 @@ void gmt_mapinset_syntax (struct GMT_CTRL *GMT, char option, char *string) { gmt_refpoint_syntax (GMT, "D", NULL, GMT_ANCHOR_INSET, 1); GMT_Usage (API, 3, "Append +w[]/[] of bounding rectangle ( is a unit from %s).", GMT_DIM_UNITS_DISPLAY); gmt_refpoint_syntax (GMT, "D", NULL, GMT_ANCHOR_INSET, 2); - GMT_Usage (API, -2, "If is omitted, the inset defaults to the top-left corner inside the map frame (using jTL)."); + GMT_Usage (API, -2, "If is omitted, the inset defaults to the top-right corner inside the map frame (using jTR)."); if (GMT->current.setting.run_mode == GMT_CLASSIC) { GMT_Usage (API, 2, "Append +s to save inset lower left corner and dimensions to ."); GMT_Usage (API, 2, "Append +t to translate plot origin to the lower left corner of the inset."); diff --git a/src/gmt_support.c b/src/gmt_support.c index 7568db72b1a..c8770ae4c7d 100644 --- a/src/gmt_support.c +++ b/src/gmt_support.c @@ -13955,7 +13955,7 @@ int gmt_getinset (struct GMT_CTRL *GMT, char option, char *in_text, struct GMT_M * 1) -D[+r][+s][+u] * 2) -Dg|j|J|n|x[]+w[][/[]][+j][+o[/]][+s] * Note: the [+s] is only valid in classic mode (via psbasemap) - * If (and its g|j|J|n|x code) is entirely omitted, we default to jTL (Top-Left inside) + * If (and its g|j|J|n|x code) is entirely omitted, we default to jTR (Top-Right inside) * * For backwards compatibility we also check the deprecated form of (1): * [] @@ -13977,12 +13977,12 @@ int gmt_getinset (struct GMT_CTRL *GMT, char option, char *in_text, struct GMT_M /* Determine if we got an reference point or a region */ - /* Inject default reference point (jTL) if omitted by user --- */ + /* Inject default reference point (jTR) if omitted by user --- */ char refpoint_str[GMT_LEN256]; char *parse_text = text; - /* If the user omitted the reference point (e.g., -D+w5c), inject a default one (jTL = Top-Left inside) */ + /* If the user omitted the reference point (e.g., -D+w5c), inject a default one (jTR = Top-Right inside) */ if (text[0] == '+' || text[0] == '\0') { - snprintf (refpoint_str, GMT_LEN256-1, "jTL%s", text); + snprintf (refpoint_str, GMT_LEN256-1, "jTR%s", text); parse_text = refpoint_str; }