Skip to content

Commit

Permalink
Bug fix for dismounted cyclists on one-way roads
Browse files Browse the repository at this point in the history
  • Loading branch information
CorinStaves committed Feb 26, 2024
1 parent 04651d9 commit a086c12
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/main/java/network/CreateMatsimNetworkRoad.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,39 +190,27 @@ private static void addLinkToNetwork(int edgeID, SimpleFeature edge, Network net

// If allows walk but not bike, add bike but specify must dismount
boolean walkNotBike = allowedModesOut.contains(walk) && !allowedModesOut.contains(bike);
boolean dismount = walkNotBike || roadType.contains("Cycling Forbidden") || cycleosm.equals("dismount");

l1.getAttributes().putAttribute("dismount",dismount);
l2.getAttributes().putAttribute("dismount",dismount);

// Add back cycling (dismounted) if walking is allowed
if(walkNotBike) allowedModesOut.add(bike);

// Allowed modes return
// One way details
boolean oneWay = ((String) edge.getAttribute("onwysmm")).startsWith("One Way") || Boolean.TRUE.equals(edge.getAttribute("is_oneway"));

// Allowed modes on return link
Set<String> allowedModesRtn = new HashSet<>(allowedModesOut);
String oneWaySummary = (String) edge.getAttribute("onwysmm");
if(oneWaySummary.equals("One Way")) {
allowedModesRtn.remove(bike);
if(oneWay) {
allowedModesRtn.remove(car);
allowedModesRtn.remove(truck);
} else if(oneWaySummary.equals("One Way - Two Way Cycling")) { // Manchester network only
allowedModesRtn.remove(car);
allowedModesRtn.remove(truck);
} else {
Boolean isOneWay = (Boolean) edge.getAttribute("is_oneway"); // Melbourne network only
if(isOneWay != null) {
if(isOneWay) {
allowedModesRtn.remove(bike);
allowedModesRtn.remove(car);
allowedModesRtn.remove(truck);
}
}
}

// Set allowed modes
l1.setAllowedModes(allowedModesOut);
l2.setAllowedModes(allowedModesRtn);

// Do cyclists have to dismount?
boolean dismount = walkNotBike || roadType.contains("Cycling Forbidden") || cycleosm.equals("dismount");
l1.getAttributes().putAttribute("dismount",dismount);
l2.getAttributes().putAttribute("dismount",dismount || oneWay);

// Are cars allowed on this link? (necessary for mode-specific filtered networks)
boolean allowsCarOut = allowedModesOut.contains(car);
boolean allowsCarRtn = allowedModesRtn.contains(car);
Expand Down

0 comments on commit a086c12

Please sign in to comment.