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); } }
@Test public void testDefaultYear_empty() { Counts counts = new Counts(); ByteArrayOutputStream out = new ByteArrayOutputStream(); new CountsWriter(counts).write(out); Counts counts2 = new Counts(); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); new MatsimCountsReader(counts2).parse(in); // there should not have been an Exception }
counts_writer.write(filename); File f = new File(filename); Assert.assertTrue(f.length() > 0.0);
@Test public void testInput() { final String file = utils.getOutputDirectory()+"/counts.xml"; final Counts<Link> originalCounts = createDummyCounts(); new CountsWriter( originalCounts ).write( file ); final Counts<Link> reprojectedCounts = new Counts(); new MatsimCountsReader( new Transformation() , reprojectedCounts ).readFile( file ); assertCountsAreReprojectedCorrectly( originalCounts , reprojectedCounts ); }
@Test public void testOutput() { final String file = utils.getOutputDirectory()+"/counts.xml"; final Counts<Link> originalCounts = createDummyCounts(); new CountsWriter( new Transformation() , originalCounts ).write( file ); final Counts<Link> reprojectedCounts = new Counts(); new MatsimCountsReader( reprojectedCounts ).readFile( file ); assertCountsAreReprojectedCorrectly( originalCounts , reprojectedCounts ); }
countsWriter.write(filename);
/** * @throws SAXException * @throws ParserConfigurationException * @throws IOException * * @author mrieser */ @Test public void testWriteParse_nameIsNull() throws SAXException, ParserConfigurationException, IOException { CountsFixture f = new CountsFixture(); f.setUp(); f.counts.setName(null); Assert.assertNull(f.counts.getName()); String filename = this.utils.getOutputDirectory() + "counts.xml"; new CountsWriter(f.counts).write(filename); Counts counts2 = new Counts(); new CountsReaderMatsimV1(counts2).readFile(filename); Assert.assertEquals("", counts2.getName()); } }
new CountsWriter( originalCounts ).write( file );