Skip to content

Commit

Permalink
fix osm tags
Browse files Browse the repository at this point in the history
  • Loading branch information
GregorRyb committed Jan 22, 2025
1 parent 8650b45 commit 1b67cfc
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.matsim.run;

import com.sun.jdi.connect.Transport;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Scenario;
Expand All @@ -16,13 +17,16 @@
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.population.Person;
import org.matsim.contrib.bicycle.BicycleModule;
import org.matsim.core.network.NetworkUtils;
import org.matsim.core.network.algorithms.MultimodalNetworkCleaner;
import org.matsim.core.population.PopulationUtils;
import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule;
import org.matsim.vehicles.VehicleType;
import org.matsim.vehicles.VehicleUtils;


import java.util.Collection;
import java.util.Collections;
import java.util.Set;

/**
Expand Down Expand Up @@ -124,20 +128,20 @@ protected void prepareScenario(Scenario scenario) {

if (bike == BicycleHandling.onNetworkWithStandardMatsim || bike == BicycleHandling.onNetworkWithBicycleContrib) {
for (Link link: scenario.getNetwork().getLinks().values()) {
// if it is a car link bikes can be added
if (link.getAllowedModes().contains(TransportMode.car)) {
if (!link.getAllowedModes().contains(TransportMode.pt) && !link.getAttributes().getAttribute("type").equals("motorway") ||
!link.getAttributes().getAttribute("type").equals("trunk") || !link.getAttributes().getAttribute("type").equals("motorway_link") ||
!link.getAttributes().getAttribute("type").equals("trunk_link") || !link.getAttributes().getAttribute("type").equals("highway.motorway")
|| !link.getAttributes().getAttribute("type").equals("highway.motorway_link")
|| !link.getAttributes().getAttribute("type").equals("highway.trunk")
|| !link.getAttributes().getAttribute("type").equals("highway.trunk_link")
) {
//check OSM link type
String type = (String) link.getAttributes().getAttribute("type");
//not add bikes to trunk and motorways
if(!type.contains("motorway") && !type.contains("trunk")) {
Set<String> allowedModes = Sets.newHashSet(TransportMode.bike);
allowedModes.addAll(link.getAllowedModes());
link.setAllowedModes(allowedModes);
}
}
}
//run network cleander for
new MultimodalNetworkCleaner(scenario.getNetwork()).run(Collections.singleton(TransportMode.bike));
}
}

Expand Down

0 comments on commit 1b67cfc

Please sign in to comment.