Skip to content

Commit d8ebeef

Browse files
authored
Ensure small circle vector lengths can use map units (#6168)
See #6166 for background. This PR fixes mistakes in both plot and plot3 where the case for small circle and length was not considered. Instead of adding a new test I simpy added k to the values in smallcirclevec.sh and changed one to be in meters. All tests work as before plus the problem was fixed. Closes #6166.
1 parent 00b8889 commit d8ebeef

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

src/psxy.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,8 +1366,14 @@ EXTERN_MSC int GMT_psxy (void *V_API, int mode, void *args) {
13661366
bcol = (S.read_size) ? ex2 : ex1;
13671367
if (S.symbol == GMT_SYMBOL_BARX && (S.base_set & GMT_BASE_READ)) gmt_set_column_type (GMT, GMT_IN, bcol, gmt_M_type (GMT, GMT_IN, GMT_X));
13681368
if (S.symbol == GMT_SYMBOL_BARY && (S.base_set & GMT_BASE_READ)) gmt_set_column_type (GMT, GMT_IN, bcol, gmt_M_type (GMT, GMT_IN, GMT_Y));
1369-
if (S.symbol == GMT_SYMBOL_GEOVECTOR && (S.v.status & PSL_VEC_JUST_S) == 0)
1370-
gmt_set_column_type (GMT, GMT_IN, ex2, GMT_IS_GEODIMENSION);
1369+
if (S.symbol == GMT_SYMBOL_GEOVECTOR && (S.v.status & PSL_VEC_JUST_S) == 0) { /* Input is either azim,length or just length for small circle vectors */
1370+
if (S.v.status & PSL_VEC_POLE) { /* Small circle distance is either map length or start,stop angles */
1371+
if ((S.v.status & PSL_VEC_ANGLES) == 0) /* Just map length */
1372+
gmt_set_column_type (GMT, GMT_IN, ex1, GMT_IS_GEODIMENSION);
1373+
}
1374+
else /* Great circle map length */
1375+
gmt_set_column_type (GMT, GMT_IN, ex2, GMT_IS_GEODIMENSION);
1376+
}
13711377
else if ((S.symbol == PSL_ELLIPSE || S.symbol == PSL_ROTRECT) && S.convert_angles && !S.par_set) {
13721378
if (S.n_required == 1)
13731379
gmt_set_column_type (GMT, GMT_IN, ex1, GMT_IS_GEODIMENSION);

src/psxyz.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,8 +1044,14 @@ EXTERN_MSC int GMT_psxyz (void *V_API, int mode, void *args) {
10441044
}
10451045
gmt_set_meminc (GMT, GMT_BIG_CHUNK); /* Only a sizeable amount of PSXZY_DATA structures when we initially allocate */
10461046
GMT->current.map.is_world = !(S.symbol == PSL_ELLIPSE && S.convert_angles);
1047-
if (S.symbol == GMT_SYMBOL_GEOVECTOR && (S.v.status & PSL_VEC_JUST_S) == 0)
1048-
gmt_set_column_type (GMT, GMT_IN, ex2, GMT_IS_GEODIMENSION);
1047+
if (S.symbol == GMT_SYMBOL_GEOVECTOR && (S.v.status & PSL_VEC_JUST_S) == 0) { /* Input is either azim,length or just length for small circle vectors */
1048+
if (S.v.status & PSL_VEC_POLE) { /* Small circle distance is either map length or start,stop angles */
1049+
if ((S.v.status & PSL_VEC_ANGLES) == 0) /* Just map length */
1050+
gmt_set_column_type (GMT, GMT_IN, ex1, GMT_IS_GEODIMENSION);
1051+
}
1052+
else /* Great circle map length */
1053+
gmt_set_column_type (GMT, GMT_IN, ex2, GMT_IS_GEODIMENSION);
1054+
}
10491055
else if ((S.symbol == PSL_ELLIPSE || S.symbol == PSL_ROTRECT) && S.convert_angles && !S.par_set) {
10501056
if (S.n_required == 1) {
10511057
gmt_set_column_type (GMT, GMT_IN, ex1, GMT_IS_GEODIMENSION);

test/psxy/smallcirvec.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ ps=smallcirvec.ps
66
gmt set PROJ_ELLIPSOID Sphere
77
# Vector from point with head at end
88
cat << EOF > t.txt
9-
0 0 8000 red 0 45 b+e+b
10-
-30 0 6000 green -30 -30 e+e+b
11-
30 30 6000 blue 10 10 c+e+b
12-
-10 0 6671.7 yellow 80 0 c+e+b
9+
0 0 8000k red 0 45 b+e+b
10+
-30 0 6000k green -30 -30 e+e+b
11+
30 30 6000000e blue 10 10 c+e+b
12+
-10 0 6671.7k yellow 80 0 c+e+b
1313
EOF
1414
gmt psbasemap -Rg -JG0/0/4.5i -Bag -P -K -Xc > $ps
1515
while read lon lat length color plon plat just; do

0 commit comments

Comments
 (0)