1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! `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()?;
//! # Ok::<_, hittekaart::error::Error>(())
//! ```