mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-26 07:52:05 +03:00
dont conflict between synthetic OSM IDs created by map_editor and by map clipping
This commit is contained in:
parent
1edb3cf81b
commit
9d237f314b
@ -50,7 +50,8 @@ pub fn clip_map(map: &mut RawMap, timer: &mut Timer) {
|
|||||||
> 1
|
> 1
|
||||||
{
|
{
|
||||||
let mut copy = map.intersections[&move_i].clone();
|
let mut copy = map.intersections[&move_i].clone();
|
||||||
copy.orig_id.osm_node_id = map.new_osm_node_id();
|
// Start low, so we don't conflict with IDs generated by map_editor.
|
||||||
|
copy.orig_id.osm_node_id = map.new_osm_node_id(-1);
|
||||||
|
|
||||||
// Nothing deletes intersections yet, so this is safe.
|
// Nothing deletes intersections yet, so this is safe.
|
||||||
move_i = StableIntersectionID(map.intersections.len());
|
move_i = StableIntersectionID(map.intersections.len());
|
||||||
|
@ -235,7 +235,7 @@ impl Model {
|
|||||||
intersection_type: IntersectionType::StopSign,
|
intersection_type: IntersectionType::StopSign,
|
||||||
label: None,
|
label: None,
|
||||||
orig_id: OriginalIntersection {
|
orig_id: OriginalIntersection {
|
||||||
osm_node_id: self.map.new_osm_node_id(),
|
osm_node_id: self.map.new_osm_node_id(time_to_id()),
|
||||||
},
|
},
|
||||||
synthetic: true,
|
synthetic: true,
|
||||||
})
|
})
|
||||||
@ -350,7 +350,7 @@ impl Model {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let osm_way_id = self.map.new_osm_way_id();
|
let osm_way_id = self.map.new_osm_way_id(time_to_id());
|
||||||
let mut osm_tags = BTreeMap::new();
|
let mut osm_tags = BTreeMap::new();
|
||||||
osm_tags.insert(osm::SYNTHETIC.to_string(), "true".to_string());
|
osm_tags.insert(osm::SYNTHETIC.to_string(), "true".to_string());
|
||||||
osm_tags.insert(
|
osm_tags.insert(
|
||||||
@ -762,7 +762,7 @@ impl Model {
|
|||||||
.create_building(RawBuilding {
|
.create_building(RawBuilding {
|
||||||
polygon: Polygon::rectangle(center, BUILDING_LENGTH, BUILDING_LENGTH),
|
polygon: Polygon::rectangle(center, BUILDING_LENGTH, BUILDING_LENGTH),
|
||||||
osm_tags: BTreeMap::new(),
|
osm_tags: BTreeMap::new(),
|
||||||
osm_way_id: self.map.new_osm_way_id(),
|
osm_way_id: self.map.new_osm_way_id(time_to_id()),
|
||||||
parking: None,
|
parking: None,
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -831,3 +831,11 @@ impl ObjectID for ID {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't conflict with the synthetic IDs generated by map clipping.
|
||||||
|
fn time_to_id() -> i64 {
|
||||||
|
-1 * (std::time::SystemTime::now()
|
||||||
|
.duration_since(std::time::UNIX_EPOCH)
|
||||||
|
.unwrap()
|
||||||
|
.as_secs() as i64)
|
||||||
|
}
|
||||||
|
@ -186,10 +186,9 @@ impl RawMap {
|
|||||||
results
|
results
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_osm_node_id(&self) -> i64 {
|
pub fn new_osm_node_id(&self, start: i64) -> i64 {
|
||||||
// Slow, but deterministic.
|
// Slow, but deterministic.
|
||||||
// TODO Argh, these will conflict between different maps! Is that a problem?
|
let mut osm_node_id = start;
|
||||||
let mut osm_node_id = -1;
|
|
||||||
loop {
|
loop {
|
||||||
if self
|
if self
|
||||||
.intersections
|
.intersections
|
||||||
@ -203,10 +202,9 @@ impl RawMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_osm_way_id(&self) -> i64 {
|
pub fn new_osm_way_id(&self, start: i64) -> i64 {
|
||||||
// Slow, but deterministic.
|
// Slow, but deterministic.
|
||||||
// TODO Argh, these will conflict between different maps! Is that a problem?
|
let mut osm_way_id = start;
|
||||||
let mut osm_way_id = -1;
|
|
||||||
loop {
|
loop {
|
||||||
if self
|
if self
|
||||||
.roads
|
.roads
|
||||||
|
Loading…
Reference in New Issue
Block a user