Add functionality for drawing folium.Maps
- this code is not unit-tested due to the complexity involving interactive `folium.Map`s => visual checks give high confidence
This commit is contained in:
parent
605ade4078
commit
4b6d92958d
12 changed files with 714 additions and 13 deletions
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import folium
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
||||
|
|
@ -104,3 +107,31 @@ class Grid(meta.Base):
|
|||
pixel.addresses.append(assoc)
|
||||
|
||||
return grid
|
||||
|
||||
def clear_map(self) -> Grid: # pragma: no cover
|
||||
"""Shortcut to the `.city.clear_map()` method.
|
||||
|
||||
Returns:
|
||||
self: enabling method chaining
|
||||
""" # noqa:D402,DAR203
|
||||
self.city.clear_map()
|
||||
return self
|
||||
|
||||
@property # pragma: no cover
|
||||
def map(self) -> folium.Map: # noqa:WPS125
|
||||
"""Shortcut to the `.city.map` object."""
|
||||
return self.city.map
|
||||
|
||||
def draw(self, **kwargs: Any) -> folium.Map: # pragma: no cover
|
||||
"""Draw all pixels in the grid.
|
||||
|
||||
Args:
|
||||
**kwargs: passed on to `Pixel.draw()`
|
||||
|
||||
Returns:
|
||||
`.city.map` for convenience in interactive usage
|
||||
"""
|
||||
for pixel in self.pixels:
|
||||
pixel.draw(**kwargs)
|
||||
|
||||
return self.map
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue