MATSIM
PtCountSimComparisonTableWriter.java
Go to the documentation of this file.
1 
2 /* *********************************************************************** *
3  * project: org.matsim.*
4  * PtCountSimComparisonTableWriter.java
5  * *
6  * *********************************************************************** *
7  * *
8  * copyright : (C) 2019 by the members listed in the COPYING, *
9  * LICENSE and WARRANTY file. *
10  * email : info at matsim dot org *
11  * *
12  * *********************************************************************** *
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * See also COPYING, LICENSE and WARRANTY file *
19  * *
20  * *********************************************************************** */
21 
22  package org.matsim.pt.counts;
23 
24 import java.util.List;
25 
26 import org.matsim.api.core.v01.Id;
30 
32 
33  private List<CountSimComparison> countSimCompList;
34 
35  public PtCountSimComparisonTableWriter(List<CountSimComparison> countSimCompList) {
36  this.countSimCompList = countSimCompList;
37  }
38 
39  @Override
40  public void write(String filename) {
41  SimpleWriter simpleWriter = null;
42  try {
43  simpleWriter = new SimpleWriter(filename);
44  Id<TransitStopFacility> lastStopId = null;
45  // Sorted by stopId
46  for (CountSimComparison count : countSimCompList) {
47  Id<TransitStopFacility> stopId = Id.create(count.getId(), TransitStopFacility.class);
48  if (!stopId.equals(lastStopId)) {
49  simpleWriter.write("StopId :\t");
50  simpleWriter.write(stopId.toString());
51  simpleWriter.write("\nhour\tsimVal\tscaledSimVal\tcountVal\n");
52  lastStopId = stopId;
53  }
54  simpleWriter.write(count.getHour());
55  simpleWriter.write('\t');
56 
57  double countValue = count.getCountValue();
58  double simValue = count.getSimulationValue();
59 
60  simpleWriter.write(simValue);
61  simpleWriter.write('\t');
62 
63  simpleWriter.write(simValue);
64  simpleWriter.write('\t');
65  simpleWriter.write(countValue);
66  simpleWriter.write('\n');
67 
68  }
69  } finally {
70  if (simpleWriter != null) {
71  simpleWriter.close();
72  }
73  }
74  }
75 
76 }
static< T > Id< T > create(final long key, final Class< T > type)
Definition: Id.java:68
PtCountSimComparisonTableWriter(List< CountSimComparison > countSimCompList)
boolean equals(Object obj)
Definition: Id.java:139