MATSIM
Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | List of all members
org.matsim.counts.Count< T > Class Template Reference
Inheritance diagram for org.matsim.counts.Count< T >:
Inheritance graph
[legend]

Public Member Functions

final Volume createVolume (final int h, final double val)
 
final void setCsId (final String cs_id)
 
final Id< T > getId ()
 
final String getCsLabel ()
 
final Volume getMaxVolume ()
 
final Volume getVolume (final int h)
 
final HashMap< Integer, VolumegetVolumes ()
 
Coord getCoord ()
 
void setCoord (final Coord coord)
 
final String toString ()
 

Protected Member Functions

 Count (MeasurementLocation< T > v)
 

Private Attributes

final MeasurementLocation< T > location
 
final Measurable volume
 

Static Private Attributes

static final Logger log = LogManager.getLogger(Counts.class)
 

Detailed Description

This class is a wrapper around the newer MeasurementLocation.

Parameters
<T>

Definition at line 40 of file Count.java.

Constructor & Destructor Documentation

◆ Count()

Definition at line 48 of file Count.java.

References org.matsim.counts.Measurable.ANY_MODE, org.matsim.api.core.v01.TransportMode.car, org.matsim.counts.MeasurementLocation< T >.createVolume(), org.matsim.counts.Measurable.getInterval(), org.matsim.counts.MeasurementLocation< T >.hasMeasurableForMode(), org.matsim.counts.Measurable.HOURLY, org.matsim.counts.Measurable.supportsHourlyAggregate(), and org.matsim.counts.Measurable.VOLUMES.

48  {
49  this.location = v;
50 
51  String mode;
52  if (location.hasMeasurableForMode(Measurable.VOLUMES, Measurable.ANY_MODE))
53  mode = Measurable.ANY_MODE;
54  else
55  mode = TransportMode.car;
56 
57  // Counts only support hourly volumes
58  this.volume = location.createVolume(mode, Measurable.HOURLY);
59 
60  if (!this.volume.supportsHourlyAggregate()) {
61  log.warn("Unsupported counts interval '" + this.volume.getInterval() + "' for analysis functionality. " +
62  "Interval should be able to aggregate hourly, otherwise counts will be empty");
63  }
64  }
static final Logger log
Definition: Count.java:43
final Measurable volume
Definition: Count.java:46
final MeasurementLocation< T > location
Definition: Count.java:45
Here is the call graph for this function:

Member Function Documentation

◆ createVolume()

final Volume org.matsim.counts.Count< T >.createVolume ( final int  h,
final double  val 
)

Creates and adds a Volume to the Counting station.

Parameters
hindicating the hour-of-day. Note: the hours for a counting station must be from 1-24, and not from 0-23, otherwise the MatsimCountsReader will throw an error.
valthe total number of vehicles counted during hour h.
Returns
the Counting station's Volume.

Definition at line 76 of file Count.java.

Referenced by org.matsim.counts.CountsReaderMatsimV1.startVolume().

76  {
77  if (h < 1) {
78  throw new RuntimeException("counts start at 1, not at 0. If you have a use case where you need to go below one, "
79  + "let us know and we think about it, but so far we had numerous debugging sessions because someone inserted counts at 0.");
80  }
81 
82  Volume v = new Volume(h, val);
83 
84  // Only hourly volumes can be set
85  if (this.volume.getInterval() == Measurable.HOURLY)
86  this.volume.setAtHour(h - 1, val);
87  else
88  log.warn("Unsupported counts '" + this.volume.getInterval() + "' for setting values. Resolution must be hourly.");
89 
90  return v;
91  }
static final Logger log
Definition: Count.java:43
final Measurable volume
Definition: Count.java:46
void setAtHour(int hour, double value)
Definition: Measurable.java:64

◆ setCsId()

final void org.matsim.counts.Count< T >.setCsId ( final String  cs_id)

Definition at line 93 of file Count.java.

References org.matsim.counts.MeasurementLocation< T >.setStationName().

93  {
94  location.setStationName(cs_id);
95  }
final MeasurementLocation< T > location
Definition: Count.java:45
Here is the call graph for this function:

◆ getId()

final Id<T> org.matsim.counts.Count< T >.getId ( )

Implements org.matsim.api.core.v01.Identifiable< T >.

Definition at line 98 of file Count.java.

References org.matsim.counts.MeasurementLocation< T >.getRefId().

Referenced by org.matsim.counts.algorithms.CountsComparisonAlgorithm.setDistanceFilter().

