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

Function gmtplot_map_annotate

src/gmt_plot.c:2752–3013  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2750}
2751
2752GMT_LOCAL void gmtplot_map_annotate (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, double w, double e, double s, double n) {
2753 unsigned int i, k, nx = 0, ny = 0, last, form, remove[2] = {0,0}, trim, add, x_kind = 0;
2754 bool do_minutes, do_seconds, done_Greenwich, done_Dateline, check_edges;
2755 bool full_lat_range, proj_A, proj_B, annot_0_and_360 = false, dual[2], is_dual, annot, is_world_save, lon_wrap_save;
2756 char label[GMT_LEN256] = {""};
2757 char **label_c = NULL;
2758 double *val = NULL, dx[2], dy[2], w2, s2, del, shift = 0.0;
2759
2760 if (!(gmt_M_x_is_lon (GMT, GMT_IN) || gmt_M_y_is_lat (GMT, GMT_IN) || GMT->current.proj.projection_GMT == GMT_POLAR)) return; /* Annotations and header already done by gmtplot_linear_map_boundary */
2761
2762 is_world_save = GMT->current.map.is_world;
2763 lon_wrap_save = GMT->current.map.lon_wrap;
2764
2765 if (GMT->current.proj.projection_GMT == GMT_POLAR) { /* r-theta requires more info to know what theta is */
2766 if (GMT->current.proj.angle_kind == GMT_IS_LON) x_kind = 0;
2767 else if (GMT->current.proj.angle_kind == GMT_IS_LAT) x_kind = 3;
2768 else x_kind = 4;
2769 }
2770
2771 if (GMT->current.map.frame.header[0] && !GMT->current.map.frame.plotted_header) { /* Make plot header for geographic maps */
2772 if (gmt_M_is_geographic (GMT, GMT_IN) || GMT->current.map.frame.side[N_SIDE] & GMT_AXIS_ANNOT) {
2773 PSL_setfont (PSL, GMT->current.setting.font_annot[GMT_PRIMARY].id);
2774 PSL_command (PSL, "/PSL_H_y %d ", PSL_IZ (PSL, GMT->current.setting.map_tick_length[GMT_PRIMARY] + GMT->current.setting.map_annot_offset[GMT_PRIMARY] + GMT->current.setting.map_title_offset));
2775 if (GMT->current.setting.map_degree_symbol == gmt_none)
2776 PSL_deftextdim (PSL, "-h", GMT->current.setting.font_annot[GMT_PRIMARY].size, "100");
2777 else {
2778 snprintf (label, GMT_LEN16, "100%c", (int)GMT->current.setting.ps_encoding.code[GMT->current.setting.map_degree_symbol]);
2779 PSL_deftextdim (PSL, "-h", GMT->current.setting.font_annot[GMT_PRIMARY].size, label);
2780 }
2781 PSL_command (PSL, "add def\n");
2782 }
2783 else
2784 PSL_defunits (PSL, "PSL_H_y", GMT->current.setting.map_title_offset + GMT->current.setting.map_tick_length[GMT_PRIMARY]);
2785
2786 PSL_command (PSL, "%d %d PSL_H_y add M\n", PSL_IZ (PSL, GMT->current.proj.rect[XHI] * 0.5), PSL_IZ (PSL, GMT->current.proj.rect[YHI]));
2787 gmt_map_title (GMT, 0.0, 0.0);
2788 }
2789
2790 gmtplot_consider_internal_annotations (GMT, PSL, w, e, s, n); /* Handle any special case of internal annotations */
2791
2792 if (GMT->current.proj.edge[S_SIDE] || GMT->current.proj.edge[N_SIDE]) {
2793 dx[0] = gmtlib_get_map_interval (GMT, GMT->current.map.frame.axis[GMT_X].type, &GMT->current.map.frame.axis[GMT_X].item[GMT_ANNOT_UPPER]);
2794 dx[1] = gmtlib_get_map_interval (GMT, GMT->current.map.frame.axis[GMT_X].type, &GMT->current.map.frame.axis[GMT_X].item[GMT_ANNOT_LOWER]);
2795 /* Determine if we should annotate both 0 and 360 degrees */
2796
2797 full_lat_range = (fabs (180.0 - fabs (GMT->common.R.wesn[YHI] - GMT->common.R.wesn[YLO])) < GMT_CONV4_LIMIT);
2798 proj_A = (GMT->current.proj.projection_GMT == GMT_MERCATOR || GMT->current.proj.projection_GMT == GMT_OBLIQUE_MERC ||
2799 GMT->current.proj.projection_GMT == GMT_WINKEL || GMT->current.proj.projection_GMT == GMT_ECKERT4 || GMT->current.proj.projection_GMT == GMT_ECKERT6 ||
2800 GMT->current.proj.projection_GMT == GMT_ROBINSON || GMT->current.proj.projection_GMT == GMT_CYL_EQ || GMT->current.proj.projection_GMT == GMT_CYL_STEREO ||
2801 GMT->current.proj.projection_GMT == GMT_CYL_EQDIST || GMT->current.proj.projection_GMT == GMT_MILLER || GMT->current.proj.projection_GMT == GMT_LINEAR);
2802 proj_B = (GMT->current.proj.projection_GMT == GMT_HAMMER || GMT->current.proj.projection_GMT == GMT_MOLLWEIDE ||
2803 GMT->current.proj.projection_GMT == GMT_SINUSOIDAL);
2804 if (gmt_M_is_conical (GMT) && gmt_M_360_range (w, e)) /* Special case since 360 longitudes do not form a circle but a pacman shape */
2805 annot_0_and_360 = true;
2806 else
2807 annot_0_and_360 = (is_world_save && (proj_A || (!full_lat_range && proj_B)));
2808 }
2809 else

Callers 1

gmtplot_map_annotationsFunction · 0.85

Calls 15

PSL_setfontFunction · 0.85
PSL_commandFunction · 0.85
PSL_deftextdimFunction · 0.85
PSL_defunitsFunction · 0.85
gmt_map_titleFunction · 0.85
gmtlib_get_map_intervalFunction · 0.85
PSL_commentFunction · 0.85
PSL_settextmodeFunction · 0.85
gmt_setfontFunction · 0.85
gmtlib_set_do_secondsFunction · 0.85
gmtlib_coordinate_arrayFunction · 0.85

Tested by

no test coverage detected