@Override public Collection<AgentSnapshotInfo> addAgentSnapshotInfo(Collection<AgentSnapshotInfo> positions) { for (MobsimEngine mobsimEngine : mobsimEngines) { if (mobsimEngine instanceof VisData) { VisData visData = (VisData) mobsimEngine; positions = visData.addAgentSnapshotInfo(positions); } } return positions; } };
private void closeSnapshotWriters() { for (SnapshotWriter writer : this.snapshotWriters) { writer.finish(); } }
/** * @param elevation */ @SuppressWarnings("static-method") public AgentSnapshotInfo createAgentSnapshotInfo(Id<Person> agentId, double easting, double northing, double elevation, double azimuth) { PositionInfo info = new PositionInfo() ; info.setId( agentId ) ; info.setEasting( easting ) ; info.setNorthing( northing ) ; info.setAzimuth( azimuth ) ; return info ; }
private void doSnapshot(final double time, VisMobsim visMobsim) { if (!this.snapshotWriters.isEmpty()) { Collection<AgentSnapshotInfo> positions = new ArrayList<AgentSnapshotInfo>(); for (VisLink link : visMobsim.getVisNetwork().getVisLinks().values()) { link.getVisData().addAgentSnapshotInfo(positions); } // We do not put non-network agents in movies. // Otherwise, we would add snapshots from visMobsim.getNonNetworkAgentSnapshots() here. for (SnapshotWriter writer : this.snapshotWriters) { writer.beginSnapshot(time); for (AgentSnapshotInfo position : positions) { writer.addAgent(position); } writer.endSnapshot(); } } }
private void addHolePosition(final Collection<AgentSnapshotInfo> positions, double distanceFromFromNode, Hole veh, double curvedLength, Coord upstreamCoord, Coord downstreamCoord) { Integer lane = 20 ; double speedValue = 1. ; AgentSnapshotInfo pos = this.snapshotInfoFactory.createAgentSnapshotInfo(Id.create("hole", Person.class), upstreamCoord, downstreamCoord, distanceFromFromNode, lane, curvedLength); pos.setColorValueBetweenZeroAndOne(speedValue); pos.setAgentState(AgentState.PERSON_OTHER_MODE ); positions.add(pos); }
public final int positionAgentsInActivities(final Collection<AgentSnapshotInfo> positions, Link link, Collection<MobsimAgent> agentsInActivities, int cnt2) { for (MobsimAgent pa : agentsInActivities) { AgentSnapshotInfo agInfo = snapshotInfoFactory.createAgentSnapshotInfo(pa.getId(), link, 0.9*link.getLength(), cnt2) ; agInfo.setAgentState( AgentState.PERSON_AT_ACTIVITY ) ; positions.add(agInfo) ; cnt2++ ; } return cnt2; }
/** * creator based on Coord * @param curveLength lengths are usually different (usually longer) than the euclidean distances between the startCoord and endCoord */ public AgentSnapshotInfo createAgentSnapshotInfo(Id<Person> agentId, Coord startCoord, Coord endCoord, double distanceOnLink, Integer lane, double curveLength) { PositionInfo info = new PositionInfo() ; info.setId(agentId) ; double lanePosition = this.linkWidthCalculator.calculateLanePosition(lane); Gbl.assertNotNull( startCoord ); Gbl.assertNotNull( endCoord ); calculateAndSetPosition(info, startCoord, endCoord, distanceOnLink, curveLength, lanePosition) ; return info; }
AbstractAgentSnapshotInfoBuilder( Scenario sc, SnapshotLinkWidthCalculator linkWidthCalculator ){ this.snapshotInfoFactory = new AgentSnapshotInfoFactory( linkWidthCalculator ); this.scenario = sc ; }
@Override public MobsimListener get() { if (iterationContext.getIteration() % controlerConfigGroup.getWriteSnapshotsInterval() == 0) { SnapshotWriterManager manager = new SnapshotWriterManager(config); for (com.google.inject.Provider<SnapshotWriter> snapshotWriter : this.snapshotWriters) { manager.addSnapshotWriter(snapshotWriter.get()); } return manager; } else { return new NoopMobsimListener(); } }
@Override public VisNetwork getVisNetwork() { return visMobsim.getVisNetwork(); }
@Override public VisData getNonNetwokAgentSnapshots() { return visMobsim.getNonNetworkAgentSnapshots(); }
@Override public double calculateVehicleSpacing(double linkLength, double overallStorageCapacity, Collection<? extends VisVehicle> vehs) { double sum = 0. ; for ( VisVehicle veh : vehs ) { sum += veh.getSizeInEquivalents() ; } return linkLength / sum ; }
@Override public Map<Id<Person>, MobsimAgent> getMobsimAgents() { return visMobsim.getAgents(); }
public SnapshotWriterManager(Config config) { snapshotPeriod = findSnapshotPeriod(config); }
public LiveServerQuadTree(VisNetwork net) { super(net.getNetwork()); this.net = net; }
@Override public void notifyMobsimBeforeCleanup(MobsimBeforeCleanupEvent e) { closeSnapshotWriters(); }
@Override public SnapshotWriter get() { String fileName = controlerIO.getIterationFilename(iteration, "T.veh.gz"); return new TransimsSnapshotWriter(fileName); }
@Override public void notifyMobsimAfterSimStep(MobsimAfterSimStepEvent e) { double time = e.getSimulationTime(); if (time >= this.snapshotTime) { this.snapshotTime += this.snapshotPeriod; doSnapshot(time, (VisMobsim) e.getQueueSimulation()); } }
/** * Generate snapshot info based on Link. * * Comments:<ul> * <li>One could argue that this method should not know about Links at all, * but it shortens code at several places, and since Link is a standard interface, I see no reason to not provide this * as a service. * </ul> */ public AgentSnapshotInfo createAgentSnapshotInfo(Id<Person> agentId, Link link, double distanceOnLink, int lane) { PositionInfo info = new PositionInfo() ; info.setId(agentId) ; double lanePosition = this.linkWidthCalculator.calculateLanePosition(lane); calculateAndSetPosition(info, link.getFromNode().getCoord(), link.getToNode().getCoord(), distanceOnLink, link.getLength(), lanePosition ); return info; }
public final void finish() { for (SnapshotWriter writer : this.snapshotWriters) { writer.finish(); } }