@Override public int compare(final Count c1, final Count c2) { // This seemed to be intended for a rather special case with a rather special // numbering of counts... michaz mar 10 // int i1 = Integer.parseInt(c1.getCsId().substring(c1.getCsId().length()-3)); // int i2 = Integer.parseInt(c2.getCsId().substring(c2.getCsId().length()-3)); // if (i1 < i2) return -1; // else if (i1 > i2) return 1; // else return 0; return c1.getCsLabel().compareTo(c2.getCsLabel()); } }
@Override public void startCount(final Count count, final BufferedWriter out) throws IOException { out.write("\t<count"); out.write(" loc_id=\"" + count.getId() + "\""); out.write(" cs_id=\"" + count.getCsLabel() + "\""); if (count.getCoord() != null) { final Coord coord = coordinateTransformation.transform( count.getCoord() ); out.write(" x=\"" + coord.getX() + "\""); out.write(" y=\"" + coord.getY() + "\""); } out.write(">\n"); }
/** * Creates the List with the counts vs sim values stored in the * countAttribute Attribute of this class. */ private void compare() { for (Count<Link> count : this.counts.getCounts().values()) { if (!distanceFilter.isInRange(count)) { continue; } double[] volumes = this.volumesPerLinkPerHour.getVolumesForStop(Id.create(count.getId(), TransitStopFacility.class)); if (volumes == null || volumes.length == 0) { log.warn("No volumes for count location: " + count.getId().toString()); continue; } for (int hour = 1; hour <= 24; hour++) { Volume volume = count.getVolume(hour); if (volume != null) { double countValue = volume.getValue(); double simValue=volumes[hour-1]; simValue *= this.countsScaleFactor; this.result.add(new CountSimComparisonImpl(count.getId(), count.getCsLabel(), hour, countValue, simValue)); } } } }
writer.write((anOcuppancy) + TAB); writer.write(count.getCoord().toString() + TAB + count.getCsLabel() + NL);
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()); }
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());
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"); }