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

Public Member Functions

 Counts ()
 
MeasurementLocation< T > createAndAddMeasureLocation (final Id< T > id, String stationName)
 
String getName ()
 
void setName (String name)
 
String getDescription ()
 
void setDescription (String description)
 
String getSource ()
 
void setSource (String source)
 
int getYear ()
 
void setYear (int year)
 
Set< String > getMeasurableTypes ()
 
Map< Id< T >, MeasurementLocation< T > > getMeasureLocations ()
 
MeasurementLocation< T > getMeasureLocation (Id< T > id)
 
final Count< T > createAndAddCount (final Id< T > linkId, final String stationName)
 Old API. More...
 
final TreeMap< Id< T >, Count< T > > getCounts ()
 
Count< T > getCount (final Id< T > locId)
 
Attributes getAttributes ()
 
String toString ()
 
MatsimFactory getFactory ()
 

Static Public Attributes

static final String ELEMENT_NAME = "counts"
 

Private Attributes

final Map< Id< T >, MeasurementLocation< T > > locations = new TreeMap<>()
 
final Attributes attributes = new AttributesImpl()
 
String name
 
String description
 
String source
 
int year
 

Detailed Description

This class provides count object, that can assign any measurable values (traffic volumes, velocities e.g.) for any matsim transport mode to an identifiable object (links, nodes, transit stations e.g) Structure is similar to regular counts, but more flexible to use.

Definition at line 21 of file Counts.java.

Constructor & Destructor Documentation

◆ Counts()

Definition at line 31 of file Counts.java.

31  {
32  }

Member Function Documentation

◆ createAndAddMeasureLocation()

MeasurementLocation<T> org.matsim.counts.Counts< T extends Identifiable< T >.createAndAddMeasureLocation ( final Id< T >  id,
String  stationName 
)

Creates a MeasurementLocation object and adds to count tree map. Argument has to be an id for an matsim Identifiable object (link, node, pt station e.g).

Definition at line 37 of file Counts.java.

Referenced by org.matsim.counts.Counts<?>.createAndAddCount(), and org.matsim.counts.CountsReaderMatsimV2.startMeasurementLocation().

37  {
38 
39  if (this.locations.containsKey(id)) {
40  throw new RuntimeException("There is already a measurement object for location " + id.toString());
41  }
42 
43  MeasurementLocation<T> loc = new MeasurementLocation<T>(id, stationName);
44  this.locations.put(id, loc);
45 
46  return loc;
47  }
final Map< Id< T >, MeasurementLocation< T > > locations
Definition: Counts.java:24

◆ getName()

String org.matsim.counts.Counts< T extends Identifiable< T >.getName ( )

Definition at line 49 of file Counts.java.

49  {
50  return name;
51  }

◆ setName()

void org.matsim.counts.Counts< T extends Identifiable< T >.setName ( String  name)

◆ getDescription()

String org.matsim.counts.Counts< T extends Identifiable< T >.getDescription ( )

Definition at line 57 of file Counts.java.

57  {
58  return description;
59  }

◆ setDescription()

void org.matsim.counts.Counts< T extends Identifiable< T >.setDescription ( String  description)

◆ getSource()

String org.matsim.counts.Counts< T extends Identifiable< T >.getSource ( )

Definition at line 65 of file Counts.java.

65  {
66  return source;
67  }

◆ setSource()

void org.matsim.counts.Counts< T extends Identifiable< T >.setSource ( String  source)

Definition at line 69 of file Counts.java.

Referenced by org.matsim.counts.CountsReaderMatsimV2.startMultiModeCounts().

69  {
70  this.source = source;
71  }

◆ getYear()

int org.matsim.counts.Counts< T extends Identifiable< T >.getYear ( )

Definition at line 73 of file Counts.java.

73  {
74  return year;
75  }

◆ setYear()

void org.matsim.counts.Counts< T extends Identifiable< T >.setYear ( int  year)

◆ getMeasurableTypes()

Set<String> org.matsim.counts.Counts< T extends Identifiable< T >.getMeasurableTypes ( )

Returns all measured types of observations for all modes.

Definition at line 84 of file Counts.java.

84  {
85  return locations.values().stream()
86  .map(MeasurementLocation::getMeasurables)
87  .flatMap(e -> e.keySet().stream())
88  .map(MeasurementLocation.TypeAndMode::type)
89  .collect(Collectors.toSet());
90  }
final Map< Id< T >, MeasurementLocation< T > > locations
Definition: Counts.java:24

◆ getMeasureLocations()

Map<Id<T>, MeasurementLocation<T> > org.matsim.counts.Counts< T extends Identifiable< T >.getMeasureLocations ( )

Definition at line 92 of file Counts.java.

