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

Function gmtplot_map_latline

src/gmt_plot.c:596–636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

594}
595
596GMT_LOCAL void gmtplot_map_latline (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, double lat, double west, double east) /* Draws a line of constant latitude */ {
597 uint64_t nn;
598 double *llon = NULL, *llat = NULL;
599#ifdef DEBUG
600 uint64_t k;
601 FILE *fp = NULL;
602 char name[GMT_LEN64] = {""};
603 if (GMT->hidden.gridline_debug && (GMT->hidden.gridline_kind == 'x' || GMT->hidden.gridline_val != lat)) return;
604#endif
605 nn = gmtlib_latpath (GMT, lat, west, east, &llon, &llat);
606#ifdef DEBUG
607 if (GMT->hidden.gridline_debug) {
608 snprintf (name, GMT_LEN64, "gridline_y_%g_ll.txt", lat);
609 fp = fopen (name, "w");
610 for (k = 0; k < nn; k++) fprintf (fp, "%g\t%g\n", llon[k], llat[k]);
611 fclose (fp);
612 }
613#endif
614 GMT->current.plot.n = gmt_geo_to_xy_line (GMT, llon, llat, nn);
615#ifdef DEBUG
616 if (GMT->hidden.gridline_debug) {
617 snprintf (name, GMT_LEN64, "gridline_y_%g_xy.txt", lat);
618 fp = fopen (name, "w");
619 for (k = 0; k < GMT->current.plot.n; k++) fprintf (fp, "%g\t%g\t%d\n", GMT->current.plot.x[k], GMT->current.plot.y[k], GMT->current.plot.pen[k]);
620 fclose (fp);
621 }
622#endif
623
624 if (GMT->current.plot.n > 1) { /* Need at least 2 points for a line */
625 PSL_comment (PSL, "Lat = %g\n", lat);
626 if (GMT->current.map.parallel_straight) { /* Simplify to a 2-point straight line */
627 GMT->current.plot.x[1] = GMT->current.plot.x[GMT->current.plot.n-1];
628 GMT->current.plot.y[1] = GMT->current.plot.y[GMT->current.plot.n-1];
629 GMT->current.plot.pen[1] = GMT->current.plot.pen[GMT->current.plot.n-1];
630 GMT->current.plot.n = 2;
631 }
632 gmt_plot_line (GMT, GMT->current.plot.x, GMT->current.plot.y, GMT->current.plot.pen, GMT->current.plot.n, PSL_LINEAR);
633 }
634 gmt_M_free (GMT, llon);
635 gmt_M_free (GMT, llat);
636}
637
638GMT_LOCAL void gmtplot_map_lonline (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, double lon, double south, double north) /* Draws a line of constant longitude */ {
639 uint64_t nn;

Callers 3

gmtplot_lineary_gridFunction · 0.85
gmtplot_y_gridFunction · 0.85
gmt_linearx_gridFunction · 0.85

Calls 4

gmtlib_latpathFunction · 0.85
gmt_geo_to_xy_lineFunction · 0.85
PSL_commentFunction · 0.85
gmt_plot_lineFunction · 0.85

Tested by

no test coverage detected