98  {
99  return location.getRefId();
100  }
final MeasurementLocation< T > location
Definition: Count.java:45
Here is the call graph for this function:

◆ getCsLabel()

final String org.matsim.counts.Count< T >.getCsLabel ( )

Definition at line 102 of file Count.java.

References org.matsim.counts.MeasurementLocation< T >.getStationName().

102  {
103  return location.getStationName();
104  }
final MeasurementLocation< T > location
Definition: Count.java:45
Here is the call graph for this function:

◆ getMaxVolume()

final Volume org.matsim.counts.Count< T >.getMaxVolume ( )

Definition at line 106 of file Count.java.

References org.matsim.counts.Measurable.HOURLY.

106  {
107  int hour = -1;
108  double max = -1.0;
109  for (Int2DoubleMap.Entry e : this.volume) {
110  if (e.getDoubleValue() > max) {
111  max = e.getDoubleValue();
112  hour = e.getIntKey() / Measurable.HOURLY;
113  }
114  }
115  return hour >= 0 ? new Volume(hour + 1, max) : null;
116  }

◆ getVolume()

final Volume org.matsim.counts.Count< T >.getVolume ( final int  h)

Definition at line 118 of file Count.java.

References org.matsim.counts.Measurable.aggregateAtHour(), and org.matsim.counts.Measurable.supportsHourlyAggregate().

118  {
119  if (this.volume.supportsHourlyAggregate()) {
120  // Uses old format where hours starts at 1
121  OptionalDouble v = this.volume.aggregateAtHour(h - 1);
122  return v.isPresent() ? new Volume(h, v.getAsDouble()) : null;
123  }
124 
125  return null;
126  }
final Measurable volume
Definition: Count.java:46
OptionalDouble aggregateAtHour(int hour)
Here is the call graph for this function:

◆ getVolumes()

final HashMap<Integer, Volume> org.matsim.counts.Count< T >.getVolumes ( )

Definition at line 128 of file Count.java.

References org.matsim.counts.Measurable.HOURLY.

128  {
129  HashMap<Integer, Volume> res = new HashMap<>();
130  for (Int2DoubleMap.Entry e : volume) {
131  // Offset for old API
132  int h = (e.getIntKey() / Measurable.HOURLY) + 1;
133  res.put(h, new Volume(h, e.getDoubleValue()));
134  }
135 
136  return res;
137  }
final Measurable volume
Definition: Count.java:46

◆ getCoord()

Coord org.matsim.counts.Count< T >.getCoord ( )
Returns
Returns the exact coordinate, where this counting station is located, or null if no exact location is available.

Definition at line 143 of file Count.java.

References org.matsim.counts.MeasurementLocation< T >.getCoordinates().

Referenced by org.matsim.counts.algorithms.CountsComparisonAlgorithm.setCountCoordUsingDistanceFilter().

143  {
144  return location.getCoordinates();
145  }
final MeasurementLocation< T > location
Definition: Count.java:45
Here is the call graph for this function:

◆ setCoord()

void org.matsim.counts.Count< T >.setCoord ( final Coord  coord)

Definition at line 147 of file Count.java.

References org.matsim.counts.MeasurementLocation< T >.setCoordinates().

Referenced by org.matsim.counts.CountsReaderMatsimV1.startCount().

147  {
148  location.setCoordinates(coord);
149  }
final MeasurementLocation< T > location
Definition: Count.java:45
Here is the call graph for this function:

◆ toString()

final String org.matsim.counts.Count< T >.toString ( )

Definition at line 152 of file Count.java.

References org.matsim.counts.MeasurementLocation< T >.getId(), org.matsim.counts.MeasurementLocation< T >.getStationName(), and org.matsim.counts.Measurable.size().

152  {
153  return "[Loc_id=" + this.location.getId() + "]" +
154  "[cs_id=" + this.location.getStationName() + "]" +
155  "[nof_volumes=" + this.volume.size() + "]";
156  }
final Measurable volume
Definition: Count.java:46
final MeasurementLocation< T > location
Definition: Count.java:45
Here is the call graph for this function:

Member Data Documentation

◆ log

final Logger org.matsim.counts.Count< T >.log = LogManager.getLogger(Counts.class)
staticprivate

Definition at line 43 of file Count.java.

◆ location

final MeasurementLocation<T> org.matsim.counts.Count< T >.location
private

Definition at line 45 of file Count.java.

◆ volume

final Measurable org.matsim.counts.Count< T >.volume
private

Definition at line 46 of file Count.java.


The documentation for this class was generated from the following file: