public void testGetCounts() { final Counts counts = new Counts(); counts.createAndAddCount(Id.create(0, Link.class), "1"); assertEquals("Getting counts failed", 1, counts.getCounts().size()); } }
@Override public void startCounts(final Counts counts, final BufferedWriter out) throws IOException { out.write("<counts "); out.write("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"); out.write("xsi:noNamespaceSchemaLocation=\"http://matsim.org/files/dtd/counts_v1.xsd\"\n"); if (counts.getName() != null) { out.write(" name=\"" + counts.getName() + "\""); } else { out.write(" name=\"\""); } if (counts.getDescription() != null) { out.write(" desc=\"" + counts.getDescription() + "\""); } out.write(" year=\"" + counts.getYear() + "\" "); out.write(" > \n"); }
private void startCounts(final Attributes meta) { this.counts.setName(meta.getValue("name")); this.counts.setDescription(meta.getValue("desc")); this.counts.setYear(Integer.parseInt(meta.getValue("year"))); }
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()); }
this.config.getOutputFormat().contains("all")) { String filename = controlerIO.getIterationFilename(event.getIteration(), "simulatedCounts.xml.gz"); Counts<Link> simCounts = new Counts<>(); simCounts.setDescription("sim values from iteration " + event.getIteration()); simCounts.setName("sim values from iteration " + event.getIteration()); simCounts.setYear(event.getIteration()); for (CountSimComparison countSimComparison : cca.getComparison()) { if (simCounts.getCount(countSimComparison.getId()) == null) { simCounts.createAndAddCount(countSimComparison.getId(), counts.getCount(countSimComparison.getId()).getCsLabel()); simCounts.getCount(countSimComparison.getId()).setCoord(counts.getCount(countSimComparison.getId()).getCoord()); simCounts.getCount(countSimComparison.getId()).createVolume(countSimComparison.getHour(), countSimComparison.getSimulationValue());
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()); }
@Override public void notifyStartup(final StartupEvent controlerStartupEvent) { if (counts != null) { for (Id<Link> linkId : counts.getCounts().keySet()) { this.linkStats.put(linkId, new double[24]); } } }
for ( Id<Link> id : originalCounts.getCounts().keySet() ) { final Coord originalCoord = originalCounts.getCount( id ).getCoord(); final Coord internalCoord = internalCounts.getCount( id ).getCoord(); final Counts<Link> dumpedCounts = new Counts<>(); new MatsimCountsReader( dumpedCounts ).readFile( outputDirectory+"/output_counts.xml.gz" ); for ( Id<Link> id : originalCounts.getCounts().keySet() ) { final Coord originalCoord = originalCounts.getCount( id ).getCoord(); final Coord dumpedCoord = dumpedCounts.getCount( id ).getCoord();
private Counts<Link> createDummyCounts() { final Counts<Link> counts = new Counts<Link>(); counts.setYear( 1988 ); for ( double i=0; i < 10; i+=1 ) { for ( double j=0; j < 10; j+=1 ) { final Count<Link> c = counts.createAndAddCount( Id.createLinkId( i+"-"+j ), i+"-"+j ); c.setCoord( new Coord( i , j ) ); c.createVolume( 1 , 0 ); } } return counts; }
/** * @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()); } }
@Inject PtCountControlerListener(final Config config, EventsManager eventsManager, OutputDirectoryHierarchy controlerIO, IterationStopWatch iterationStopWatch, Network network) { this.eventsManager = eventsManager; this.controlerIO = controlerIO; this.iterationStopWatch = iterationStopWatch; this.network = network; log.info("Using pt counts."); this.config = config; this.boardCounts = new Counts(); this.alightCounts = new Counts(); this.occupancyCounts = new Counts(); this.occupancyAnalyzer = new OccupancyAnalyzer(3600, 24 * 3600 - 1) ; }
private void assertCountsAreReprojectedCorrectly( Counts<Link> originalCounts, Counts<Link> reprojectedCounts) { Assert.assertEquals( "unexpected number of counts", originalCounts.getCounts().size(), reprojectedCounts.getCounts().size() ); for ( Id<Link> id : originalCounts.getCounts().keySet() ) { final Coord original = originalCounts.getCount( id ).getCoord(); final Coord transformed = reprojectedCounts.getCount( id ).getCoord(); Assert.assertEquals( "wrong reprojected X value", original.getX() + 1000 , transformed.getX(), MatsimTestUtils.EPSILON ); Assert.assertEquals( "wrong reprojected Y value", original.getY() + 1000 , transformed.getY(), MatsimTestUtils.EPSILON ); } }
private void startCount(final Attributes meta) { String locId = meta.getValue("loc_id"); this.currcount = this.counts.createAndAddCount(Id.create(locId, Link.class), meta.getValue("cs_id")); String x = meta.getValue("x"); String y = meta.getValue("y"); if (x != null && y != null) { this.currcount.setCoord( coordinateTransformation.transform( new Coord( Double.parseDouble(x), Double.parseDouble(y)))); } }
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 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); } }
public MeasurementCadytsContext(Config config, Tuple<Counts<Measurement>, Measurements> tuple) { CadytsConfigGroup cadytsConfig = ConfigUtils.addOrGetModule(config, CadytsConfigGroup.GROUP_NAME, CadytsConfigGroup.class ) ; cadytsConfig.setWriteAnalysisFile(true); this.counts = tuple.getFirst() ; this.measurements = tuple.getSecond() ; Set<String> measurementsSet = new TreeSet<>(); for (Id<Measurement> id : this.counts.getCounts().keySet()) { measurementsSet.add(id.toString()); } cadytsConfig.setCalibratedItems(measurementsSet); this.writeAnalysisFile = cadytsConfig.isWriteAnalysisFile(); }