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, Storage, generate
)

tracks = [
    Track.from_file(b"Documents/track.gpx", None),
    Track.from_coordinates([(45.0, 47.0)]),
]
storage = Storage.Sqlite(b"/tmp/tiles.sqlite")
generate(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.

Functions

hittekaart_py.generate(items, renderer, storage)

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

Parameters:
hittekaart_py.set_threads(threads)

Set the number of threads that hittekaart will use.

Note that this is a global function, it will affect all subsequent calls.

Note further that you may only call this function once, at startup. Calls after the thread pool has been initialized (e.g. via a generate() or set_threads() call) will raise an exception.

Parameters:

threads (int) – Number of threads to use.

Errors

exception hittekaart_py.HitteError

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