{"record":{"id":"768100ec530c67eb","repo":"a-b-street/abstreet","slug":"couldn-t-find-a-border-near-start","errorCode":null,"errorMessage":"Couldn't find a {:?} border near start {}","messagePattern":"Couldn't find a (.+?) border near start (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"map_model/src/make/transit.rs","lineNumber":179,"sourceCode":"    let start = if map.boundary_polygon.contains_pt(route.shape.first_pt()) {\n        map.get_ts(stops[0]).driving_pos.lane()\n    } else {\n        // Find the first time the route shape hits the map boundary\n        let entry_pt = *map\n            .boundary_polygon\n            .get_outer_ring()\n            .all_intersections(&route.shape)\n            .get(0)\n            .ok_or_else(|| anyhow!(\"couldn't find where shape enters map\"))?;\n        // Snap that to a border\n        let borders = if route.route_type == RawTransitType::Bus {\n            &snapper.bus_incoming_borders\n        } else {\n            &snapper.train_incoming_borders\n        };\n        match borders.closest_pt(entry_pt, border_snap_threshold) {\n            Some((l, _)) => l,\n            None => bail!(\n                \"Couldn't find a {:?} border near start {}\",\n                route.route_type,\n                entry_pt\n            ),\n        }\n    };\n\n    let end_border = if map.boundary_polygon.contains_pt(route.shape.last_pt()) {\n        None\n    } else {\n        // Find the last time the route shape hits the map boundary\n        let exit_pt = *map\n            .boundary_polygon\n            .get_outer_ring()\n            .all_intersections(&route.shape)\n            .last()\n            .ok_or_else(|| anyhow!(\"couldn't find where shape leaves map\"))?;\n        // Snap that to a border","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/map_model/src/make/transit.rs#L161-L197","documentation":"A transit route's entry point (first stop's lane position, or the route shape's entry) must be near a map border that vehicles of the route type can enter through. If no incoming border of the required type (Bus or Train) is within border_snap_threshold, the route's start can't be connected and create_route bails.","triggerScenarios":"finalize_transit -> create_route where route.shape.first_pt() lies outside map.boundary_polygon (route starts off-map) and borders.closest_pt(entry_pt, 30m) returns None for the vehicle-type snapper.","commonSituations":"Regional GTFS routes that begin far outside the map boundary; borders snapped to the wrong type (train vs bus); map boundary excluding the route's first segment by more than 30 meters.","solutions":["Increase border_snap_threshold (currently 30 meters) to catch farther borders.","Check that the map's incoming borders include the route type (Bus/Train) near the entry point.","Trim the GTFS route shape/stops to the portion inside the map boundary."],"exampleFix":"// before\nlet border_snap_threshold = Distance::meters(30.0);\n// after\nlet border_snap_threshold = Distance::meters(100.0);","handlingStrategy":"try-catch","validationCode":"if !map.boundary_polygon.contains_pt(route.shape.first_pt()) {\n    let near = borders.closest_pt(entry_pt, border_snap_threshold);\n    if near.is_none() { /* trim route or widen threshold */ }\n}","typeGuard":null,"tryCatchPattern":"match create_route(...) {\n    Err(e) if e.to_string().contains(\"border near start\") => {\n        warn!(\"route {} starts off-map\", route.gtfs_id); skip();\n    }\n    other => other?,\n}","preventionTips":["Trim GTFS route shapes to the map boundary before import","Ensure border generation includes borders of every imported vehicle type","Set border_snap_threshold appropriately for regional routes"],"tags":["transit","gtfs","borders"],"backgroundTag":"resource-not-found","analyzedSha":"0964f29315820c91b171b585eb51e300164e9197","analyzedAt":"2026-09-13T18:02:03.421Z","contentChangedAt":"2026-09-13T18:02:03.421Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}