Skip to content

Commit ac580b2

Browse files
authored
plot: fix line not plotted in polar projection (#8984)
Fix #878 Curiosity. This one was fixed by Claude during today's advisory board meeting
1 parent ca5130f commit ac580b2

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/gmt_map.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ GMT_LOCAL unsigned int gmtmap_wesn_crossing (struct GMT_CTRL *GMT, double lon0,
799799
* entirely outside the region but still cut through it, we first find all possible candidates and then decide
800800
* which ones are valid crossings. We may find 0, 1, or 2 intersections */
801801

802-
unsigned int n = 0, i;
802+
unsigned int n = 0, i, j;
803803
double d, x0, y0;
804804

805805
/* If wrapping is allowed: first bring both points between W and E boundaries,
@@ -883,6 +883,21 @@ GMT_LOCAL unsigned int gmtmap_wesn_crossing (struct GMT_CTRL *GMT, double lon0,
883883

884884
if (n == 0) return (0);
885885

886+
/* Discard crossings on boundaries that are not real edges (e.g., the pole in
887+
* polar projections where edge[0]=false, or a pole-enclosing boundary in many
888+
* geographic projections). Must happen before corner checks below. See #878. */
889+
for (i = j = 0; i < n; i++) {
890+
if (sides[i] < 4 && !GMT->current.proj.edge[sides[i]]) continue; /* Skip non-edge */
891+
if (j < i) {
892+
clon[j] = clon[i]; clat[j] = clat[i];
893+
sides[j] = sides[i];
894+
}
895+
j++;
896+
}
897+
n = j;
898+
899+
if (n == 0) return (0);
900+
886901
for (i = 0; i < n; i++) {
887902
gmt_geo_to_xy (GMT, clon[i], clat[i], &xx[i], &yy[i]);
888903
if (GMT->current.proj.projection_GMT == GMT_POLAR && sides[i]%2) sides[i] = 4 - sides[i]; /* toggle 1 <-> 3 */

0 commit comments

Comments
 (0)