MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / gmt_plot_grid_graticules

Function gmt_plot_grid_graticules

src/gmt_plot.c:10860–10937  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10858}
10859
10860void gmt_plot_grid_graticules (struct GMT_CTRL *GMT, struct GMT_GRID *G, struct GMT_GRID *I, struct GMT_PALETTE *P, struct GMT_PEN *pen, bool skip, double *intensity, bool grdview) {
10861 /* Lay down an image from a grid using polygons of the graticules. This is recoded from grdview
10862 * so it can also be used in grdimage.
10863 * G is the data grid
10864 * I is an optional intensity grid. If NULL then either intensity points to a
10865 * constant intensity or it is also NULL, meaning no intensity adjustment for colors.
10866 * P is the CPT in use for fills
10867 * pen is an optional pen for drawing the graticules, or NULL
10868 * skip determines if we paint NaN polygons or not
10869 * intensity is pointer to a constant intensity or NULL.
10870 */
10871 openmp_int row, col;
10872 uint64_t ij, n;
10873 int outline = 0;
10874 bool delay_outline = false;
10875 double *xx = NULL, *yy = NULL, inc2[2] = {0.0, 0.0};
10876 struct GMT_FILL fill;
10877 struct GMT_DATASEGMENT *S = gmt_get_segment (GMT, 2);
10878 gmt_init_fill (GMT, &fill, -1.0, -1.0, -1.0); /* Initialize fill structure */
10879
10880 GMT_Report (GMT->parent, GMT_MSG_INFORMATION, "Tiling grid without interpolation\n");
10881
10882 inc2[GMT_X] = 0.5 * G->header->inc[GMT_X]; inc2[GMT_Y] = 0.5 * G->header->inc[GMT_Y];
10883 if (pen) { /* Want to outline each graticule with given pen */
10884 if (gmt_M_is_zero (pen->rgb[3])) { /* No transparency, use the pen as is while painting polygons */
10885 gmt_setpen (GMT, pen);
10886 outline = 1;
10887 }
10888 else { /* Pen has transparency so do lines separately */
10889 delay_outline = true;
10890 outline = 0;
10891 }
10892 }
10893 S->data = gmt_M_memory (GMT, NULL, 2, double *);
10894 S->n_columns = 2;
10895 gmt_M_grd_loop (GMT, G, row, col, ij) { /* Compute rgb for each pixel */
10896 if (gmt_M_is_fnan (G->data[ij]) && skip) continue;
10897 if (I && skip && gmt_M_is_fnan (I->data[ij])) continue;
10898 gmt_get_fill_from_z (GMT, P, G->data[ij], &fill);
10899 if (I)
10900 gmt_illuminate (GMT, I->data[ij], fill.rgb);
10901 else if (intensity)
10902 gmt_illuminate (GMT, *intensity, fill.rgb);
10903 n = gmt_graticule_path (GMT, &xx, &yy, 1, true, G->x[col] - inc2[GMT_X], G->x[col] + inc2[GMT_X], G->y[row] - inc2[GMT_Y], G->y[row] + inc2[GMT_Y]);
10904 gmt_setfill (GMT, &fill, outline);
10905 if (GMT->current.proj.three_D && grdview) { /* Deal with grdview */
10906 uint64_t k;
10907 double xp, yp;
10908 for (k = 0; k < n; k++) {
10909 gmt_geoz_to_xy (GMT, xx[k], yy[k], G->data[ij], &xp, &yp);
10910 xx[k] = xp; yy[k] = yp;
10911 }
10912 PSL_plotpolygon (GMT->PSL, xx, yy, n);
10913 }
10914 else { /* 2-D, most likely grdimage w/wo -p */
10915 S->data[GMT_X] = xx; S->data[GMT_Y] = yy; S->n_rows = n;
10916 gmt_geo_polygons (GMT, S);
10917 }

Callers 2

GMT_grdviewFunction · 0.85
GMT_grdimageFunction · 0.85

Calls 12

gmt_get_segmentFunction · 0.85
gmt_init_fillFunction · 0.85
GMT_ReportFunction · 0.85
gmt_setpenFunction · 0.85
gmt_get_fill_from_zFunction · 0.85
gmt_illuminateFunction · 0.85
gmt_graticule_pathFunction · 0.85
gmt_setfillFunction · 0.85
gmt_geoz_to_xyFunction · 0.85
PSL_plotpolygonFunction · 0.85
gmt_geo_polygonsFunction · 0.85
gmt_free_segmentFunction · 0.85

Tested by

no test coverage detected