/** * Add additional facility data that will generate an additional column for each (x,y,t)-Entry. The facilities are aggregated to * the measurement points in downstream code. */ public void addAdditionalFacilityData(ActivityFacilities facilities) { // TDO cleanu up this method if (facilities.getName() == null || facilities.getName().equals("")) { throw new RuntimeException("Cannot add unnamed facility containers here. A key is required to identify them.") ; } for (ActivityFacilities existingFacilities : this.additionalFacs.values()) { if (existingFacilities.getName().equals(facilities.getName())) { throw new RuntimeException("Additional facilities under the name of + " + facilities.getName() + " already exist. Cannot add additional facilities under the same name twice.") ; } } this.additionalFacs.put(facilities.getName(), facilities); }
/** * I wanted to plot something like (max(acc)-acc)*population. For that, I needed "population" at the x/y coordinates. * This is the mechanics via which I inserted that. (The computation is then done in postprocessing.) * <p></p> * You can add arbitrary ActivityFacilities containers here. They will be aggregated to the grid points, and then written to * file as additional column. */ public void addAdditionalFacilityData(ActivityFacilities facilities ) { log.warn("changed this data flow (by adding the _cnt_ column) but did not test. If it works, please remove this warning. kai, mar'14") ; if ( this.lockedForAdditionalFacilityData ) { throw new RuntimeException("too late for adding additional facility data; spatial grids have already been generated. Needs" + " to be called before generating the spatial grids. (This design should be improved ..)") ; } if ( facilities.getName()==null || facilities.getName().equals("") ) { throw new RuntimeException("cannot add unnamed facility containers here since we need a key to find them again") ; } for ( ActivityFacilities existingFacilities : this.additionalFacilityData ) { if ( existingFacilities.getName().equals( facilities.getName() ) ) { throw new RuntimeException("additional facilities under the name of + " + facilities.getName() + " already exist; cannot add additional facilities under the same name twice.") ; } } this.additionalFacilityData.add( facilities ) ; }
public void startFacilities(final ActivityFacilities facilities, final BufferedWriter out) throws IOException { out.write("<facilities"); if (facilities.getName() != null) { out.write(" name=\"" + facilities.getName() + "\""); } out.write(">\n\n"); this.attributesWriter.writeAttributes("\t", out, facilities.getAttributes()); }
public static void assignAdditionalFacilitiesDataToMeasurePoint(ActivityFacilities measurePoints, Map<Id<ActivityFacility>, Geometry> measurePointGeometryMap, Map<String, ActivityFacilities> additionalFacilityData) { LOG.info("Start assigning additional facilities data to measure point."); GeometryFactory geometryFactory = new GeometryFactory(); for (ActivityFacilities additionalDataFacilities : additionalFacilityData.values()) { // Iterate over all additional data collections String additionalDataName = additionalDataFacilities.getName(); int additionalDataFacilitiesToAssign = additionalDataFacilities.getFacilities().size(); for (Id<ActivityFacility> measurePointId : measurePoints.getFacilities().keySet()) { // Iterate over all measure points ActivityFacility measurePoint = measurePoints.getFacilities().get(measurePointId); measurePoint.getAttributes().putAttribute(additionalDataName, 0); Geometry geometry = measurePointGeometryMap.get(measurePointId); for (ActivityFacility facility : additionalDataFacilities.getFacilities().values()) { // Iterate over additional-data facilities Point point = geometryFactory.createPoint(new Coordinate(facility.getCoord().getX(), facility.getCoord().getY())); if (geometry.contains(point)) { measurePoint.getAttributes().putAttribute(additionalDataName, (int) measurePoint.getAttributes().getAttribute(additionalDataName) + 1); additionalDataFacilitiesToAssign--; } } } LOG.warn(additionalDataFacilitiesToAssign + " have not been assigned to a measure point geometry."); } LOG.info("Finished assigning additional facilities data to measure point."); } }
if ( this.additionalSpatialGrids.get( facilities.getName() ) != null ) { throw new RuntimeException("this should not yet exist ...") ; this.additionalSpatialGrids.put( facilities.getName(), spatialGrids ) ; Tuple<SpatialGrid,SpatialGrid> spatialGrids = this.additionalSpatialGrids.get( facilities.getName() ) ; GridUtils.aggregateFacilitiesIntoSpatialGrid(facilities, spatialGrids.getFirst(), spatialGrids.getSecond(), null);