Crate hittekaart

Crate hittekaart 

Source
Expand description

hittekaart is a crate to generate heatmaps from GPS tracks. It reads GPX files and produces OSM-compatible overlay tiles.

This crate is mainly written to power the CLI wrapper and the Python interface, and as such, is opinionated (and leaky) at points.

§Example

use hittekaart::{gpx, renderer::{self, heatmap}, storage::{self, Storage}};
const ZOOM: u32 = 10;
let source =
r#"<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1">
  <trk>
    <trkseg>
      <trkpt lat="49.184246" lon="9.201409"></trkpt>
    </trkseg>
  </trk>
</gpx>"#;
let track = gpx::extract_from_str(source)?;
let tracks = &[track];
// Generating a heat-map is a two-step process: First, we collect the "heat zones", then we
// render each zone to a PNG.
let heat = renderer::prepare(
    &renderer::heatmap::Renderer,
    ZOOM,
    tracks,
    // A callback you can use to show progress
    || Ok(()),
)?;
// Before we run the second step, we set up the storage system. You can save the bytes in any
// way you want, but there are convenience functions in this crate:
let mut store = storage::Sqlite::connect(":memory:")?;
store.prepare()?;
store.prepare_zoom(ZOOM)?;
// Now we're ready to do the actual colorizing
renderer::colorize(
    &renderer::heatmap::Renderer,
    heat,
    // The callback receives the rendered tile, with the PNG data ready to grab.
    |tile| {
        store.store(ZOOM, tile.x, tile.y, &tile.data)
    },
)?;
store.finish()?;

Modules§

error
Error definitions for hittekaart.
gpx
GPX data extraction functions.
layer
Lazy tiled image.
renderer
Generic “tile rendering” methods.
storage
Abstractions over different storage backends.