Skip to content

Commit

Permalink
add speed reduction on specified links
Browse files Browse the repository at this point in the history
  • Loading branch information
GregorRyb committed Mar 5, 2024
1 parent 46ed086 commit b4679a6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/org/matsim/run/RunGladbeckScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public class RunGladbeckScenario extends RunMetropoleRuhrScenario {
@CommandLine.Option(names = "--tempo30Zone", defaultValue = "false", description = "measures to reduce car speed to 30 km/h")
boolean tempo30Zone;

@CommandLine.Option(names = "--tempo30Streets", defaultValue = "false", description = "measures to reduce car speed to 30 km/h")
boolean tempo30Streets;

@CommandLine.Mixin
private ShpOptions shp;

Expand Down Expand Up @@ -115,6 +118,11 @@ protected void prepareScenario(Scenario scenario) {
ReduceSpeed.implementPushMeasuresByModifyingNetworkInArea(scenario.getNetwork(), ShpGeometryUtils.loadPreparedGeometries(IOUtils.resolveFileOrResource(shp.getShapeFile().toString())));
}

if (tempo30Streets) {
ReduceSpeed.implementPushMeasuresByModifyingNetworkInArea(scenario.getNetwork(), ShpGeometryUtils.loadPreparedGeometries(IOUtils.resolveFileOrResource(shp.getShapeFile().toString())));
}


if (schoolClosure) {
List<Id<Link>> listOfSchoolLinks = new ArrayList<>();
//TODO switch to shp file
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/matsim/run/policies/ReduceSpeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,19 @@ public static void implementPushMeasuresByModifyingNetworkInArea(Network network
//apply 'tempo 30' to all roads but primary and motorways
link.setFreespeed(link.getFreespeed() * 0.6); //27 km/h is used in the net for 30 km/h streets
});
}

public static void implementSpeedReductionOnPreDefinedLinks (Network network, List<PreparedGeometry> shpWithPreDefinedStreets) {
Set<? extends Link> carLinks = network.getLinks().values().stream()
.filter(link -> link.getAllowedModes().contains(TransportMode.car)) //filter car links
.filter(link -> !((String) link.getAttributes().getAttribute("type")).contains("residential"))
.filter(link -> ShpGeometryUtils.isCoordInPreparedGeometries(link.getCoord(), shpWithPreDefinedStreets)) //spatial filter
.collect(Collectors.toSet());

carLinks.forEach(link -> {
//apply 'tempo 30' to all roads witin the shape file
link.setFreespeed(link.getFreespeed() * 0.6); //27 km/h is used in the net for 30 km/h streets
});
}

}

0 comments on commit b4679a6

Please sign in to comment.