public CountsComparisonAlgorithm getCCA() { final CalcLinkStats linkStats = new AttributeFactory().createLinkStats(this.network); CountsComparisonAlgorithm cca = new CountsComparisonAlgorithm(new CountsComparisonAlgorithm.VolumesForId() { @Override public double[] getVolumesForStop(Id<TransitStopFacility> locationId) { return linkStats.getAvgLinkVolumes(Id.create(locationId, Link.class)); } }, this.counts, this.network, 1.0); // cca.setDistanceFilter(100.0, "0"); return cca; }
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()); }
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()); }
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 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 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"); }