Renders text for features.
Parameters: |
|
---|
For features with point geometries the text symbolizer places the text centered both vertically and horizontally at the point
>>> symbolizer = TextSymbolizer(property_name='title', face_name='Sans', size=10, color=Color.name('red'))
>>> point_feature = Feature(geometry=Geometry(type='Point', coordinates=[5, 5]),
... properties={'title': 'Primary Peak'})
Need to add a point symbolizer as well to see placement
For line geometries the text can be placed at the center of the line, placement “point”, or along the line, placement “line”.
The default placement is “point”.
>>> line_feature = Feature(geometry=Geometry(type='LineString', coordinates=[[1, 1], [9, 9]]),
... properties={'title': 'Simple Street'})
>>> symbolizer.placement = 'line'
For lines with segments the text follows the angle of the line
>>> polygon_feature = Feature(
... geometry=Geometry(type='Polygon',
... coordinates=[[[1, 1], [5, 8], [9, 9], [5, 2]]]),
... properties={'title': 'Lake Diamond'}
... )
With placement ‘point’ the text is placed at the centroid of the polygon.
>>> symbolizer.placement = 'point'
TODO: rendering a polygon with placement ‘line’
>>> symbolizer.placement = 'line'
If a halo attribute is specified the text is drawn twice. Once with the line width of the text increased by the halo radius and in the halo colour and again with normal line width and colour.
>>> symbolizer = TextSymbolizer(property_name='title', face_name='Sans', size=10, color=Color.name('red'), halo_radius=1, halo_color=Color.name('black'))
0 | |
2.5 | |
5 |
An halo example with line placement