Skip to content

Index

subsurfaceio.tiles

Reusable SVG tiles used by soil-pattern graphics.

Look up a tile and emit its <pattern> or <symbol> definition:

from subsurfaceio.tiles import tile_registry

svg = tile_registry.tiles['gint_CIRC05'].generate_definition_svg()

Classes:

Name Description
Tile

Reusable SVG pattern or symbol used inside a graphic.

Tiles

Catalog of named Tile records.

Attributes:

Name Type Description
tile_registry Tiles

tile_registry module-attribute

tile_registry: Tiles = Tiles.model_validate(
    dict(tiles=tiles)
)

Tile pydantic-model

Bases: BaseModel

Reusable SVG pattern or symbol used inside a graphic.

Config:

  • frozen: True

Fields:

  • name (str)
  • description (str | None)
  • width (float)
  • height (float)
  • mapping (Literal['Repeat', 'Expand to fit', 'Repeat Horizontal/Expand Vertical', 'Expand Horizontal/Repeat Vertical', 'Maintain Proportions', 'Maintain Size', 'Maintain Size - Expand Borders'])

description pydantic-field

description: str | None = None

height pydantic-field

height: float

mapping pydantic-field

mapping: Literal[
    "Repeat",
    "Expand to fit",
    "Repeat Horizontal/Expand Vertical",
    "Expand Horizontal/Repeat Vertical",
    "Maintain Proportions",
    "Maintain Size",
    "Maintain Size - Expand Borders",
] = "Repeat"

model_config class-attribute instance-attribute

model_config = ConfigDict(frozen=True)

name pydantic-field

name: str

width pydantic-field

width: float

definition_id

definition_id(
    width: float | None = None, height: float | None = None
) -> str

Stable SVG id for this tile, including size when the mapping is dynamic.

Parameters:

Name Type Description Default
width float | None

Rendered width used in expand-horizontal ids.

None
height float | None

Rendered height used in expand-vertical ids.

None

Returns:

Type Description
str

Element id string.

generate_definition_svg cached

generate_definition_svg(
    width_for_expand_horizontal: float | None = None,
    height_for_expand_vertical: float | None = None,
) -> str

Return the SVG <pattern> or <symbol> definition for this tile.

Parameters:

Name Type Description Default
width_for_expand_horizontal float | None

Rendered pixel width; required when mapping is 'Expand Horizontal/Repeat Vertical'.

None
height_for_expand_vertical float | None

Rendered pixel height; required when mapping is 'Repeat Horizontal/Expand Vertical'.

None

Raises:

Type Description
NotImplementedError

For mappings not yet supported.

ValueError

When a required dimension is missing.

Returns:

Type Description
str

SVG <pattern> or <symbol> definition markup.

Tiles pydantic-model

Bases: BaseModel

Catalog of named Tile records.

Fields:

tiles pydantic-field

tiles: dict[str, Tile]