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

WIP Ensure vector +z is nondimensional or uses unit q only #7047

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 16 additions & 2 deletions src/gmt_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -16535,10 +16535,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;
Expand Down