From 4b45242d20a6009f67d57925aa2af2b338716fb4 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Fri, 30 Sep 2022 11:17:33 -1000 Subject: [PATCH 1/2] Ensure vector +z is nondimensional or uses unit q only See #7039 for discussion. The coding of modifier +z was expecting plot units but that makes no sense. This PR checks that either no unit or q is applied and errors otherwise. --- src/gmt_init.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gmt_init.c b/src/gmt_init.c index 07d065ce5ce..e3f56715fef 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -16485,10 +16485,24 @@ int gmt_parse_vector (struct GMT_CTRL *GMT, char symbol, char *text, struct GMT_ } } break; - case 'z': /* Input (angle,length) are vector components (dx,dy) instead */ + case 'z': /* Input (angle,length) are vector components (dx,dy) instead. Either the components are + already in plot units (and scale is nondimensional) or we append unit q to scale from + user units to plot units. */ S->v.status |= PSL_VEC_COMPONENTS; S->v.status |= PSL_VEC_MAGNIFY; - if (p[1]) error += gmtinit_get_length (GMT, symbol, &p[1], false, is_grdvector, &(S->v.comp_scale), &(S->v.v_unit_d)); + if (p[1]) { /* Got an argument [Default is 1, i.e., do nothing] */ + size_t last = strlen (p) - 1; /* Position of last character in p */ + if (p[last] == 'q') { /* User data should be scaled by -J -R */ + S->v.v_unit_d = true; + p[last] = '\0'; /* Hide the q for now */ + } + else if (strchr (GMT_DIM_UNITS GMT_LEN_UNITS, p[last])) { + GMT_Report (GMT->parent, GMT_MSG_ERROR, "Cannot supply units to a non-dimensional scale set via +z\n"); + error++; + } + S->v.comp_scale = atof (&p[1]); + if (S->v.v_unit_d) p[last] = 'q'; /* Restore q */ + } break; case 'v': /* Scale vector polar length component, or get inverse scale, or a fixed magnitude */ S->v.status |= PSL_VEC_MAGNIFY; From d01f462352fb38c8af36d541adef85fca5157a17 Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Sat, 1 Oct 2022 20:19:31 -1000 Subject: [PATCH 2/2] Update plots via dvc --- test/baseline/psxy.dvc | 4 ++-- test/baseline/psxyz.dvc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/baseline/psxy.dvc b/test/baseline/psxy.dvc index 3b53dbac3c3..15416a9b35e 100644 --- a/test/baseline/psxy.dvc +++ b/test/baseline/psxy.dvc @@ -1,5 +1,5 @@ outs: -- md5: bac31d281e71fbcedcf6ae7166ba2e5e.dir - size: 9331268 +- md5: 255d9b081a7eade814459af6e27ad83c.dir + size: 9328693 nfiles: 142 path: psxy diff --git a/test/baseline/psxyz.dvc b/test/baseline/psxyz.dvc index e0d511fc1d6..2c284b6ed82 100644 --- a/test/baseline/psxyz.dvc +++ b/test/baseline/psxyz.dvc @@ -1,5 +1,5 @@ outs: -- md5: 817364f35149dd02f20424cf38cc0f60.dir - size: 1109038 +- md5: 51618f649106cef265f348a303ef375d.dir + size: 1106463 nfiles: 26 path: psxyz