This commit is contained in:
Dongho Kim
2025-12-18 07:36:51 +09:00
parent 4b606e28da
commit 1dcdce3ef1
52 changed files with 3872 additions and 1788 deletions

View File

@@ -0,0 +1,41 @@
use std::collections::HashMap;
// Store railway ways for deferred insertion (after relation processing for colors)
pub struct RailwayWay {
pub id: i64,
pub tags: HashMap<String, String>,
pub points: Vec<u8>, // Serialized line blob
pub first_lat: f64,
pub first_lon: f64,
}
pub struct RailwayStore {
ways: HashMap<i64, RailwayWay>, // way_id -> railway data
way_colors: HashMap<i64, String>, // way_id -> colour from route relation
}
impl RailwayStore {
pub fn new() -> Self {
Self {
ways: HashMap::new(),
way_colors: HashMap::new(),
}
}
pub fn insert_way(&mut self, id: i64, tags: HashMap<String, String>, points: Vec<u8>, first_lat: f64, first_lon: f64) {
self.ways.insert(id, RailwayWay { id, tags, points, first_lat, first_lon });
}
pub fn set_color(&mut self, way_id: i64, color: String) {
// Only set if not already set (first route relation wins)
self.way_colors.entry(way_id).or_insert(color);
}
pub fn get_color(&self, way_id: i64) -> Option<&String> {
self.way_colors.get(&way_id)
}
pub fn into_data(self) -> (HashMap<i64, RailwayWay>, HashMap<i64, String>) {
(self.ways, self.way_colors)
}
}