diff --git a/src/main/java/org/matsim/run/prepare/NetworkOptions.java b/src/main/java/org/matsim/run/prepare/NetworkOptions.java index e68568e..231ada9 100644 --- a/src/main/java/org/matsim/run/prepare/NetworkOptions.java +++ b/src/main/java/org/matsim/run/prepare/NetworkOptions.java @@ -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. @@ -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. */ diff --git a/src/main/java/org/matsim/run/prepare/PrepareNetwork.java b/src/main/java/org/matsim/run/prepare/PrepareNetwork.java index fb12e18..0776fe7 100644 --- a/src/main/java/org/matsim/run/prepare/PrepareNetwork.java +++ b/src/main/java/org/matsim/run/prepare/PrepareNetwork.java @@ -246,4 +246,40 @@ static void prepareSlowSpeed(Network network, List geometries, } + static void prepareEBikeCity(Network network, List geometries) { + Set 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); + }); + } + }