MATSIM
XYTRecord.java
Go to the documentation of this file.
1 package org.matsim.analysis;
2 
3 import org.matsim.api.core.v01.Coord;
4 import org.matsim.api.core.v01.Id;
5 
6 import java.util.Collections;
7 import java.util.HashMap;
8 import java.util.Map;
9 
13 public class XYTRecord{
14  // yyyyyy I am at this point unsure about times and time interpretation. Some option:
15  // * give only one time. This could be interpreted as (a) startTime (i.e. when vis moves to this data set); (b) midTime (i.e. when interpolation
16  // scheme should display exactly this data set)
17  // * give start/endTime. Problems: (a) what if endTime is not same as startTime of next data set? (b) how to encode gps trajectories (which
18  // would only have a time step?) Clearly, for gps tracks one could just have endTime=startTime, or leave endTime empty.
19  private double startTime ;
20  private double endTime ;
21  private Id<?> facilityId ;
22  private Coord coord ;
23  private Map<String,Double> map ;
24 
25  private XYTRecord( double startTime, double endTime, Coord coord, Id<?> facilityId, Map<String,Double> map ) {
26  this.startTime = startTime;
27  this.endTime = endTime;
28  this.coord = coord;
29  this.facilityId = facilityId;
30  this.map = map ;
31  }
32  @Override
33  public String toString() {
34  StringBuilder str = new StringBuilder( "NoiseRecord=[ startTime=" + startTime + " | endTime=" + endTime + " | facilityId=" + facilityId
35  + " | coord=" + coord );
36  for( Map.Entry<String, Double> entry : map.entrySet() ){
37  str.append( " | " ).append( entry.getKey() ).append( "=" ).append(entry.getValue()) ;
38  }
39  str.append( " ]" ) ;
40  return str.toString() ;
41  }
42  public double getStartTime(){
43  return startTime;
44  }
45  public double getEndTime(){
46  return endTime;
47  }
48  public Id<?> getFacilityId(){
49  return facilityId;
50  }
51  public Coord getCoord(){
52  return coord;
53  }
54  public Map<String,Double> getMap() { return Collections.unmodifiableMap(map ); }
55 
56  public static class Builder{
57  private double startTime = Double.NEGATIVE_INFINITY;
58  private double endTime = Double.POSITIVE_INFINITY;
59  private Coord coord = null;
60  private Id<?> facilityId = null;
61  private Map<String,Double> map = new HashMap<>() ;
62  public Builder setStartTime( double startTime ){
63  this.startTime = startTime;
64  return this;
65  }
66  public Builder setEndTime( double endTime ){
67  this.endTime = endTime;
68  return this;
69  }
70  public Builder setCoord( Coord coord ){
71  this.coord = coord;
72  return this;
73  }
74  public Builder setFacilityId( Id<?> facilityId ){
75  this.facilityId = facilityId;
76  return this;
77  }
78  public Builder put( String key, double value ) {
79  // this is deliberately "double" and not "Double" since
80  // * we might want to keep the option to back it by a data structure that allows primitive types
81  // * if one wants to set a "null" value, one can alternatively not set the value at all. (A csv writer may then have to compensate
82  // for that.)
83  // kai, aug'19
84  map.put( key, value ) ;
85  return this ;
86  }
87  public XYTRecord build(){
88  return new XYTRecord( startTime , endTime , coord , facilityId, map );
89  }
90  }
91 }
Map< String, Double > getMap()
Definition: XYTRecord.java:54
Builder setStartTime(double startTime)
Definition: XYTRecord.java:62
Builder put(String key, double value)
Definition: XYTRecord.java:78
Map< String, Double > map
Definition: XYTRecord.java:23
Builder setFacilityId(Id<?> facilityId)
Definition: XYTRecord.java:74
XYTRecord(double startTime, double endTime, Coord coord, Id<?> facilityId, Map< String, Double > map)
Definition: XYTRecord.java:25
Builder setEndTime(double endTime)
Definition: XYTRecord.java:66