Skip to content

Commit

Permalink
Produce valid .osc files in the lane editor, by including version
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Mar 24, 2024
1 parent 5486508 commit 53b83f1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions osm2streets-js/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,9 @@ impl JsStreetNetwork {
pub fn way_to_xml(&self, id: i64) -> String {
let way = &self.ways[&osm::WayID(id)];
let mut out = format!(r#"<way id="{id}""#);
// TODO Add this to osm-reader
/*if let Some(version) = way.version {
if let Some(version) = way.version {
out.push_str(&format!(r#" version="{version}""#));
}*/
}
out.push_str(">\n");
for node in &way.nodes {
out.push_str(&format!(r#" <nd ref="{}"/>"#, node.0));
Expand Down
3 changes: 3 additions & 0 deletions streets_reader/src/osm_reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct Document {
pub struct Node {
pub pt: Pt2D,
pub tags: Tags,
pub version: Option<i32>,
}

#[derive(Clone)]
Expand All @@ -32,10 +33,12 @@ pub struct Way {
pub nodes: Vec<NodeID>,
pub pts: Vec<Pt2D>,
pub tags: Tags,
pub version: Option<i32>,
}

pub struct Relation {
pub tags: Tags,
/// Role, member
pub members: Vec<(String, OsmID)>,
pub version: Option<i32>,
}
19 changes: 17 additions & 2 deletions streets_reader/src/osm_reader/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ impl Document {
]));
}
}
Element::Node { id, lon, lat, tags } => {
Element::Node {
id,
lon,
lat,
tags,
version,
} => {
if doc.gps_bounds.is_none() {
warn!(
"No clipping polygon provided and the .osm is missing a <bounds> element, \
Expand All @@ -68,10 +74,16 @@ impl Document {
Node {
pt,
tags: make_tags(tags),
version,
},
);
}
Element::Way { id, node_ids, tags } => {
Element::Way {
id,
node_ids,
tags,
version,
} => {
if doc.ways.contains_key(&id) {
panic!("Duplicate {id}, your .osm is corrupt");
}
Expand All @@ -92,6 +104,7 @@ impl Document {
nodes,
pts,
tags: make_tags(tags),
version,
},
);
}
Expand All @@ -100,6 +113,7 @@ impl Document {
id,
tags,
mut members,
version,
} => {
if doc.relations.contains_key(&id) {
panic!("Duplicate {id}, your .osm is corrupt");
Expand All @@ -116,6 +130,7 @@ impl Document {
Relation {
tags: make_tags(tags),
members,
version,
},
);
}
Expand Down

0 comments on commit 53b83f1

Please sign in to comment.