Skip to content

Commit

Permalink
add network modification
Browse files Browse the repository at this point in the history
  • Loading branch information
GregorRyb committed Aug 27, 2024
1 parent 3556501 commit f6e61b1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/matsim/run/prepare/NetworkOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public class NetworkOptions {
private Path slowSpeedArea;
@CommandLine.Option(names = "--slow-speed-relative-change", description = "provide a value that is bigger than 0.0 and smaller than 1.0")
private Double slowSpeedRelativeChange;
@CommandLine.Option(names = "--slow-speed-relative-change", description = "provide a value that is bigger than 0.0 and smaller than 1.0")
private Path eBikeCity;
@CommandLine.Option(names = "--eBikeCity", description = "provide a value that is bigger than 0.0 and smaller than 1.0")


/**
* Return whether a car free area is defined.
Expand Down Expand Up @@ -107,8 +111,15 @@ public void prepare(Network network) {
PrepareNetwork.prepareCarFree(network, new ShpOptions(carFreeArea, null, null), carFreeModesToDelete);
}
}

if (isDefined(eBikeCity)) {


}
}



/**
* Return path to drt area.
*/
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/org/matsim/run/prepare/PrepareNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,40 @@ static void prepareSlowSpeed(Network network, List<PreparedGeometry> geometries,

}

static void prepareEBikeCity(Network network, List<PreparedGeometry> geometries) {
Set<? extends Link> carLinksInArea = network.getLinks().values().stream()
//filter car links
.filter(link -> link.getAllowedModes().contains(TransportMode.car))
//spatial filter
.filter(link -> ShpGeometryUtils.isCoordInPreparedGeometries(link.getCoord(), geometries))
//we won't change motorways and motorway_links
.filter(link -> !((String) link.getAttributes().getAttribute("type")).contains("motorway"))
.filter(link -> !((String) link.getAttributes().getAttribute("type")).contains("trunk"))
.collect(Collectors.toSet());

carLinksInArea.forEach(link -> link.setCapacity(link.getCapacity() * 0.5));
carLinksInArea.forEach(link -> {
if (link.getNumberOfLanes() > 2.0) {
link.setNumberOfLanes(link.getNumberOfLanes() * 0.5);
}
});
carLinksInArea.forEach(link -> {
var id = link.getId().toString() + "_cyev";
var newLink = network.getFactory().createLink(Id.createLinkId(id), link.getFromNode(), link.getToNode());
newLink.getAttributes().putAttribute("type", "cycleway");
newLink.getAttributes().putAttribute("cycleway", "yes");
newLink.getAttributes().putAttribute("surface", "asphalt");
newLink.getAttributes().putAttribute("smoothness", "excellent");
//newLink.getAttributes().putAttribute(BicycleUtils.BICYCLE_INFRASTRUCTURE_SPEED_FACTOR, 1.0);
var origid = link.getAttributes().getAttribute("origid");
origid = origid == null ? "" : origid;
newLink.getAttributes().putAttribute("origid", origid);
newLink.setCapacity(10000);
//double the speed of cyclist
newLink.setFreespeed(8.32);
newLink.setAllowedModes(Collections.singleton(TransportMode.bike));
network.addLink(newLink);
});
}

}

0 comments on commit f6e61b1

Please sign in to comment.