| 798 | } |
| 799 | |
| 800 | GMT_LOCAL void gmtplot_lineary_oblgrid (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, double w, double e, double s, double n, double dval) { |
| 801 | /* y gridlines in oblique coordinates for all but the Oblique Mercator projection [which already is oblique] */ |
| 802 | |
| 803 | double *y = NULL, *lon = NULL, *lon_obl = NULL, *lat = NULL, tval, p_cap; |
| 804 | bool cap; |
| 805 | unsigned int i, k, ny, np; |
| 806 | gmt_M_unused(PSL); gmt_M_unused(s); gmt_M_unused(n); |
| 807 | |
| 808 | /* Ideally we should determine the w/e/s/n of the oblique coordinates but here we will simply |
| 809 | * create oblique coordinates for the full 0/360/-90/90, convert to regular coordinates and |
| 810 | * then truncate points outside the actual w/e/s/n */ |
| 811 | |
| 812 | ny = gmtlib_linear_array (GMT, -M_PI_2, M_PI_2, D2R * dval, D2R * GMT->current.map.frame.axis[GMT_Y].phase, &y); |
| 813 | tval = (e - w) * GMT->current.setting.map_line_step / GMT->current.map.width; |
| 814 | np = gmtlib_linear_array (GMT, 0.0, TWO_PI, D2R * tval, 0.0, &lon_obl); |
| 815 | lon = gmt_M_memory (GMT, NULL, np+2, double); /* Allow 2 more slots for possibly inserted cap-latitudes */ |
| 816 | lat = gmt_M_memory (GMT, NULL, np+2, double); |
| 817 | for (i = 0; i < ny; i++) { |
| 818 | for (k = 0; k < np; k++) { |
| 819 | gmtlib_iobl (GMT, &lon[k], &lat[k], lon_obl[k], y[i]); /* Get regular coordinates of this point */ |
| 820 | lon[k] *= R2D; lat[k] *= R2D; /* Convert to degrees */ |
| 821 | } |
| 822 | if ((GMT->current.plot.n = gmt_geo_to_xy_line (GMT, lon, lat, np)) == 0) continue; |
| 823 | gmt_plot_line (GMT, GMT->current.plot.x, GMT->current.plot.y, GMT->current.plot.pen, GMT->current.plot.n, PSL_LINEAR); |
| 824 | } |
| 825 | if (ny) gmt_M_free (GMT, y); |
| 826 | p_cap = fabs (GMT->current.setting.map_polar_cap[0]); |
| 827 | cap = !doubleAlmostEqual (p_cap, 90.0); /* true if we have a polar cap specified */ |
| 828 | if (cap) { /* Draw the polar cap(s) with a separate spacing */ |
| 829 | p_cap = D2R * GMT->current.setting.map_polar_cap[0]; |
| 830 | for (k = 0; k < np; k++) { /* S polar cap */ |
| 831 | gmtlib_iobl (GMT, &lon[k], &lat[k], lon_obl[k], -p_cap); /* Get regular coordinates of this point */ |
| 832 | lon[k] *= R2D; lat[k] *= R2D; /* Convert to degrees */ |
| 833 | } |
| 834 | if ((GMT->current.plot.n = gmt_geo_to_xy_line (GMT, lon, lat, np)) > 0) |
| 835 | gmt_plot_line (GMT, GMT->current.plot.x, GMT->current.plot.y, GMT->current.plot.pen, GMT->current.plot.n, PSL_LINEAR); |
| 836 | for (k = 0; k < np; k++) { /* N polar cap */ |
| 837 | gmtlib_iobl (GMT, &lon[k], &lat[k], lon_obl[k], p_cap); /* Get regular coordinates of this point */ |
| 838 | lon[k] *= R2D; lat[k] *= R2D; /* Convert to degrees */ |
| 839 | } |
| 840 | if ((GMT->current.plot.n = gmt_geo_to_xy_line (GMT, lon, lat, np)) > 0) |
| 841 | gmt_plot_line (GMT, GMT->current.plot.x, GMT->current.plot.y, GMT->current.plot.pen, GMT->current.plot.n, PSL_LINEAR); |
| 842 | } |
| 843 | gmt_M_free (GMT, lon_obl); |
| 844 | gmt_M_free (GMT, lon); |
| 845 | gmt_M_free (GMT, lat); |
| 846 | } |
| 847 | |
| 848 | GMT_LOCAL void gmtplot_y_grid (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, double w, double e, double *y, unsigned int ny) { |
| 849 | unsigned int i; |
no test coverage detected