Skip to content

geohierarchy.maps.layers.registry

The layer-type registry itself: :class:LayerTypeSpec + register/get/list.

A "layer type" here is a rendering classification (how a level's tiles turn into pixels: filled polygons, circle-markers, or stroked lines -- optionally with hover/click interactivity), not a data classification. Two very different hierarchy levels -- H3 hexagons at some resolution and census tracts -- are typically the same layer type ("polygon") because they render identically (filled area, popup on click); what differs between them (color column, popup fields, zoom band) already lives in :class:~geohierarchy.maps.folium.render.MapLayer, not here.

LayerTypeSpec(name, kind, interactive=True, default_paint=dict(), description='') dataclass

A registered layer type.

Attributes:

Name Type Description
name str

Registry key, e.g. "hexagon", "circle", "census_polygon", "street_overlay", "development_overlay".

kind LayerKind

Geometry-rendering primitive -- see :data:LayerKind. Drives which MapLibre layer "type" is emitted (fill/circle/line) and which branch of :meth:~geohierarchy.maps.folium.style.ColorSpec.maplibre_paint / Leaflet vectorTileLayerStyles shape (fillColor vs. radius vs. stroke-only) applies.

interactive bool

Whether click/hover (popup + hover-highlight) should be wired up by default for this layer type. Overlay/annotation layers (e.g. a border-only development-priority overlay) often set this False.

default_paint Dict[str, object]

Optional MapLibre paint overrides merged UNDER whatever :meth:ColorSpec.maplibre_paint produces (e.g. a circle layer type's base radius). Renderer-supplied paint keys win.

description str

Human-readable summary, surfaced by :func:list_layer_types for discoverability.

register_layer_type(spec, *, overwrite=False)

Register a new layer type.

Parameters:

Name Type Description Default
spec LayerTypeSpec

The :class:LayerTypeSpec to register.

required
overwrite bool

If False (default), raises if spec.name is already registered -- catches accidental duplicate registration rather than silently shadowing an existing type.

False

Returns:

Type Description
LayerTypeSpec

spec, for convenient use as FOO = register_layer_type(...).

get_layer_type(name)

Look up a registered layer type by name.

Parameters:

Name Type Description Default
name Optional[str]

Registry key, or None to get the default ("polygon") -- the common case for most hierarchy levels (hexagons, census polygons, any other filled-area level).

required

Returns:

Type Description
LayerTypeSpec

The matching :class:LayerTypeSpec.

Raises:

Type Description
KeyError

If name isn't registered. Message lists what IS registered, since this is a config/typo error a caller should fix, not something to fall back silently from.

list_layer_types()

Return {name: description} for every registered layer type.