fn region_block() -> Vec { let mut st = StringTable::new(); let k_amenity = st.id("amenity"); let v_cafe = st.id("cafe"); let k_name = st.id("name"); let v_inside = st.id("Inside Cafe"); let v_outside = st.id("Outside Cafe"); let k_place = st.id("place"); let v_town = st.id("town"); let v_testville = st.id("Testville"); let k_type = st.id("type"); let k_boundary = st.id("boundary"); // also the value of `type=*` let v_admin = st.id("administrative"); let k_admin_level = st.id("admin_level"); let v_eight = st.id("8"); let v_green = st.id("Green Boundary"); let k_leisure = st.id("leisure"); let v_park = st.id("park"); let role_outer = st.id("outer"); let role_label = st.id("label"); let nodes: Vec = REGION_NODES .iter() .map(|(id, lat, lon)| { let tags = match *id { REGION_INSIDE_CAFE_ID => vec![(k_amenity, v_cafe), (k_name, v_inside)], REGION_OUTSIDE_CAFE_ID => vec![(k_amenity, v_cafe), (k_name, v_outside)], REGION_TOWN_NODE_ID => vec![(k_place, v_town), (k_name, v_testville)], _ => Vec::new(), }; (*id, *lat, *lon, tags) }) .collect(); let dense = dense_group(&nodes); let ways = [way(REGION_RING_WAY_ID, &[], &[11, 12, 13, 14, 11])]; let rels = [relation( REGION_BOUNDARY_ID, &[ (k_type, k_boundary), (k_boundary, v_admin), (k_admin_level, v_eight), (k_name, v_green), (k_leisure, v_park), ], // Ascending, so the delta encoding stays small. &[(REGION_TOWN_NODE_ID, role_label, 0), (REGION_RING_WAY_ID, role_outer, 1)], )]; let mut node_group = Vec::new(); bytes_field(2, &dense, &mut node_group); let mut way_group = Vec::new(); for w in &ways { bytes_field(3, w, &mut way_group); } let mut rel_group = Vec::new(); for r in &rels { bytes_field(4, r, &mut rel_group); } let mut block = Vec::new(); bytes_field(1, &st.encode(), &mut block); bytes_field(2, &node_group, &mut block); bytes_field(2, &way_group, &mut block); bytes_field(2, &rel_group, &mut block); varint_field(17, 100, &mut block); // granularity block } /// Write the region-link fixture to a unique temp directory. pub fn write_region_sample(tag: &str) -> (std::path::PathBuf, std::path::PathBuf) { write_pbf(tag, &pbf_from_block(®ion_block())) } // ---- the vector-layer fixture -------------------------------------------- // // A SECOND fixture rather than more features in the one above. The road-graph and // POI tests assert exact counts against it (`ways.len() == 3`, `records == 3`, // `NODE_COUNT`), so every addition there ripples into four modules' tests and // makes each of them slightly less about what it is testing. The vector layers // need different elements anyway. /// `highway=speed_camera` with a direction. pub const CAMERA_NODE_ID: i64 = 1001; /// `man_made=surveillance` + `surveillance:type=ALPR` + a Flock operator, so it /// hits the ALPR branch by two independent signals. pub const ALPR_NODE_ID: i64 = 1003; pub const STOP_SIGN_NODE_ID: i64 = 1006; pub const SIGNALS_NODE_ID: i64 = 1007; /// A named cafe: tagged, but not road furniture. The negative control. pub const LAYERS_CAFE_NODE_ID: i64 = 1008; /// `highway=residential` + `maxspeed=25 mph`, the raw-string case. pub const MAXSPEED_WAY_ID: i64 = 3001; /// `highway=motorway` + `maxspeed=none`, which the graph's parser would collapse /// to 0 and this layer must keep verbatim. Also the `roads` layer's /// fully-attributed way: a oneway bridge with lanes, turn lanes, width and layer. pub const MAXSPEED_NONE_WAY_ID: i64 = 3002; /// `highway=service` with no speed limit at all. The negative control. pub const NO_MAXSPEED_WAY_ID: i64 = 3003; /// `railway=subway`, a transit line in its own right. pub const RAILWAY_WAY_ID: i64 = 5001; /// `railway=narrow_gauge`, which folds into `rail`. pub const NARROW_GAUGE_WAY_ID: i64 = 5002; /// `railway=platform`, which is not a line. The negative control. pub const PLATFORM_WAY_ID: i64 = 5003; /// A **closed** `railway=platform` way, carried by the route relation below as a /// `role=platform` member. The shape that drew a box around every station. pub const ROUTE_PLATFORM_WAY_ID: i64 = 5004; /// `type=route` + `route=subway`, with a colour and a ref, over two member ways /// plus a `role=platform` member that is not part of the line. pub const ROUTE_RELATION_ID: i64 = 9001; /// `type=route` + `route=bus`, which this layer drops. pub const BUS_RELATION_ID: i64 = 9002; /// `type=boundary` + `boundary=administrative` + `admin_level=8`, with an outer /// ring split across two ways and one inner ring (a hole). pub const ADMIN_CITY_RELATION_ID: i64 = 9101; /// The same, but `admin_level=6`: a county, which the city layer drops. pub const ADMIN_COUNTY_RELATION_ID: i64 = 9102; /// The corners of [`ROUTE_PLATFORM_WAY_ID`], well clear of every other fixture /// coordinate so its absence from the route's geometry can be asserted directly. const ROUTE_PLATFORM_NODES: [(i64, i32, i32); 4] = [ (2201, 377_950_000, -1_224_050_000), (2202, 377_950_000, -1_224_040_000), (2203, 377_960_000, -1_224_040_000), (2204, 377_960_000, -1_224_050_000), ]; /// Way ids the admin boundary is assembled from. pub const ADMIN_OUTER_WAY_A: i64 = 7001; pub const ADMIN_OUTER_WAY_B: i64 = 7002; pub const ADMIN_INNER_WAY: i64 = 7003; /// Node ids the vector-layer fixture's ways are built from. const WAY_NODE_IDS: [i64; 6] = [2001, 2002, 2003, 2004, 2005, 2006]; /// The admin boundary's outer ring corners, then its hole's corners. A 0.04-degree /// square near the other fixture geometry, with a 0.01-degree hole inside it. const ADMIN_NODES: [(i64, i32, i32); 8] = [ (2101, 378_000_000, -1_224_000_000), (2102, 378_000_000, -1_223_600_000), (2103, 378_400_000, -1_223_600_000), (2104, 378_400_000, -1_224_000_000), (2111, 378_100_000, -1_223_900_000), (2112, 378_100_000, -1_223_800_000), (2113, 378_200_000, -1_223_800_000), (2114, 378_200_000, -1_223_900_000), ]; /// One node in the vector-layer fixture: `(id, lat_e7, lon_e7, tags)`. type FixtureNode = (i64, i32, i32, Vec<(u32, u32)>);