| 2159 | } |
| 2160 | |
| 2161 | GMT_LOCAL void gmtplot_map_gridticks (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, double w, double e, double s, double n) { |
| 2162 | /* Draw symmetric or asymmetric grid ticks along the courser gridlines for parallels and meridians */ |
| 2163 | bool single, point_point = false; |
| 2164 | unsigned int i, j, k, nx, ny, G_nx, G_ny, G_i, G_j, B = 0, E = 0, item[2] = {GMT_GRID_UPPER, GMT_GRID_LOWER}; |
| 2165 | double x0, y0, xa, xb, ya, yb, xi, yj, *x = NULL, *y = NULL, *G_x = NULL, *G_y = NULL; |
| 2166 | double angle, Ca, Sa, L, sgn[2] = {1.0, 0.0}, G_dx, G_dy, dx, dy, ys, yn; |
| 2167 | |
| 2168 | for (k = i = 0; k < 2; k++) |
| 2169 | if (GMT->current.setting.map_grid_cross_type[k] > GMT_CROSS_NORMAL) i++; |
| 2170 | |
| 2171 | if (i == 0) return; /* No gridline ticks requested */ |
| 2172 | |
| 2173 | if (gmtplot_get_current_gridlines (GMT, &G_dx, &G_dy)) { |
| 2174 | GMT_Report (GMT->parent, GMT_MSG_ERROR, "Gridline tick embellishments specified but no gridlines have been laid down first\n"); |
| 2175 | return; |
| 2176 | } |
| 2177 | |
| 2178 | if (gmt_M_pole_is_point (GMT)) { /* Might have two separate domains of gridlines */ |
| 2179 | point_point = true; |
| 2180 | if (GMT->current.proj.projection_GMT == GMT_POLAR) { /* Different for polar graphs since "lat" = 0 is at the center */ |
| 2181 | ys = 90.0 - GMT->current.setting.map_polar_cap[0]; |
| 2182 | yn = n; |
| 2183 | } |
| 2184 | else { |
| 2185 | ys = MAX (s, -GMT->current.setting.map_polar_cap[0]); |
| 2186 | yn = MIN (n, GMT->current.setting.map_polar_cap[0]); |
| 2187 | } |
| 2188 | } |
| 2189 | else { /* No polar cap to worry about */ |
| 2190 | ys = s; |
| 2191 | yn = n; |
| 2192 | } |
| 2193 | /* Get the course gridline spacings */ |
| 2194 | G_nx = gmtlib_linear_array (GMT, w, e, G_dx, 0.0, &G_x); |
| 2195 | G_ny = gmtlib_linear_array (GMT, ys, yn, G_dy, 0.0, &G_y); |
| 2196 | |
| 2197 | gmt_map_clip_on (GMT, GMT->session.no_rgb, 3); |
| 2198 | |
| 2199 | for (k = 0; k < 2; k++) { |
| 2200 | if (gmt_M_is_zero (GMT->current.setting.map_grid_cross_size[k])) continue; |
| 2201 | |
| 2202 | PSL_comment (PSL, "%s\n", k ? "Map gridticks (secondary)" : "Map gridticks (primary)"); |
| 2203 | |
| 2204 | gmt_setpen (GMT, &GMT->current.setting.map_grid_pen[k]); |
| 2205 | |
| 2206 | /* Get the detailed gridline tick spacings */ |
| 2207 | nx = gmtlib_coordinate_array (GMT, w, e, &GMT->current.map.frame.axis[GMT_X].item[item[k]], &x, NULL); |
| 2208 | ny = gmtlib_coordinate_array (GMT, ys, yn, &GMT->current.map.frame.axis[GMT_Y].item[item[k]], &y, NULL); |
| 2209 | /* Get a small increment in x and y for computing local angle */ |
| 2210 | dy = (ny > 1) ? y[1] - y[0] : GMT->current.map.dlat; |
| 2211 | dx = (nx > 1) ? x[1] - x[0] : GMT->current.map.dlon; |
| 2212 | |
| 2213 | L = 0.5 * fabs (GMT->current.setting.map_grid_cross_size[k]); |
| 2214 | |
| 2215 | for (G_j = 0; G_j < G_ny; G_j++) { /* For each gridline parallel */ |
| 2216 | yj = G_y[G_j]; /* Current parallel */ |
| 2217 | single = (gmt_M_pole_is_point(GMT) && doubleAlmostEqualZero (fabs (yj), 90.0)); /* Only place one grid tick at the poles for maps where the poles are points */ |
| 2218 | if (gmt_M_pole_is_point(GMT) && doubleAlmostEqualZero (fabs (yj), 90.0)) continue; /* No grid tick at single pole points */ |
no test coverage detected