Skip to content

Commit

Permalink
fix problem of car free area and parking interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
GregorRyb committed Jan 28, 2024
1 parent 8d19ab9 commit a90d7af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/main/java/org/matsim/run/LeipzigRouterPlanAlgorithm.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.matsim.api.core.v01.population.*;
import org.matsim.contrib.vsp.scenario.SnzActivities;
import org.matsim.core.controler.PersonPrepareForSimAlgorithm;
import org.matsim.core.network.NetworkUtils;
import org.matsim.core.network.filter.NetworkFilterManager;
import org.matsim.core.population.algorithms.PlanAlgorithm;
import org.matsim.core.population.algorithms.XY2Links;
Expand Down Expand Up @@ -74,7 +75,11 @@ private static LeipzigUtils.PersonParkingBehaviour getParkingBehaviour(Network f

// check if non-home activity (since otherwise we assume that there is no parking restriction):
//link might be null if inside car free zone (i.e. not in modal network)
if (link == null || isParkingRelevantActivity(activity)) {
if (isParkingRelevantActivity(activity)) {

if (link==null) {
link = NetworkUtils.getNearestLink(fullModalNetwork, activity.getCoord());
}

if (isLinkParkingTypeInsideResidentialArea(link)) {
parkingBehaviour = LeipzigUtils.PersonParkingBehaviour.parkingSearchLogicLeipzig;
Expand Down
7 changes: 6 additions & 1 deletion src/test/java/org/matsim/run/ParkingLeipzigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ public final void runPoint1pctIntegrationTestWithParkingWithCarFreeArea() {
EventsManager eventsManager = EventsUtils.createEventsManager();
eventsManager.addHandler(new ParkingActivityStartEventHandler());
EventsUtils.readEvents(eventsManager , output +"/" + "/leipzig-1pct.output_events.xml.gz");
Assert.assertTrue(ParkingActivityStartEventHandler.parkingEvents.size() == 0);

for (ActivityStartEvent event: ParkingActivityStartEventHandler.parkingEvents) {
if (event.getPersonId().equals("parkingAgentCarFreeLeisureCloseToResParkingZone")) {
Assert.assertTrue(event.getLinkId().equals("11827009#2"));
}
}
}

class ParkingActivityStartEventHandler implements ActivityStartEventHandler {
Expand Down

0 comments on commit a90d7af

Please sign in to comment.