diff --git a/src/main/java/org/matsim/run/LeipzigRouterPlanAlgorithm.java b/src/main/java/org/matsim/run/LeipzigRouterPlanAlgorithm.java index aaf79d68..28a13ec2 100644 --- a/src/main/java/org/matsim/run/LeipzigRouterPlanAlgorithm.java +++ b/src/main/java/org/matsim/run/LeipzigRouterPlanAlgorithm.java @@ -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; @@ -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; diff --git a/src/test/java/org/matsim/run/ParkingLeipzigTest.java b/src/test/java/org/matsim/run/ParkingLeipzigTest.java index d244bf32..f6b6affb 100644 --- a/src/test/java/org/matsim/run/ParkingLeipzigTest.java +++ b/src/test/java/org/matsim/run/ParkingLeipzigTest.java @@ -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 {