92  {
93  return locations;
94  }
final Map< Id< T >, MeasurementLocation< T > > locations
Definition: Counts.java:24

◆ getMeasureLocation()

MeasurementLocation<T> org.matsim.counts.Counts< T extends Identifiable< T >.getMeasureLocation ( Id< T >  id)

Definition at line 96 of file Counts.java.

Referenced by org.matsim.counts.Counts<?>.getCount().

96  {
97  return this.locations.get(id);
98  }
final Map< Id< T >, MeasurementLocation< T > > locations
Definition: Counts.java:24

◆ createAndAddCount()

final Count<T> org.matsim.counts.Counts< T extends Identifiable< T >.createAndAddCount ( final Id< T >  linkId,
final String  stationName 
)

Old API.

Old style API to create a measurement for car volumes at one station. Consider using createAndAddMeasureLocation(Id, String) instead.

Parameters
linkIdthe link to which the counting station is assigned, must be unique
stationNamesome additional identifier for humans, e.g. the original name/id of the counting station
Returns
the created Count object, or RuntimeException} if it could not be created because it already exists
Deprecated:
use createAndAddMeasureLocation(Id, String) instead

Definition at line 114 of file Counts.java.

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

114  {
115  MeasurementLocation<T> location = createAndAddMeasureLocation(linkId, stationName);
116  return new Count<>(location);
117  }
MeasurementLocation< T > createAndAddMeasureLocation(final Id< T > id, String stationName)
Definition: Counts.java:37

◆ getCounts()

final TreeMap<Id<T>, Count<T> > org.matsim.counts.Counts< T extends Identifiable< T >.getCounts ( )

Retrieve map of all counts. This will be inefficient because all intermediate objects for the old API will be created.

Deprecated:
use getMeasureLocations() instead

Definition at line 125 of file Counts.java.

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

125  {
126  TreeMap<Id<T>, Count<T>> result = new TreeMap<>();
127 
128  for (Map.Entry<Id<T>, MeasurementLocation<T>> e : locations.entrySet()) {
129  result.put(e.getKey(), new Count<>(e.getValue()));
130  }
131 
132  return result;
133  }
final Map< Id< T >, MeasurementLocation< T > > locations
Definition: Counts.java:24

◆ getCount()

Count<T> org.matsim.counts.Counts< T extends Identifiable< T >.getCount ( final Id< T >  locId)

Use getMeasureLocation(Id) instead.

Definition at line 139 of file Counts.java.

139  {
140  MeasurementLocation<T> loc = getMeasureLocation(locId);
141  return loc == null ? null : new Count<>(loc);
142  }
MeasurementLocation< T > getMeasureLocation(Id< T > id)
Definition: Counts.java:96

◆ getAttributes()

Attributes org.matsim.counts.Counts< T extends Identifiable< T >.getAttributes ( )

◆ toString()

String org.matsim.counts.Counts< T extends Identifiable< T >.toString ( )

Definition at line 151 of file Counts.java.

151  {
152  return "[name=" + this.name + "]" + "[nof_locations=" + this.locations.size() + "]";
153  }
final Map< Id< T >, MeasurementLocation< T > > locations
Definition: Counts.java:24

◆ getFactory()

MatsimFactory org.matsim.counts.Counts< T extends Identifiable< T >.getFactory ( )

Implements org.matsim.core.api.internal.MatsimToplevelContainer.

Definition at line 155 of file Counts.java.

155  {
156  throw new RuntimeException( "not implemented" );
157  // yy I need this to fulfill MatsimToplevelContainer. Which I need to be able to use ProjectionUtils.putCRS(...) in the readers/writers. kai, feb'24
158  }

Member Data Documentation

◆ ELEMENT_NAME

final String org.matsim.counts.Counts< T extends Identifiable< T >.ELEMENT_NAME = "counts"
static

◆ locations

final Map<Id<T>, MeasurementLocation<T> > org.matsim.counts.Counts< T extends Identifiable< T >.locations = new TreeMap<>()
private

Definition at line 24 of file Counts.java.

Referenced by org.matsim.counts.Counts<?>.getMeasureLocations().

◆ attributes

final Attributes org.matsim.counts.Counts< T extends Identifiable< T >.attributes = new AttributesImpl()
private

Definition at line 25 of file Counts.java.

Referenced by org.matsim.counts.Counts<?>.getAttributes().

◆ name

String org.matsim.counts.Counts< T extends Identifiable< T >.name
private

◆ description

String org.matsim.counts.Counts< T extends Identifiable< T >.description
private

◆ source

String org.matsim.counts.Counts< T extends Identifiable< T >.source
private

◆ year

int org.matsim.counts.Counts< T extends Identifiable< T >.year
private

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