Skip to content

Commit

Permalink
Work on cycleway snapping for St George:
Browse files Browse the repository at this point in the history
- relax is_cycleway definition to allow sidewalks
- dropdown shortcut for debug steps
- the cycleway itself may be short, ignore it
- the short road between the main road and intersection may have been merged
  • Loading branch information
dabreegster committed Mar 10, 2023
1 parent 806be52 commit 99637e5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 19 deletions.
2 changes: 1 addition & 1 deletion osm2streets/src/road.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl Road {
for spec in &self.lane_specs_ltr {
if spec.lt == LaneType::Biking {
bike = true;
} else if spec.lt != LaneType::Shoulder {
} else if !spec.lt.is_walkable() {
return false;
}
}
Expand Down
11 changes: 10 additions & 1 deletion osm2streets/src/transform/separate_cycletracks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,17 @@ fn find_cycleways(streets: &StreetNetwork) -> Vec<Cycleway> {
for i in cycleway_road.endpoints() {
let mut candidates = Vec::new();
for road in streets.roads_per_intersection(i) {
if road.untrimmed_length() < SHORT_ROAD_THRESHOLD {
if road.id != cycleway_road.id
&& road.center_line.length() < SHORT_ROAD_THRESHOLD
{
candidates.push(road.id);
}
}
if candidates.len() == 1 {
main_road_endpoints.push(streets.roads[&candidates[0]].other_side(i));
} else if candidates.is_empty() {
// Maybe this intersection has been merged already. Use it directly.
main_road_endpoints.push(i);
}
}

Expand All @@ -72,6 +77,10 @@ fn find_cycleways(streets: &StreetNetwork) -> Vec<Cycleway> {
// might be more.
let main_road_src_i = main_road_endpoints[0];
let main_road_dst_i = main_road_endpoints[1];
// It may be none at all, when the main road intersection gets merged
if main_road_src_i == main_road_dst_i {
continue;
}
// Find all main road segments "parallel to" this cycleway, by pathfinding between
// the main road intersections. We don't care about the order, but simple_path
// does. In case it's one-way for driving, try both.
Expand Down
12 changes: 6 additions & 6 deletions street-explorer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ <h1>StreetExplorer</h1>
<details class="fieldset">
<summary>Processing Options</summary>
<label>
<input name="debugEachStep" type="checkbox" />Debug each
<input name="debugEachStep" type="checkbox" checked />Debug each
transformation step
</label>
<label>
<input name="dualCarriagewayExperiment" type="checkbox" />Enable
dual carriageway experiment
</label>
<label>
<input name="cycletrackSnappingExperiment" type="checkbox" />Enable
<input name="cycletrackSnappingExperiment" type="checkbox" checked />Enable
cycletrack snapping experiment
</label>
<label>
Expand All @@ -55,12 +55,12 @@ <h1>StreetExplorer</h1>
<div>
Sidewalks:
<label>
<input name="sidewalks" type="radio" value="mapped" checked />use mapped
footways
<input name="sidewalks" type="radio" value="mapped" checked />use
mapped footways
</label>
<label>
<input name="sidewalks" type="radio" value="infer" />infer
on roads
<input name="sidewalks" type="radio" value="infer" />infer on
roads
</label>
</div>
</details>
Expand Down
36 changes: 25 additions & 11 deletions street-explorer/js/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,20 @@ export class SequentialLayerGroup {
}
}

changeCurrent(newIdx) {
this.groups[this.current].setEnabled(false);
this.current = newIdx;
this.groups[this.current].setEnabled(true);

// Rerender
document.getElementById(this.name).replaceWith(this.renderControls());
}

renderControls() {
const prev = makeButton("Previous");
prev.disabled = this.current == 0;
prev.onclick = () => {
this.groups[this.current].setEnabled(false);
this.current -= 1;
this.groups[this.current].setEnabled(true);

// Rerender
document.getElementById(this.name).replaceWith(this.renderControls());
this.changeCurrent(this.current - 1);
};

const label = document.createTextNode(
Expand All @@ -147,12 +151,21 @@ export class SequentialLayerGroup {
const next = makeButton("Next");
next.disabled = this.current == this.groups.length - 1;
next.onclick = () => {
this.groups[this.current].setEnabled(false);
this.current += 1;
this.groups[this.current].setEnabled(true);
this.changeCurrent(this.current + 1);
};

// Rerender
document.getElementById(this.name).replaceWith(this.renderControls());
const dropdown = L.DomUtil.create("select");
var i = 0;
for (let group of this.groups) {
const option = L.DomUtil.create("option");
option.value = i;
option.textContent = `${group.name}`;
dropdown.appendChild(option);
i++;
}
dropdown.value = this.current;
dropdown.onchange = () => {
this.changeCurrent(parseInt(dropdown.value));
};

var row1 = L.DomUtil.create("u");
Expand All @@ -161,6 +174,7 @@ export class SequentialLayerGroup {
const column = makeDiv([
row1,
row2,
dropdown,
this.groups[this.current].renderControls(),
]);
column.id = this.name;
Expand Down

0 comments on commit 99637e5

Please sign in to comment.