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

Function gmtplot_consider_internal_annotations

src/gmt_plot.c:2490–2676  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2488}
2489
2490GMT_LOCAL void gmtplot_consider_internal_annotations (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, double w, double e, double s, double n) {
2491 /* Special annotation routine for annotating latitude (or radius) along a specified meridian. This allows us to annotate
2492 * maps that do not have the axes we wish to annotate, such as annotating latitudes for a 0/360 azimuthal map. */
2493 unsigned int i, nx = 0, ny = 0, first = 0, form, lonlat, justify;
2494 bool do_minutes, do_seconds, do_grid = false;
2495 char label[GMT_LEN256] = {""}, format[GMT_LEN64] = {""}, **label_c = NULL;
2496 double *val = NULL, *tval = NULL, dx, dy, x0, y0, x1, y1, L, ds, dc, line_angle, text_angle, angle, dyg, dxg, xa, xb, ya, yb, Sa, Ca;
2497
2498 if (GMT->current.map.frame.internal_annot == 0) return; /* Not requested */
2499
2500 form = gmt_setfont (GMT, &GMT->current.setting.font_annot[GMT_PRIMARY]);
2501 PSL_comment (PSL, "Map annotations (Internal)\n");
2502 PSL_settextmode (PSL, PSL_TXTMODE_MINUS); /* Replace hyphens with minus signs */
2503
2504 if (GMT->current.map.frame.internal_annot == 1) { /* Placement of latitude or radial annotations along selected meridian */
2505 dy = gmtlib_get_map_interval (GMT, GMT->current.map.frame.axis[GMT_Y].type, &GMT->current.map.frame.axis[GMT_Y].item[GMT_ANNOT_UPPER]);
2506 if (gmt_M_y_is_lat (GMT, GMT_IN)) {
2507 do_minutes = (fabs (fmod (dy, 1.0)) > GMT_CONV4_LIMIT);
2508 do_seconds = gmtlib_set_do_seconds (GMT, dy);
2509 lonlat = 1;
2510 }
2511 else { /* Also, we know that GMT->current.setting.format_geo_out = -1 in this case */
2512 do_minutes = do_seconds = 0;
2513 lonlat = 2;
2514 }
2515 if (GMT->current.plot.r_theta_annot) { /* Make format for radial term */
2516 char tmp[GMT_LEN64] = {""};
2517 strcpy (format, GMT->current.setting.format_float_map);
2518 gmt_get_format (GMT, dy, NULL, NULL, tmp);
2519 strncpy (GMT->current.setting.format_float_map, tmp, GMT_LEN64-1);
2520 }
2521
2522 if (GMT->current.proj.z_down) { /* Want to annotate depth rather than radius */
2523 if (GMT->current.map.frame.axis[GMT_Y].file_custom)
2524 ny = gmtlib_coordinate_array (GMT, 0.0, GMT->current.proj.z_radius-s, &GMT->current.map.frame.axis[GMT_Y].item[GMT_ANNOT_UPPER], &tval, &label_c);
2525 else if (GMT->current.proj.z_down == GMT_ZDOWN_Z) /* z = n - r */
2526 ny = gmtlib_linear_array (GMT, 0.0, GMT->current.proj.z_radius-s, dy, GMT->current.map.frame.axis[GMT_Y].phase, &tval);
2527 else if (GMT->current.proj.z_down == GMT_ZDOWN_ZP) /* z = n - r */
2528 ny = gmtlib_linear_array (GMT, GMT->current.proj.z_radius-n, GMT->current.proj.z_radius-s, dy, GMT->current.map.frame.axis[GMT_Y].phase, &tval);
2529 val = gmt_M_memory (GMT, NULL, ny, double);
2530 for (i = 0; i < ny; i++) {
2531 if (GMT->current.proj.z_down == GMT_ZDOWN_ZP)
2532 val[i] = GMT->current.proj.z_radius - tval[i]; /* These are the z values needed for positioning */
2533 else
2534 val[i] = GMT->common.R.wesn[YHI] - tval[i]; /* These are the radial values needed for positioning */
2535 }
2536 }
2537 else { /* Annotate radius */
2538 if (GMT->current.map.frame.axis[GMT_Y].file_custom)
2539 ny = gmtlib_coordinate_array (GMT, s, n, &GMT->current.map.frame.axis[GMT_Y].item[GMT_ANNOT_UPPER], &val, &label_c);
2540 else
2541 ny = gmtlib_linear_array (GMT, s, n, dy, GMT->current.map.frame.axis[GMT_Y].phase, &val);
2542 tval = val; /* Here they are the same thing */
2543 }
2544
2545 /* Lot of exceptions to check for that affects if first or last annotatino should be skipped */
2546 if (GMT->current.proj.z_down == GMT_ZDOWN_Z && ny && tval[ny-1] < GMT->current.proj.z_radius)
2547 ny--;

Callers 1

gmtplot_map_annotateFunction · 0.85

Calls 15

gmt_setfontFunction · 0.85
PSL_commentFunction · 0.85
PSL_settextmodeFunction · 0.85
gmtlib_get_map_intervalFunction · 0.85
gmtlib_set_do_secondsFunction · 0.85
gmt_get_formatFunction · 0.85
gmtlib_coordinate_arrayFunction · 0.85
gmtlib_linear_arrayFunction · 0.85
gmt_setpenFunction · 0.85
gmtlib_get_annot_labelFunction · 0.85
gmt_geo_to_xyFunction · 0.85

Tested by

no test coverage detected