hittekaart_py package

The hittekaart_py module provides a Python interface for hittekaart heatmap generation. Unlike previous modules, this is a binding using PyO3, and not a subprocess wrapper.

Example

from hittekaart_py import (
    Track, HeatmapRenderer, Settings, Storage, generate
)

settings = Settings(threads=3)
tracks = [
    Track.from_file(b"Documents/track.gpx", None),
    Track.from_coordinates([(45.0, 47.0)]),
]
storage = Storage.Sqlite(b"/tmp/tiles.sqlite")
generate(settings, tracks, HeatmapRenderer(), storage)

Input and output

class hittekaart_py.Track

An in-memory representation of a track.

static from_file(path, compression)

Loads a track from the given file.

Parameters:
  • path (bytes) – Path to the file.

  • compression (str | None) – Decompression algorithm to use when reading the file. Can be None, "gzip" or "brotli".

Returns:

The created track.

Return type:

Track

static from_coordinates(coordinates)

Directly represents the given coordinates as a track.

Parameters:

coordinates (list[tuple[float, float]]) – The coordinates as a list of longitude-latitude pairs.

Returns:

The created track.

Return type:

Track

class hittekaart_py.Storage

Represents the output storage.

static Folder(path)

Output the tiles to the given folder. This will create a subdirectory for every zoom level, then a directory for the x coordinate, then a file y.png.

Note that this will create many small files, which can waste space.

Parameters:

path (bytes) – Path to the folder.

Returns:

The created storage.

Return type:

Storage

static Sqlite(path)

Output the tiles to the given SQLite database.

Parameters:

path (bytes) – Path to the database.

Returns:

The created storage.

Return type:

Storage

Renderers

class hittekaart_py.HeatmapRenderer

The renderer that generates a heatmap.

class hittekaart_py.MarktileRenderer

The renderer that will only mark visited tiles.

class hittekaart_py.TilehuntRenderer(zoom)

The renderer that will mark visisted tiles at a fixed zoom level.

Parameters:

zoom (int) – The zoom level.

Tile generation

class hittekaart_py.Settings(min_zoom=1, max_zoom=19, threads=0)

Settings that apply to all renderers.

min_zoom: int

Smalles zoom level to generate tiles for.

max_zoom: int

Largest zoom level to generate tiles for.

threads: int

Number of threads to use for tile generation.

Setting this to 0 will automatically determine the number of available cores and use that many threads.

hittekaart_py.generate(settings, items, renderer, storage)

Generates the tiles using the given renderer, and saves them to the given storage.

Parameters:

Errors

exception hittekaart_py.HitteError

Catch-all error for underlying hittekaart errors. See the string description for the error cause.