public CountsWriter( final CoordinateTransformation coordinateTransformation, final Counts counts) { this.counts = counts; // use the newest writer-version by default this.handler = new CountsWriterHandlerImplV1(coordinateTransformation); }
public void testSECounts() { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); CountsReaderMatsimV1 reader = new CountsReaderMatsimV1(counts); reader.startTag("counts", attributeFactory.createCountsAttributes(), null); assertEquals("Counts attribute setting failed", "testName", counts.getName()); assertEquals("Counts attribute setting failed", "testDesc", counts.getDescription()); assertEquals("Counts attribute setting failed", 2000, counts.getYear()); }
@Override public Counts<Link> get() { Counts<Link> calibrationCounts = new Counts<>(); new MatsimCountsReader(calibrationCounts).parse(config.getCountsFileURL(matsimConfig.getContext())); return calibrationCounts; } }
public void testSEElementCountWithoutCoords() throws SAXException { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); MatsimCountsReader reader = new MatsimCountsReader(counts); reader.setDoctype("counts_v1.xsd"); reader.startElement("", "counts", "counts", attributeFactory.createCountsAttributes()); reader.startElement("", "count", "count", attributeFactory.createCountAttributes()); Count count = counts.getCount(Id.create(1, Link.class)); assertEquals("Count attribute setting failed", "testNr", count.getCsLabel()); assertNull("Count attributes x,y should not be set", count.getCoord()); reader.endElement("", "count", "count"); reader.endElement("", "counts", "counts"); }
public void testSEElementVolume() throws SAXException { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); MatsimCountsReader reader = new MatsimCountsReader(counts); reader.setDoctype("counts_v1.xsd"); reader.startElement("", "counts", "counts", attributeFactory.createCountsAttributes()); reader.startElement("", "count", "count", attributeFactory.createCountAttributes()); reader.startElement("", "volume", "volume", attributeFactory.createVolumeAttributes()); assertEquals("Volume attribute setting failed", 100.0, counts.getCount(Id.create(1, Link.class)).getVolume(1).getValue(), EPSILON); reader.endElement("", "volume", "volume"); reader.endElement("", "count", "count"); reader.endElement("", "counts", "counts"); } }
public void testSEVolume() { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); CountsReaderMatsimV1 reader = new CountsReaderMatsimV1(counts); reader.startTag("counts", attributeFactory.createCountsAttributes(), null); reader.startTag("count", attributeFactory.createCountAttributes(), null); reader.startTag("volume", attributeFactory.createVolumeAttributes(), null); assertEquals("Volume attribute setting failed", 100.0, counts.getCount(Id.create(1, Link.class)).getVolume(1).getValue(), EPSILON); } }
@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 ); }
public void testSEElementCountWithCoords() throws SAXException { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); MatsimCountsReader reader = new MatsimCountsReader(counts); reader.setDoctype("counts_v1.xsd"); reader.startElement("", "counts", "counts", attributeFactory.createCountsAttributes()); reader.startElement("", "count", "count", attributeFactory.createCountAttributesWithCoords()); Count count = counts.getCount(Id.create(1, Link.class)); assertNotNull("Count attribute x,y setting failed", count.getCoord()); assertEquals("Count attribute x setting failed", 123.456, count.getCoord().getX(), EPSILON); assertEquals("Count attribute y setting failed", 987.654, count.getCoord().getY(), EPSILON); reader.endElement("", "count", "count"); reader.endElement("", "counts", "counts"); }
public void testSEElementCounts() throws SAXException { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); MatsimCountsReader reader = new MatsimCountsReader(counts); reader.setDoctype("counts_v1.xsd"); reader.startElement("", "counts", "counts", attributeFactory.createCountsAttributes()); assertEquals("Counts attribute setting failed", "testName", counts.getName()); assertEquals("Counts attribute setting failed", "testDesc", counts.getDescription()); assertEquals("Counts attribute setting failed", 2000, counts.getYear()); try { reader.endElement("", "counts", "counts"); } catch (SAXException e) { throw new RuntimeException(e); } }
public void testSECount() { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); CountsReaderMatsimV1 reader = new CountsReaderMatsimV1(counts); reader.startTag("counts", attributeFactory.createCountsAttributes(), null); reader.startTag("count", attributeFactory.createCountAttributes(), null); assertEquals("Count attribute setting failed", "testNr", counts.getCount(Id.create(1, Link.class)).getCsLabel()); }
@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 }
public void testCreateVolume() { Count count = new Count(Id.create(0, Link.class), "1"); Volume volume = count.createVolume(1, 100.0); assertTrue("Creation and initialization of volume failed", volume.getHourOfDayStartingWithOne()==1); assertTrue("Creation and initialization of volume failed", volume.getValue()==100.0); }
public void testGetVolume() { Count count = new Count(Id.create(0, Link.class), "1"); count.createVolume(1, 100.0); assertTrue("Getting volume failed", count.getVolume(1).getValue() == 100.0); }
public void testCompare() { CountsFixture fixture = new CountsFixture(); fixture.setUp(); CountsComparisonAlgorithm cca = fixture.getCCA(); cca.run(); List<CountSimComparison> csc_list = cca.getComparison(); int cnt=0; for (CountSimComparison csc : csc_list) { assertEquals("Wrong sim value set", 2*cnt, csc.getSimulationValue(), 0.0); cnt++; cnt=cnt%24; }//while }
public void testGetCounts() { final Counts counts = new Counts(); counts.createAndAddCount(Id.create(0, Link.class), "1"); assertEquals("Getting counts failed", 1, counts.getCounts().size()); } }
public void testCreateChart() { CountsFixture fixture = new CountsFixture(); fixture.setUp(); CountsLoadCurveGraph eg = new CountsLoadCurveGraph(fixture.ceateCountSimCompList(), 1, "testCreateChart"); assertNotNull("No graph is created", eg.createChart(0)); } }
public void testCreateChart() { CountsFixture fixture = new CountsFixture(); fixture.setUp(); BoxPlotErrorGraph eg = new BoxPlotErrorGraph(fixture.ceateCountSimCompList(), 1, "testCreateChart", "testCreateChart"); assertNotNull("No graph is created", eg.createChart(0)); } }
public void testCreateChart() { CountsFixture fixture = new CountsFixture(); fixture.setUp(); CountsSimRealPerHourGraph eg = new CountsSimRealPerHourGraph(fixture.ceateCountSimCompList(), 1, "testCreateChart"); assertNotNull("No graph is created", eg.createChart(0)); } }
@Override public Mobsim get() { return new DummyMobsim(eventsManager, count++); } }
@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 ); }