Folium Line-Text-Overlay Visualization System¶
viz_line_text_overlay
¶
ResolvedLineTextOverlayFeature
dataclass
¶
Bases: ResolvedFeature
Resolved visual properties of a text along a line.
Used by LineTextOverlayGenerator. The properties give the resolved
values with the defaults of LineTextOverlayFeatureResolver; without a
value, text_offset is half the font size.
Source code in src/mesqual/visualizations/folium_viz_system/viz_line_text_overlay.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
LineTextOverlayFeatureResolver
¶
Bases: FeatureResolver[ResolvedLineTextOverlayFeature]
Resolves the visual properties of a text that follows a line, for example a flow value along a line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text_offset
|
PropertyMapper | float
|
Distance of the text from the line in pixels. Default: half the font size. |
None
|
text_orientation
|
PropertyMapper | int
|
Rotation of the text in degrees. |
0
|
text_repeat
|
PropertyMapper | bool
|
Repeat the text along the whole line. |
False
|
text_center
|
PropertyMapper | bool
|
Place the text at the middle of the line. |
False
|
text_below
|
PropertyMapper | bool
|
Place the text below the line. |
False
|
font_weight
|
PropertyMapper | str
|
CSS font weight. |
'bold'
|
font_size
|
PropertyMapper | int
|
Font size in pixels. |
12
|
font_color
|
PropertyMapper | str
|
Font color. |
'#000000'
|
reverse_path_direction
|
PropertyMapper | bool
|
Run the text from the end to the start of the line. |
False
|
text_print_content
|
PropertyMapper | str
|
The text. |
True
|
tooltip
|
PropertyMapper | str | bool
|
Tooltip content, see |
True
|
popup
|
PropertyMapper | Popup | bool
|
Popup content, see |
False
|
geometry
|
PropertyMapper | LineString
|
LineString of the text path. Default: the first LineString or
MultiLineString of the item attributes |
None
|
**property_mappers
|
PropertyMapper | Any
|
Additional custom property mappings. |
{}
|
Each argument takes a static value or a PropertyMapper.
Source code in src/mesqual/visualizations/folium_viz_system/viz_line_text_overlay.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
LineTextOverlayGenerator
¶
Bases: FoliumObjectGenerator[LineTextOverlayFeatureResolver]
Draws a text along the line of each item, with folium PolyLineTextPath on an invisible line.
An item without LineString geometry or without text gets no text.
Examples:
A text along each border line:
>>> import folium
>>> generator = LineTextOverlayGenerator(
... LineTextOverlayFeatureResolver(
... geometry=PropertyMapper.from_item_attr('geo_line_string'),
... text_print_content=PropertyMapper.from_item_attr('area_to', lambda area: f'to {area}'),
... )
... )
>>> folium_map = folium.Map(location=[48, 9], zoom_start=6)
>>> fg = generator.generate_objects_for_model_df(dataset.fetch('CountryBorder.Model'), folium.FeatureGroup('Borders'))
>>> fg = fg.add_to(folium_map)
>>> html = folium_map.get_root().render()
>>> html.count('.setText('), '"to C2"' in html
(2, True)
Source code in src/mesqual/visualizations/folium_viz_system/viz_line_text_overlay.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |