Php/svg Labelling Algorithm
We need a sophisticated PHP function/algorithm that can read an SVG file containing numerous PATH tags and add a small TEXT label (containing a number) inside each of the polygons.
Ideally this label should be in the centroid position, but with certain complex polygons this is not always inside the boundary: sometimes outside, and sometimes overlapping the boundary itself. So the function will need to intelligently tell if the label’s bounding box is completely inside the polygon.
Part two of the function needs to check if the chosen position for the label is obscured by another shape that lies on top of the target shape. If so, the algorithm needs to intelligently find another position that is not obscured by another shape.
I can provide example SVG files containing many polygons that need labelling. The paths are presented in z-index order, so this will help to find which shapes are on top.
More detail is available on request. This would ideally suit a PHP programmer with a background in computational geometry and SVG graphics.



