Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
translate ▾

Modern-Apps.git / scripts / maps / tile_build / src / lib.rs

lib.rs64 lines · 2.9 KiBRaw
1//! MVT + PMTiles v3 tile-build tools for the Maps basemap.
2//!
3//! Replaces `tippecanoe` and `tile-join`. Neither has a Windows path, which would
4//! otherwise leave the `transit_stops` layer unbuildable on the dev box, so the
5//! whole tile chain is now cargo-only.
6//!
7//! Built in layers, each usable on its own:
8//!
9//! * [`geojson`] — the GeoJSONSeq reader the tilers share. Hand-rolled, not
10//! serde: `miniz_oxide` being the only dependency is what lets this crate
11//! build offline.
12//! * [`geom`] — projection, bounds, tile ranges and quantisation: lon/lat in,
13//! integer tile coordinates out.
14//! * [`clip`] — Liang-Barsky for lines, Sutherland-Hodgman for polygons, against
15//! a tile's buffered rect.
16//! * [`simplify`] — Douglas-Peucker once per feature to score every vertex, then
17//! a per-zoom threshold on those scores.
18//! * [`subdivide`] — tile one feature by walking the tile quadtree, so a
19//! continent-spanning feature costs one vertex pass per zoom level rather than
20//! one per tile it touches.
21//! * [`pyramid`] — the tile pyramid driver and the drop policy.
22//! * [`par`] — the thread budget (`--threads`, `MAPS_THREADS`) and the pool the
23//! tilers run on. Parallelism never changes an output byte.
24//! * [`spill`] — the on-disk record format and `tile_id`-range buckets the streaming
25//! tiler partitions through, so peak memory tracks the tile COUNT rather than the
26//! input bytes.
27//!
28//! [`geom`], [`clip`] and [`simplify`] compose in one fixed order; [`geom`]'s module
29//! docs give the pipeline.
30//!
31//! **Output is not byte-identical to tippecanoe, by design.** Its
32//! `--drop-densest-as-needed` is a lossy per-tile heuristic and
33//! `--extend-zooms-if-still-dropping` can push an archive past its own maximum
34//! zoom; we implement a deterministic policy and a fixed max zoom instead. Tests
35//! assert our own invariants — ring closure, winding order, Douglas-Peucker
36//! monotonicity, a PMTiles round trip — never equality with tippecanoe. See
37//! [`pyramid`] for the policy and its consequences.
38
39pub mod anon;
40pub mod boolean;
41pub mod churn;
42pub mod clip;
43pub mod geojson;
44pub mod geojson_extra;
45pub mod geom;
46pub mod manifest;
47pub mod overlay;
48pub mod par;
49pub mod progress;
50pub mod pyramid;
51pub mod simplify;
52pub mod spill;
53pub mod subdivide;
54pub mod timing;
55
56// The formats themselves live in `tilecodec`, shared with the Android renderer in
57// `:library:map` — it has to read exactly what this crate writes, and one codec is
58// one thing to keep in agreement with the published archive.
59//
60// Re-exported at the crate root rather than referenced as `tilecodec::mvt`, so
61// every `crate::mvt` / `crate::pmtiles` / `crate::gz` / `crate::proto` path in
62// `pyramid`, `spill` and `geom` keeps resolving unchanged. The extraction
63// is meant to be invisible to the tiler.
64pub use tilecodec::{gz, mamaps, mvt, pmtiles, proto};