public Population geographicallyFilterPopulation( final Population origPopulation, final ObjectAttributes personAttributes) { Population filteredPopulation = PopulationUtils.createPopulation(ConfigUtils.createConfig()); Counter counter = new Counter(" person # "); boolean actInArea; for (Person p : origPopulation.getPersons().values()) { counter.incCounter(); if (p.getSelectedPlan() != null) { actInArea = false; for (PlanElement pe : p.getSelectedPlan().getPlanElements()) { if (!actInArea && pe instanceof ActivityImpl) { ActivityImpl act = (ActivityImpl) pe; if (inArea(act.getCoord())) { actInArea = true; } } } if (actInArea) { filteredPopulation.addPerson(p); filteredAgents.put(p.getId(), p); } else { personAttributes.removeAllAttributes(p.toString()); } } } return filteredPopulation; }
public ActivityFacilities filterFacilitiesWithPopulation( final ActivityFacilities origFacilities) { ActivityFacilities filteredFacilities = FacilitiesUtils.createActivityFacilities(); for (Person person : filteredAgents.values()) { if (person.getSelectedPlan() != null) { for (PlanElement pe : person.getSelectedPlan().getPlanElements()) { if (pe instanceof ActivityImpl) { ActivityImpl act = (ActivityImpl) pe; if (act.getFacilityId() != null && !filteredFacilities.getFacilities().containsKey(act.getFacilityId())) { filteredFacilities.addActivityFacility( origFacilities.getFacilities().get(act.getFacilityId())); } } } } } return filteredFacilities; }