private void dumpCounts() { try { if ( counts != null ) { final String inputCRS = config.counts().getInputCRS(); final String internalCRS = config.global().getCoordinateSystem(); if ( inputCRS == null ) { new CountsWriter(counts).write(controlerIO.getOutputFilename(Controler.OUTPUT_PREFIX + Controler.FILENAME_COUNTS)); } else { log.info( "re-projecting counts from "+internalCRS+" back to "+inputCRS+" for export" ); final CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation( internalCRS, inputCRS ); new CountsWriter( transformation , counts).write(controlerIO.getOutputFilename(Controler.OUTPUT_PREFIX + Controler.FILENAME_COUNTS)); } } } catch ( Exception ee ) { log.error("Exception writing counts.", ee); } }
@Provides @Singleton Counts<Link> provideLinkCounts(Scenario scenario, CountsConfigGroup config) { Counts<Link> counts = (Counts<Link>) scenario.getScenarioElement(Counts.ELEMENT_NAME); if (counts != null) { return counts; } else { counts = new Counts<>(); if (config.getCountsFileName() != null) { final String inputCRS = config.getInputCRS(); final String internalCRS = scenario.getConfig().global().getCoordinateSystem(); MatsimCountsReader counts_parser; if (inputCRS == null) { counts_parser = new MatsimCountsReader(counts); } else { log.info( "re-projecting counts from "+inputCRS+" to "+internalCRS+" for import" ); final CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation( inputCRS, internalCRS ); counts_parser = new MatsimCountsReader( transformation , counts ); } counts_parser.parse(config.getCountsFileURL(scenario.getConfig().getContext())); } return counts; } }