Skip to content

Reference

kachel.server

The actual tile server.

generate_tile(idx, max_square_idx, zoom_level)

Generate a tile image.

Parameters:

Name Type Description Default
idx int

bitmask indicating which tiles are covered.

required
max_square_idx int

bitmask indicating which tiles are part of a max square.

required
zoom_level int

the zoom level of the tile.

required
max_square

Whether to highlight the maximum square.

required

Returns:

Type Description
Image.Image

A 256x256 PNG image.

tile(user_id, z, x, y)

serve a tile.

Parameters:

Name Type Description Default
user_id str

The user id.

required
z int

the zoom level, higher is closer.

required
x int

the x coordinate.

required
y int

the y coordinate.

required

Returns:

Type Description
Response

a 256x256 png image

users()

Return a list of endpoints for all users.

kachel.cache

Compute a cache file given a geojson file.

A cache file is a dict mapping (x, y, z) to a boolean indicating whether the tile in zoom level 14 is covered by the geojson file.

compute_max_squares(tiles)

Compute max squares that contains covered tiles.

Parameters:

Name Type Description Default
tiles Set[Tile]

Set of visited tiles.

required
Return

List of max squares each consisting of a top left coordinate and a size.

create_cache_file(geojson_file, cache_file)

Generate a cache file from a geojson file.

is_in_max_square(tile, max_square)

Check if a tile is in the max square.

is_in_max_squares(tile, max_squares)

Check if a tile is in any of the max squares.