MATSIM
PositionEvent.java
Go to the documentation of this file.
1 package org.matsim.vis.snapshotwriters;
2 
4 import org.matsim.api.core.v01.Coord;
5 import org.matsim.api.core.v01.Id;
10 import org.matsim.vehicles.Vehicle;
11 
12 import java.util.Map;
13 
14 public class PositionEvent extends Event implements BasicLocation, HasPersonId {
15 
16  public static final String EVENT_TYPE = "position";
17 
18  private final AgentSnapshotInfo position;
19 
20  public PositionEvent(double now, AgentSnapshotInfo position) {
21  super(now);
22  this.position = position;
23  }
24 
25  @Override
26  public String getEventType() {
27  return EVENT_TYPE;
28  }
29 
30  @Override
31  public Coord getCoord() {
32  return new Coord(position.getEasting(), position.getNorthing());
33  }
34 
35  @Override
37  return position.getId();
38  }
39 
40  public Id<Link> getLinkId() {
41  return position.getLinkId();
42  }
43 
45  return position.getVehicleId();
46  }
47 
49  return position.getColorValueBetweenZeroAndOne();
50  }
51 
53  return position.getAgentState();
54  }
55 
56  @Override
57  public Map<String, String> getAttributes() {
58  try {
59  var attr = super.getAttributes();
60  attr.put("state", position.getAgentState().toString());
61  attr.put("linkId", position.getLinkId().toString());
62  if (position.getVehicleId() != null)
63  attr.put("vehicleId", position.getVehicleId().toString());
64  return attr;
65  } catch (Exception e) {
66  throw new RuntimeException("oh no!");
67  }
68  }
69 }
PositionEvent(double now, AgentSnapshotInfo position)
AgentSnapshotInfo.AgentState getState()