mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 15:33:44 +03:00
WIP trying to solve problem of driving traces not matching up sometimes
This commit is contained in:
parent
f7f9b5ab70
commit
e4dc075871
@ -13,7 +13,9 @@ pub fn split_up_roads(input: &raw_data::Map, elevation: &srtm::Elevation) -> raw
|
||||
for r in &input.roads {
|
||||
for (idx, raw_pt) in r.points.iter().enumerate() {
|
||||
let pt = raw_pt.to_hashable();
|
||||
let count = (*counts_per_pt.entry(pt).or_insert(0) += 1);
|
||||
counts_per_pt.entry(pt).or_insert(0);
|
||||
let count = counts_per_pt[&pt] + 1;
|
||||
counts_per_pt.insert(pt, count);
|
||||
|
||||
if count == 2 {
|
||||
intersections.insert(pt);
|
||||
|
@ -61,26 +61,28 @@ impl Traversable {
|
||||
let pts = &map.get_l(id).lane_center_pts;
|
||||
let len = pts.length();
|
||||
let (polyline, remainder) = pts.reversed().slice(start, end);
|
||||
let actual_len = polyline.length();
|
||||
Some((
|
||||
Trace {
|
||||
polyline,
|
||||
segments: vec![TraceSegment {
|
||||
on: *self,
|
||||
start_dist: len - start,
|
||||
end_dist: len - end,
|
||||
end_dist: len - (start + actual_len),
|
||||
}],
|
||||
},
|
||||
remainder,
|
||||
))
|
||||
} else {
|
||||
let (polyline, remainder) = map.get_l(id).lane_center_pts.slice(start, end);
|
||||
let actual_len = polyline.length();
|
||||
Some((
|
||||
Trace {
|
||||
polyline,
|
||||
segments: vec![TraceSegment {
|
||||
on: *self,
|
||||
start_dist: start,
|
||||
end_dist: end,
|
||||
end_dist: start + actual_len,
|
||||
}],
|
||||
},
|
||||
remainder,
|
||||
@ -94,13 +96,14 @@ impl Traversable {
|
||||
} else {
|
||||
let (polyline, remainder) =
|
||||
PolyLine::new(vec![t.line.pt1(), t.line.pt2()]).slice(start, end);
|
||||
let actual_len = polyline.length();
|
||||
Some((
|
||||
Trace {
|
||||
polyline,
|
||||
segments: vec![TraceSegment {
|
||||
on: *self,
|
||||
start_dist: start,
|
||||
end_dist: end,
|
||||
end_dist: start + actual_len,
|
||||
}],
|
||||
},
|
||||
remainder,
|
||||
@ -141,4 +144,12 @@ impl Trace {
|
||||
self.polyline.extend(other.polyline);
|
||||
self.segments.extend(other.segments);
|
||||
}
|
||||
|
||||
pub fn debug(&self) {
|
||||
println!("Trace with {} segments", self.segments.len());
|
||||
println!(" - PolyLine({} ... {})", self.polyline.points()[0], self.polyline.points().last().unwrap());
|
||||
for s in &self.segments {
|
||||
println!(" - {:?} [{} to {}]", s.on, s.start_dist, s.end_dist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -193,6 +193,12 @@ impl Router {
|
||||
let (piece, new_dist_left) = Traversable::Lane(next_lane)
|
||||
.slice(false, map, 0.0 * si::M, dist_left)
|
||||
.unwrap();
|
||||
if piece.polyline.points()[0] != *result.polyline.points().last().unwrap() {
|
||||
println!("so far");
|
||||
result.debug();
|
||||
println!("new piece");
|
||||
piece.debug();
|
||||
}
|
||||
result.extend(piece);
|
||||
dist_left = new_dist_left;
|
||||
last_lane = Some(next_lane);
|
||||
|
Loading…
Reference in New Issue
Block a user