maps: mamaps_planet5 keeps convention-only carriageway tables (#planet5)
- Commit
7a2bfd9d023d1ae52dc99a9656c8d295386cb769- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-14 01:13 UTC (22 days ago)
- Parents
975b013
The first planet5 planet run stopped in phase 5b: "a .mamaps body sets a marking convention but carries no carriageway table". A v10 body whose carriageway rows are all default is written as a sparse table with the convention and zero entries; it parses back as `convention: Some` with no rows, which the serializer (rightly) refuses, so a straight parse -> serialize_into_v11 fails on those tiles. The converter now re-supplies all-default rows for the roads layer in that case: the v11 body then carries the identical table (convention, zero entries) and parses back to exactly the input's Body, which --verify checks. Also: size_lab reads planet5 archives (dictionaries via zdicts_in / decompress_with) so its cmp/render/recompress modes work on them. Verified: cargo build; the planet rerun converts every tile (report).
Diff
scripts/maps/tile_build/examples/size_lab/main.rs
diff --git a/scripts/maps/tile_build/examples/size_lab/main.rs b/scripts/maps/tile_build/examples/size_lab/main.rsindex 51086564d7..c9e3f2ed00 100644--- a/scripts/maps/tile_build/examples/size_lab/main.rs+++ b/scripts/maps/tile_build/examples/size_lab/main.rs@@ -543,6 +543,8 @@ struct Arch { map: memmap2::Mmap, hdr: header::Header, dict: Dictionary,+ /// Planet5 archives' trained dictionaries.+ zd: Option<tile_build::mamaps::zdict::ZDicts>, } fn open(path: &str) -> Arch {@@ -550,7 +552,8 @@ fn open(path: &str) -> Arch { let map = unsafe { memmap2::Mmap::map(&f).expect("mmap") }; let hdr = header::Header::parse(&map[..tilecodec::stream::OPEN_PREFIX_BYTES as usize]).expect("header"); let dict = Dictionary::parse(&map[hdr.dict_offset as usize..hdr.dict_offset as usize + hdr.dict_len as usize]).expect("dict");- Arch { map, hdr, dict }+ let zd = tile_build::mamaps::read::zdicts_in(&hdr, &map).expect("dictionaries");+ Arch { map, hdr, dict, zd } } fn entries(a: &Arch) -> Vec<Ent> {@@ -627,7 +630,7 @@ impl Acc { fn raw_of(a: &Arch, e: &Ent) -> Vec<u8> { let stored = &a.map[e.off as usize..e.off as usize + e.len as usize];- tile_build::mamaps::read::decompress(a.hdr.compression, stored).expect("inflate")+ tile_build::mamaps::read::decompress_with(a.hdr.compression, stored, a.zd.as_ref()).expect("inflate") } fn cmd_bodies(path: &str, per_zoom: usize, out_dir: &str) {@@ -708,7 +711,7 @@ fn cmd_bodies(path: &str, per_zoom: usize, out_dir: &str) { // Copied first so the timing below measures decode, not a page fault on the mmap. let stored = a.map[e.off as usize..e.off as usize + e.len as usize].to_vec(); let ti = Instant::now();- let raw = tile_build::mamaps::read::decompress(a.hdr.compression, &stored).expect("inflate");+ let raw = tile_build::mamaps::read::decompress_with(a.hdr.compression, &stored, a.zd.as_ref()).expect("inflate"); let t_inf = ti.elapsed().as_nanos() as u64; let tp = Instant::now(); let body = Body::parse(&raw).expect("parse");
scripts/maps/tile_build/examples/size_lab/more.rs
diff --git a/scripts/maps/tile_build/examples/size_lab/more.rs b/scripts/maps/tile_build/examples/size_lab/more.rsindex a86052b104..7381076661 100644--- a/scripts/maps/tile_build/examples/size_lab/more.rs+++ b/scripts/maps/tile_build/examples/size_lab/more.rs@@ -42,7 +42,7 @@ impl TileIndex { fn body_at(a: &Arch, off: u64, len: u32) -> Body { let stored = &a.map[off as usize..off as usize + len as usize];- let raw = tile_build::mamaps::read::decompress(a.hdr.compression, stored).expect("inflate");+ let raw = tile_build::mamaps::read::decompress_with(a.hdr.compression, stored, a.zd.as_ref()).expect("inflate"); Body::parse(&raw).expect("parse") } @@ -99,7 +99,7 @@ fn cmd_recompress(path: &str, out_dir: &str) { for e in chunk { let stored = a.map[e.off as usize..e.off as usize + e.len as usize].to_vec(); let t = Instant::now();- let raw = tile_build::mamaps::read::decompress(a.hdr.compression, &stored).expect("inflate");+ let raw = tile_build::mamaps::read::decompress_with(a.hdr.compression, &stored, a.zd.as_ref()).expect("inflate"); let _ = Body::parse(&raw).expect("parse"); let t_now = t.elapsed().as_nanos() as u64; let p = &raw[H..];
scripts/maps/tile_build/src/bin/mamaps_planet5.rs
diff --git a/scripts/maps/tile_build/src/bin/mamaps_planet5.rs b/scripts/maps/tile_build/src/bin/mamaps_planet5.rsindex 26d39008c0..f19d4a666f 100644--- a/scripts/maps/tile_build/src/bin/mamaps_planet5.rs+++ b/scripts/maps/tile_build/src/bin/mamaps_planet5.rs@@ -96,7 +96,22 @@ fn to_v11(map: &[u8], hdr: &Header, off: u64, len: u32) -> Result<(Vec<u8>, Body let raw = decompress(hdr.compression, stored).map_err(|e| e.0)?; let body = Body::parse(&raw).map_err(|e| e.0)?; let mut s = Scratch::default();- let v11 = serialize_into_v11(&body, &mut s).map_err(|e| e.0)?.to_vec();+ // A v10 sparse carriageway table whose rows are all default is written as a convention with+ // zero entries, and parses back as `convention: Some` with no rows -- a model the serializer+ // refuses. Re-supply the all-default rows for the roads layer so the v11 body carries the+ // identical table (zero entries + the convention) and parses back to the same `Body`.+ let v11 = if body.convention.is_some() && body.carriageways.is_empty() {+ let mut b = body.clone();+ let roads = tile_build::mamaps::dict::LAYER_ROADS;+ let n = b+ .layer(roads)+ .map(|l| l.features.len())+ .ok_or("a body with a marking convention and no roads layer")?;+ b.carriageways = vec![(roads, vec![tile_build::mamaps::body::Carriageway::default(); n])];+ serialize_into_v11(&b, &mut s).map_err(|e| e.0)?.to_vec()+ } else {+ serialize_into_v11(&body, &mut s).map_err(|e| e.0)?.to_vec()+ }; Ok((v11, body)) }