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

Function msPolylineLabelPath

mapprimitive.c:1727–1770  ·  view source on GitHub ↗

Calculate the labelpath for each line if repeatdistance is enabled, else the labelpath of the longest line segment */

Source from the content-addressed store, hash-verified

1725
1726/* Calculate the labelpath for each line if repeatdistance is enabled, else the labelpath of the longest line segment */
1727labelPathObj** msPolylineLabelPath(mapObj *map, imageObj *img,shapeObj *p, int min_length, fontSetObj *fontset, char *string, labelObj *label, double scalefactor, int *numpaths,
1728 int** regular_lines, int* num_regular_lines)
1729{
1730 double max_line_length, total_length;
1731 double **segment_lengths, *line_lengths;
1732 int i, segment_index, max_line_index, labelpaths_index, labelpaths_size, regular_lines_index, regular_lines_size;
1733 labelPathObj** labelpaths;
1734
1735 labelpaths_index = 0;
1736 labelpaths_size = p->numlines; // minimal array size
1737 regular_lines_index = 0;
1738 regular_lines_size = 1;
1739 *numpaths = 0;
1740 segment_index = max_line_index = 0;
1741 total_length = max_line_length = 0.0;
1742
1743 labelpaths = (labelPathObj **) msSmallMalloc(sizeof(labelPathObj *) * labelpaths_size);
1744 (*regular_lines) = (int *) msSmallMalloc(sizeof(int) * regular_lines_size);
1745
1746 msPolylineComputeLineSegments(p, &segment_lengths, &line_lengths, &max_line_index, &max_line_length, &segment_index, &total_length);
1747
1748 if (label->repeatdistance > 0)
1749 for(i=0; i<p->numlines; i++) {
1750 msPolylineLabelPathLineString(map,img, p,min_length, fontset, string, label, scalefactor, i, segment_lengths, line_lengths[i], total_length,
1751 &labelpaths_index, &labelpaths_size, &labelpaths, regular_lines, &regular_lines_index, &regular_lines_size);
1752 }
1753 else
1754 msPolylineLabelPathLineString(map, img, p,min_length, fontset, string, label, scalefactor, max_line_index, segment_lengths, line_lengths[max_line_index], total_length,
1755 &labelpaths_index, &labelpaths_size, &labelpaths, regular_lines, &regular_lines_index, &regular_lines_size);
1756
1757 /* freeing memory: allocated by msPolylineComputeLineSegments */
1758 if ( segment_lengths ) {
1759 for ( i = 0; i < p->numlines; i++ )
1760 free(segment_lengths[i]);
1761 free(segment_lengths);
1762 }
1763
1764 free(line_lengths);
1765
1766 /* set the number of paths in the array */
1767 *numpaths = labelpaths_index;
1768 *num_regular_lines = regular_lines_index;
1769 return labelpaths;
1770}
1771
1772/*
1773 * Calculate a series of label points for each character in the label for a

Callers 1

msDrawShapeFunction · 0.85

Calls 3

msSmallMallocFunction · 0.85

Tested by

no test coverage detected