Skip to content
Merged
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
11 changes: 8 additions & 3 deletions src/grdcontour.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ GMT_LOCAL void grdcontour_sort_and_plot_ticks (struct GMT_CTRL *GMT, struct PSL_
double add, dx, dy, x_back, y_back, x_front, y_front, x_end, y_end, x_lbl, y_lbl;
double xmin, xmax, ymin, ymax, inc, dist, a, this_lon, this_lat, sa, ca;
double *s = NULL, *xp = NULL, *yp = NULL;
double da, db, dc, dd;
double da, db, dc, dd, L, L_cut;

double tick_gap = I->dim[GMT_X];
double tick_length = I->dim[GMT_Y];
Expand Down Expand Up @@ -668,8 +668,13 @@ GMT_LOCAL void grdcontour_sort_and_plot_ticks (struct GMT_CTRL *GMT, struct PSL_
if (np == 0) continue;

s = gmt_M_memory (GMT, NULL, np, double); /* Compute distance along the contour */
for (j = 1, s[0] = 0.0; j < np; j++)
s[j] = s[j-1] + hypot (xp[j]-xp[j-1], yp[j]-yp[j-1]);
for (j = 1, s[0] = 0.0; j < np; j++) {
L = hypot (xp[j]-xp[j-1], yp[j]-yp[j-1]);
L_cut = gmt_half_map_width (GMT, 0.5 * (yp[j]+yp[j-1]));
if (L > L_cut) /* Eliminate horizontal jumps exceeding half mapwidth at this y-value */
L = 0.0;
s[j] = s[j-1] + L;
}
n_ticks = irint (floor (s[np-1] / tick_gap));
if (s[np-1] < GRDCONTOUR_MIN_LENGTH || n_ticks == 0) { /* Contour is too short to be ticked or labeled */
save[pol].do_it = false;
Expand Down