MCPcopy Index your code
hub / github.com/MapServer/MapServer / msPolylineLabelPathLineString

Function msPolylineLabelPathLineString

mapprimitive.c:1779–2198  ·  view source on GitHub ↗

* Calculate a series of label points for each character in the label for a * given polyline. The resultant series of points is stored in *labelpath, * which is added to the labelpaths array. Note that the points and bounds * are allocated in this function. The polyline must be converted to image * coordinates before calling this function. */

Source from the content-addressed store, hash-verified

1777 * coordinates before calling this function.
1778 */
1779void msPolylineLabelPathLineString(mapObj *map, imageObj *img, shapeObj *p, int min_length, fontSetObj *fontset, char *string, labelObj *label, double scalefactor, int line_index,
1780 double** segment_lengths, double line_length, double total_length, int* labelpaths_index, int* labelpaths_size, labelPathObj*** labelpaths,
1781 int** regular_lines, int *regular_lines_index, int* regular_lines_size)
1782{
1783 double distance_along_segment;
1784 double segment_length, fwd_line_length, rev_line_length, text_length, text_start_length, label_buffer, text_end_length;
1785 double right_label_position, left_label_position, center_label_position;
1786 int numchars;
1787
1788 int i,j,k,l,n, inc, final_j, label_repeat;
1789 double direction;
1790 rectObj bbox;
1791 lineObj bounds;
1792 double *offsets;
1793 double size, t, tmp_length;
1794 double cx, cy; /* centre of a character, x & y values. */
1795
1796 double theta;
1797 double dx, dy, w, cos_t, sin_t;
1798
1799 labelPathObj *labelpath = NULL;
1800
1801 /* Line smoothing kernel */
1802 double kernel[] = {0.1, 0.2, 2, 0.2, 0.1}; /* {1.5, 2, 15, 2, 1.5}; */
1803 double kernel_normal = 2.6; /* Must be sum of kernel elements */
1804 int kernel_size = 5;
1805
1806 double letterspacing = 1.25;
1807 /* As per RFC 60, if label->maxoverlapangle == 0 then fall back on pre-6.0 behavior
1808 which was to use maxoverlapangle = 0.4*MS_PI ( 40% of 180 degrees ) */
1809 double maxoverlapangle = 0.4 * MS_PI;
1810
1811 offsets = NULL;
1812
1813#ifndef GD_HAS_FTEX_XSHOW
1814 goto ANGLEFOLLOW_FAILURE; /* we don't have a current enough version of GD, fall back to ANGLE AUTO */
1815#else
1816
1817 tmp_length = total_length;
1818 if (label->repeatdistance > 0)
1819 tmp_length = line_length;
1820
1821 numchars = msGetNumGlyphs(string);
1822
1823 /* skip the label and use the normal algorithm if it has fewer than 2 characters */
1824 if(numchars < 2)
1825 goto ANGLEFOLLOW_FAILURE;
1826
1827 i = line_index;
1828
1829 if (((min_length != -1) && (tmp_length < min_length))) { /* too short */
1830 goto FAILURE;
1831 }
1832
1833 if(p->line[i].numpoints < 2) { /* degenerate */
1834 goto FAILURE;
1835 }
1836

Callers 1

msPolylineLabelPathFunction · 0.85

Calls 9

msGetNumGlyphsFunction · 0.85
msGetLabelSizeFunction · 0.85
msSmallMallocFunction · 0.85
msSmallCallocFunction · 0.85
msInitShapeFunction · 0.85
msAddLineDirectlyFunction · 0.85
msComputeBoundsFunction · 0.85
msFreeLabelPathObjFunction · 0.85
msSmallReallocFunction · 0.85

Tested by

no test coverage detected