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

Function gmtplot_curved_boundary_offset

src/gmt_plot.c:1804–1824  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1802}
1803
1804GMT_LOCAL double gmtplot_curved_boundary_offset (struct GMT_CTRL *GMT, double lon, double lat, int type, unsigned int level) {
1805 /* For global curved maps like Mollweide etc, the parallel labeling occurs against an increasingly
1806 * sloping map border as we approach the poles. Here we try to compensate for that by adding a bit
1807 * of extra annotation offset boost that depends on the latitude and size of annotation font */
1808 double lat1, lat2, dlat, x1, x2, y1, y2, h, boost;
1809 if (type == 0) return 0.0; /* No boost for any longitude annotations at top/bottom of these global projections */
1810 if (!gmt_M_is_misc (GMT)) return 0.0; /* Not one of the global misc projections */
1811 if (GMT->common.R.oblique) return 0.0; /* Not a w/e/s/n curved frame */
1812
1813 /* OK, here we have Hammer, Robinson, etc. */
1814
1815 dlat = (GMT->common.R.wesn[YHI] - GMT->common.R.wesn[YLO]) / 180.0; /* So 1 degree for a global map */
1816 if (doubleAlmostEqual (lat, -90)) lat1 = lat, lat2 = lat + dlat; /* South pole point */
1817 else if (doubleAlmostEqual (lat, 90)) lat1 = lat - dlat, lat2 = lat; /* North pole point */
1818 else lat1 = lat - dlat, lat2 = lat + dlat;
1819 gmt_geo_to_xy (GMT, lon, lat1, &x1, &y1);
1820 gmt_geo_to_xy (GMT, lon, lat2, &x2, &y2);
1821 h = GMT->current.setting.font_annot[level].size * GMT->session.u2u[GMT_PT][GMT_INCH] * GMT_LET_HEIGHT; /* Approximate height of annotations */
1822 boost = 0.375 * h * fabs (x2 - x1) / (y2 - y1); /* Started with 0.5, 0.25 was too small so split the difference */
1823 return boost;
1824}
1825
1826GMT_LOCAL bool gmtplot_skip_end_annotation (struct GMT_CTRL *GMT, unsigned int axis, double x, double length) {
1827 /* Returns true if this is an annotation at the end of the axis and we are either in GMT_IS_INSIDE mode or user added modifier +e[l|u] to the axis annotation settings */

Callers 1

gmtplot_map_symbolFunction · 0.85

Calls 1

gmt_geo_to_xyFunction · 0.85

Tested by

no test coverage detected