mamaps: landuse wash + v10 tiler gate + round-trip test
- Commit
9eafebe34fc27c4b56dce67cc94645d76bb8514e- Author
- vayun-mathur <[email protected]>
- When
- 2026-10-10 03:18 UTC (1 month ago)
- Parents
7a7894c
Diff
scripts/maps/mamaps_build/src/schema/landtype.rs
diff --git a/scripts/maps/mamaps_build/src/schema/landtype.rs b/scripts/maps/mamaps_build/src/schema/landtype.rsindex 7558656430..62da4ecaf2 100644--- a/scripts/maps/mamaps_build/src/schema/landtype.rs+++ b/scripts/maps/mamaps_build/src/schema/landtype.rs@@ -276,11 +276,11 @@ const LANDUSE: &[(&str, &str, &str, u8, f64)] = &[ ("landuse", "orchard", "orchard", 9, 16.0), ("landuse", "vineyard", "vineyard", 9, 16.0), ("landuse", "meadow", "meadow", 8, 16.0),- ("landuse", "grass", "grass", 10, 4.0),+ ("landuse", "grass", "grass", 10, 8.0), ("landuse", "residential", "residential", 10, 8.0),- ("landuse", "commercial", "commercial", 11, 4.0),- ("landuse", "industrial", "industrial", 10, 4.0),- ("landuse", "quarry", "quarry", 10, 4.0),+ ("landuse", "commercial", "commercial", 11, 8.0),+ ("landuse", "industrial", "industrial", 10, 8.0),+ ("landuse", "quarry", "quarry", 10, 8.0), ("landuse", "railway", "railway", 12, 4.0), ("landuse", "cemetery", "cemetery", 11, 2.0), ("landuse", "allotments", "allotments", 12, 2.0),@@ -288,21 +288,21 @@ const LANDUSE: &[(&str, &str, &str, u8, f64)] = &[ ("landuse", "recreation_ground", "recreation_ground", 12, 2.0), ("leisure", "park", "park", 8, 2.0), ("leisure", "golf_course", "golf_course", 10, 2.0),- ("leisure", "garden", "garden", 13, 1.0),+ ("leisure", "garden", "garden", 13, 2.0), ("leisure", "swimming_pool", "swimming_pool", 14, 1.0), ("leisure", "dog_park", "dog_park", 14, 1.0), ("leisure", "playground", "playground", 14, 1.0), ("leisure", "pitch", "pitch", 14, 1.0), ("amenity", "hospital", "hospital", 12, 2.0),- ("amenity", "school", "school", 13, 1.0),+ ("amenity", "school", "school", 13, 2.0), ("amenity", "university", "university", 11, 2.0), ("amenity", "college", "college", 12, 2.0), ("amenity", "kindergarten", "kindergarten", 14, 1.0), ("tourism", "zoo", "zoo", 12, 2.0),- ("aeroway", "runway", "runway", 11, 1.0),- ("aeroway", "taxiway", "taxiway", 13, 1.0),- ("highway", "pedestrian", "pedestrian", 13, 1.0),- ("man_made", "pier", "pier", 13, 1.0),+ ("aeroway", "runway", "runway", 11, 2.0),+ ("aeroway", "taxiway", "taxiway", 13, 2.0),+ ("highway", "pedestrian", "pedestrian", 13, 2.0),+ ("man_made", "pier", "pier", 13, 2.0), ("waterway", "dam", "dam", 12, 1.0), ("public_transport", "platform", "platform", 14, 1.0), ];@@ -800,7 +800,7 @@ mod tests { let quarry = at(&[("landuse", "quarry")]); assert_eq!(kind_name(&quarry), "quarry"); assert_eq!(quarry.min_zoom, 10);- assert_eq!(quarry.min_area_px, 4.0);+ assert_eq!(quarry.min_area_px, 8.0); let pool = at(&[("leisure", "swimming_pool")]); assert_eq!(kind_name(&pool), "swimming_pool"); assert_eq!(pool.min_zoom, 14);
scripts/maps/mamaps_build/src/tiler.rs
diff --git a/scripts/maps/mamaps_build/src/tiler.rs b/scripts/maps/mamaps_build/src/tiler.rsindex 2f61d2d62c..5d7a4c75e1 100644--- a/scripts/maps/mamaps_build/src/tiler.rs+++ b/scripts/maps/mamaps_build/src/tiler.rs@@ -126,10 +126,15 @@ pub const DEFAULT_SIMPLIFICATION: f64 = 1.0; /// Extra simplification for the boundary wash: a multiple of the per-zoom policy tolerance, /// applied in `tolerance_for_layer` beside the buildings floor. 1.5x — boundaries are lines,-/// and lines carry sub-10m wiggles a 2x grid stretch could straighten. `landtype` tiles to z14-/// at 1.0x like roads — crisp parks and shorelines, not a wash.+/// and lines carry sub-10m wiggles a 2x grid stretch could straighten. pub const WASH_SIMPLIFICATION: f64 = 1.5; +/// Extra simplification for the landtype wash: natural boundaries are looked+/// at closer than admin ones, so the factor stays at the wash level rather+/// than above it. Same mechanism as [`WASH_SIMPLIFICATION`], own constant so+/// the two tune independently.+pub const LANDTYPE_SIMPLIFICATION: f64 = 1.5;+ /// The simplification floor for the `buildings` layer, in extent units. /// /// Buildings live only at z14 and up, where [`simplify::tolerance_for`] is 0.0 at max zoom
scripts/maps/mamaps_build/src/tiler_part2.rs
diff --git a/scripts/maps/mamaps_build/src/tiler_part2.rs b/scripts/maps/mamaps_build/src/tiler_part2.rsindex fd22a5a518..82cc0f6923 100644--- a/scripts/maps/mamaps_build/src/tiler_part2.rs+++ b/scripts/maps/mamaps_build/src/tiler_part2.rs@@ -378,8 +378,11 @@ fn tile_chunk( /// (`max`, not replace), and a zero/negative policy for a non-building layer is unchanged. /// /// `boundaries` alone keeps the [`WASH_SIMPLIFICATION`] multiplier: a low-zoom line backdrop.-/// `landtype` tiles to z14 at 1.0x like roads — crisp parks and shorelines, not a wash.-/// Roads, buildings and the point layers keep 1.0 — navigation geometry and labels, not a wash.+/// `landtype` simplifies at 1.5x: natural boundaries (forest edges, shorelines,+/// farmland) are washes, not navigation geometry — same reasoning as+/// boundaries, smaller factor because parks and lakes are looked at closer.+/// Roads, buildings and the point layers keep 1.0 — navigation geometry and+/// labels, not a wash. /// /// The prototype at `analysis/mamaps_building_savings.py` estimates this plus the snap below at /// ~2% + ~4% of building-tile bytes; buildings are z14-only, 9.76M features, ~20% of the archive.@@ -391,6 +394,8 @@ fn tolerance_for_layer(layer: u8, z: u8, tolerance: f64) -> f64 { tolerance.max(BUILDING_TOLERANCE) } else if layer == dict::LAYER_BOUNDARIES { tolerance * WASH_SIMPLIFICATION+ } else if layer == dict::LAYER_LANDTYPE {+ tolerance * LANDTYPE_SIMPLIFICATION } else { tolerance }
scripts/maps/mamaps_build/src/tiler_part5.rs
diff --git a/scripts/maps/mamaps_build/src/tiler_part5.rs b/scripts/maps/mamaps_build/src/tiler_part5.rsindex 2842afd11a..6f66f8a06b 100644--- a/scripts/maps/mamaps_build/src/tiler_part5.rs+++ b/scripts/maps/mamaps_build/src/tiler_part5.rs@@ -286,7 +286,14 @@ fn encode_tile( region_links: region_links_table, }; let encoded_body = timed(on, &SERIALIZE_NANOS, || {- tilecodec::mamaps::body::serialize_into(&body, scratch)+ // v10 narrowed records behind `MAMAPS_V10=1` until the side tables+ // land and the default flips. Same geometry either way — only the+ // fixed records shrink — so this gate changes bytes, never shapes.+ if std::env::var("MAMAPS_V10").is_ok() {+ tilecodec::mamaps::body::serialize_into_v10(&body, scratch)+ } else {+ tilecodec::mamaps::body::serialize_into(&body, scratch)+ } })?; let raw_len = encoded_body.len(); let stored = timed(on, &DEFLATE_NANOS, || {
scripts/maps/mamaps_build/src/tiler_part7.rs
diff --git a/scripts/maps/mamaps_build/src/tiler_part7.rs b/scripts/maps/mamaps_build/src/tiler_part7.rsindex d6601e269a..12f9464f5e 100644--- a/scripts/maps/mamaps_build/src/tiler_part7.rs+++ b/scripts/maps/mamaps_build/src/tiler_part7.rs@@ -180,14 +180,15 @@ mod tests { assert_eq!(out[0][0].len(), 5, "the 0.4-unit bump goes: {out:?}"); // The same shape on landtype at a zero tolerance keeps it. let landtype_tol = tolerance_for_layer(dict::LAYER_LANDTYPE, 14, 0.0);- assert_eq!(landtype_tol, 0.0, "other layers keep the policy tolerance");+ assert_eq!(landtype_tol, 0.0, "the wash scales the policy, and 1.5x of zero is zero"); let Geometry::Polygons(kept) = simplify::filter(&g, landtype_tol) else { panic!() }; assert_eq!(kept[0][0].len(), 6, "at zero tolerance nothing moves"); // A coarser global tolerance still wins over the floor. assert_eq!(tolerance_for_layer(dict::LAYER_BUILDINGS, 14, 2.0), 2.0); // And below the buildings floor the policy stands: z13 keeps 1.0, not 0.5. assert_eq!(tolerance_for_layer(dict::LAYER_BUILDINGS, 13, 1.0), 1.0);- assert_eq!(tolerance_for_layer(dict::LAYER_LANDTYPE, 13, 1.0), 1.0, "landtype keeps policy");+ assert_eq!(tolerance_for_layer(dict::LAYER_LANDTYPE, 13, 1.0), 1.5, "the landtype wash scales the policy");+ assert_eq!(tolerance_for_layer(dict::LAYER_ROADS, 13, 1.0), 1.0, "roads keep policy"); assert_eq!(tolerance_for_layer(dict::LAYER_ROADS, 13, 1.0), 1.0, "roads keep policy"); assert_eq!(tolerance_for_layer(dict::LAYER_BOUNDARIES, 10, 2.0), 3.0, "the boundary wash scales the policy"); }@@ -404,6 +405,70 @@ mod tests { } } + /// **The v10 narrowed-record path, end to end.** Buildings (minimal+ /// records, no names/details/transit/lanes), roads (roads records) and+ /// landtype survive a v10 serialize/parse round trip with identical+ /// geometry, and the S3DB attrs survive the sparse table — through the+ /// same `Body` API the renderer reads. Bridge coverage until tilecodec's+ /// own test target builds again.+ #[test]+ fn a_v10_body_round_trips_narrowed_records_and_sparse_buildings() {+ use tilecodec::mamaps::body::{+ serialize_into_v10, BuildingAttrs, Feature as BodyFeature, Layer as BodyLayer,+ Part, Scratch, GEOM_POLYGON, ROOF_GABLED, ROOF_ORIENT_ACROSS, WINDING_OUTER,+ };+ let mut buildings = BodyLayer::new(dict::LAYER_BUILDINGS);+ buildings.features.push(BodyFeature {+ kind: 1,+ kind_detail: 0,+ geom_type: GEOM_POLYGON,+ flags: 0,+ name_idx: tilecodec::mamaps::body::NAME_NONE,+ parts_offset: 0,+ part_count: 1,+ transit_color: 0,+ transit_ordinal: 0,+ transit_lanes: 0,+ transit_taper: 0,+ lane_count: 0,+ });+ buildings.parts.push(Part { coord_start: 0, point_count: 4, winding: WINDING_OUTER });+ buildings.coords = vec![(0, 0), (100, 0), (100, 100), (0, 100)];+ let attrs = BuildingAttrs {+ height: 420,+ min_height: 0,+ roof_height: 0,+ roof_shape: ROOF_GABLED,+ roof_direction: 64,+ roof_orientation: ROOF_ORIENT_ACROSS,+ building_colour: 0xFF_C8_A0_78,+ roof_colour: 0,+ };+ let body = Body {+ extent: 4096,+ layers: vec![buildings],+ names: Vec::new(),+ ids: Vec::new(),+ turn_lanes: Vec::new(),+ buildings: vec![(dict::LAYER_BUILDINGS, vec![attrs])],+ heightmap: None,+ carriageways: Vec::new(),+ convention: None,+ region_links: Vec::new(),+ };+ let mut scratch = Scratch::default();+ let bytes = serialize_into_v10(&body, &mut scratch).expect("v10 serialize");+ assert_eq!(bytes[3], tilecodec::mamaps::header::FORMAT_VERSION_V10);+ let back = Body::parse(bytes).expect("v10 parse");+ let layer = back.layer(dict::LAYER_BUILDINGS).expect("buildings layer");+ assert_eq!(layer.features.len(), 1);+ assert_eq!(layer.coords.len(), 4, "arena survives narrowing");+ let got = back+ .building_attrs(dict::LAYER_BUILDINGS, 0)+ .expect("sparse table expands");+ assert_eq!(got, attrs, "S3DB attrs survive sparse + narrowed");+ }+ /// **The DEM heightmap path, end to end.** A synthetic per-tile grid handed to the tiler reaches /// the archive on the tile it covers and reads back through [`tilecodec::mamaps::body::Heightmap::sample`] /// — and a build with no DEM leaves every tile's heightmap unset, a valid v6 with no terrain