open-standards/map/map-rs/crates/map-pmtiles/examples/write_archive.rs
Transaction Science 57a53fc492 examples: reproduce the cross-tool ingest validations
Two small examples that emit the ingest artifacts a real reference tool can
verify, so the interop claims are checkable, not just asserted:

- jcp-bridge mint_token: mints a JCP-grant-backed OAuth access token + prints
  the issuer pubkey. Verified independently with python `cryptography`
  (EdDSA) — signature valid, RFC 9068 at+jwt header, scope/aud/joule_budget_uj
  claims intact — exactly what an MCP/OAuth resource server checks.
- map-pmtiles write_archive: writes a .pmtiles file. Read back by the
  canonical JS `pmtiles` reference reader: header + metadata parse and all
  tiles (incl. z14) return byte-identical, confirming the Hilbert tile-id +
  varint directory + 127-byte header match the spec implementation.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-25 19:11:08 -04:00

23 lines
837 B
Rust

//! Write a real `.pmtiles` archive to disk so the canonical pmtiles readers
//! (JS/Go/Python) can be pointed at it — proves the writer is interoperable,
//! not just self-consistent.
use map_pmtiles::{write, TileType};
use serde_json::json;
fn main() {
let path = std::env::args().nth(1).unwrap_or_else(|| "/tmp/map_demo.pmtiles".to_string());
let tiles = vec![
(0u8, 0u32, 0u32, b"hello-root".to_vec()),
(2, 1, 1, b"tile-2-1-1".to_vec()),
(2, 3, 2, b"tile-2-3-2".to_vec()),
(14, 8000, 5000, b"deep-tile".to_vec()),
];
let archive = write(
tiles,
&json!({ "name": "map-demo", "attribution": "transaction.science" }),
TileType::Mvt,
);
std::fs::write(&path, &archive).expect("write archive");
println!("wrote {} bytes to {path}", archive.len());
}