MATSIM
Classes | Public Member Functions | Private Attributes | List of all members
org.matsim.vis.snapshotwriters.TransimsSnapshotWriter Class Reference
Inheritance diagram for org.matsim.vis.snapshotwriters.TransimsSnapshotWriter:
Inheritance graph
[legend]

Classes

enum  Labels
 

Public Member Functions

 TransimsSnapshotWriter (String filename)
 
void addAgent (AgentSnapshotInfo position)
 
void beginSnapshot (double time)
 
void endSnapshot ()
 
void finish ()
 

Private Attributes

BufferedWriter out = null
 
double currentTime = -1
 

Detailed Description

Writes the current position of vehicles into a file that can be read by transims.

Author
mrieser

Definition at line 34 of file TransimsSnapshotWriter.java.

Constructor & Destructor Documentation

◆ TransimsSnapshotWriter()

org.matsim.vis.snapshotwriters.TransimsSnapshotWriter.TransimsSnapshotWriter ( String  filename)

Definition at line 40 of file TransimsSnapshotWriter.java.

References org.matsim.core.utils.io.IOUtils.CHARSET_UTF8, org.matsim.vis.snapshotwriters.TransimsSnapshotWriter.Labels.EASTING, org.matsim.core.utils.io.IOUtils.getBufferedWriter(), org.matsim.core.utils.io.IOUtils.getFileUrl(), org.matsim.vis.snapshotwriters.TransimsSnapshotWriter.Labels.NORTHING, org.matsim.vis.snapshotwriters.TransimsSnapshotWriter.Labels.TIME, org.matsim.vis.snapshotwriters.TransimsSnapshotWriter.Labels.VEHICLE, and org.matsim.vis.snapshotwriters.TransimsSnapshotWriter.Labels.VELOCITY.

40  {
41  try {
42  this.out = IOUtils.getBufferedWriter(IOUtils.getFileUrl(filename), IOUtils.CHARSET_UTF8, true);
43  String header = Labels.VEHICLE
44  + "\t" + Labels.TIME
45  + "\tLINK"
46  + "\tNODE"
47  + "\tLANE"
48  + "\tDISTANCE"
49  + "\t" + Labels.VELOCITY
50  + "\tVEHTYPE"
51  + "\tACCELER"
52  + "\tDRIVER"
53  + "\tPASSENGERS"
54  + "\t" + Labels.EASTING
55  + "\t" + Labels.NORTHING
56  + "\tELEVATION"
57  + "\tAZIMUTH"
58  + "\tUSER\n";
59  this.out.write(header);
60  } catch (IOException e) {
61  e.printStackTrace();
62  }
63  }
Here is the call graph for this function:

Member Function Documentation

◆ addAgent()

void org.matsim.vis.snapshotwriters.TransimsSnapshotWriter.addAgent ( AgentSnapshotInfo  position)

Adds an agent to the current snapshot.

Parameters
positionThe position, id, and speed of the agent.

Implements org.matsim.vis.snapshotwriters.SnapshotWriter.

Definition at line 66 of file TransimsSnapshotWriter.java.

References org.matsim.vis.snapshotwriters.AgentSnapshotInfo.getAgentState(), org.matsim.vis.snapshotwriters.AgentSnapshotInfo.getColorValueBetweenZeroAndOne(), org.matsim.vis.snapshotwriters.AgentSnapshotInfo.getEasting(), org.matsim.vis.snapshotwriters.AgentSnapshotInfo.getId(), org.matsim.vis.snapshotwriters.AgentSnapshotInfo.getNorthing(), and org.matsim.vis.snapshotwriters.AgentSnapshotInfo.AgentState.PERSON_AT_ACTIVITY.

66  {
67 
68  //drop all parking vehicles
69  if (position.getAgentState() == AgentSnapshotInfo.AgentState.PERSON_AT_ACTIVITY) return;
70 
71  String buffer = position.getId().toString()
72  + "\t" + (int)this.currentTime
73  + "\t0\t0\t1\t0\t" + position.getColorValueBetweenZeroAndOne() // link(0), from node(0), lane(1), dist(0), speed
74  + "\t1\t0\t" + position.getId().toString() // vehtype(1), acceleration(0), driver-id
75  + "\t0\t" + position.getEasting() // # of passengers(0), easting
76  + "\t" + position.getNorthing()
77  + "\t0" // elevation
78  + "\t0" // azimuth
79  + "\t"+ "0" + "\n"; // user(0)
80  try {
81  out.write(buffer);
82  } catch (IOException e) {
83  e.printStackTrace();
84  }
85  }
Here is the call graph for this function:

◆ beginSnapshot()

void org.matsim.vis.snapshotwriters.TransimsSnapshotWriter.beginSnapshot ( double  time)

Tells the snapshot writer that a new snapshot begins at the specified time.

Parameters
timeThe time of the snapshot.

Implements org.matsim.vis.snapshotwriters.SnapshotWriter.

Definition at line 88 of file TransimsSnapshotWriter.java.

◆ endSnapshot()

void org.matsim.vis.snapshotwriters.TransimsSnapshotWriter.endSnapshot ( )

Tells the snapshot writer that no more vehicles will be added to the current snapshot.

Implements org.matsim.vis.snapshotwriters.SnapshotWriter.

Definition at line 93 of file TransimsSnapshotWriter.java.

◆ finish()

void org.matsim.vis.snapshotwriters.TransimsSnapshotWriter.finish ( )

Tells the snapshot writer that no more snapshots will be added ("destructor").

Implements org.matsim.vis.snapshotwriters.SnapshotWriter.

Definition at line 98 of file TransimsSnapshotWriter.java.

98  {
99  if (this.out != null) {
100  try {
101  out.close();
102  } catch (IOException e) {
103  e.printStackTrace();
104  }
105  }
106  }

Member Data Documentation

◆ out

BufferedWriter org.matsim.vis.snapshotwriters.TransimsSnapshotWriter.out = null
private

Definition at line 35 of file TransimsSnapshotWriter.java.

◆ currentTime

double org.matsim.vis.snapshotwriters.TransimsSnapshotWriter.currentTime = -1
private

Definition at line 36 of file TransimsSnapshotWriter.java.


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