Skip to content

Commit

Permalink
reduce complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
simei94 committed Oct 12, 2023
1 parent a90328e commit e4bce09
Showing 1 changed file with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,11 @@ private Map<Id<Person>, Map<Integer, TripStructureUtils.Trip>> getTripsFromPlans
for ( Person person : population.getPersons().values()) {
//check if blocked link is part of leg-route



List<TripStructureUtils.Trip> trips = TripStructureUtils.getTrips(person.getSelectedPlan());

for (int i = 0; i < trips.size(); i++) {
for (Leg leg : trips.get(i).getLegsOnly()) {
for ( String linkId : blockedLinks ) {
if (leg.getRoute().getRouteDescription().contains(linkId)) {
relevantTrips.putIfAbsent(person.getId(), new HashMap<>());
relevantTrips.get(person.getId()).put(i, trips.get(i));
continue;
}
}
}
}
getTripsFromPersons(blockedLinks, person, trips, relevantTrips);
}

} else {
Expand All @@ -178,6 +170,20 @@ private Map<Id<Person>, Map<Integer, TripStructureUtils.Trip>> getTripsFromPlans
return relevantTrips;
}

private static void getTripsFromPersons(List<String> blockedLinks, Person person, List<TripStructureUtils.Trip> trips, Map<Id<Person>, Map<Integer, TripStructureUtils.Trip>> relevantTrips) {
for (int i = 0; i < trips.size(); i++) {
for (Leg leg : trips.get(i).getLegsOnly()) {
for ( String linkId : blockedLinks) {
if (leg.getRoute().getRouteDescription().contains(linkId)) {
relevantTrips.putIfAbsent(person.getId(), new HashMap<>());
relevantTrips.get(person.getId()).put(i, trips.get(i));
continue;
}
}
}
}
}

static boolean isInsideArea(Link link, Geometry geometry) {

boolean isInsideArea = false;
Expand Down

0 comments on commit e4bce09

Please sign in to comment.