public SnapshotGenerator(final Network network, final double snapshotPeriod, final QSimConfigGroup config) { this.network = network; int initialCapacity = (int)(network.getLinks().size()*1.1); this.eventLinks = new HashMap<>(initialCapacity, 0.95f); this.linkList = new ArrayList<>(initialCapacity); this.eventAgents = new HashMap<>(1000, 0.95f); this.snapshotPeriod = snapshotPeriod; this.capCorrectionFactor = config.getFlowCapFactor() / network.getCapacityPeriod(); this.storageCapFactor = config.getStorageCapFactor(); this.snapshotStyle = config.getSnapshotStyle(); if (! Double.isNaN( config.getLinkWidthForVis() )){ this.linkWidthCalculator.setLinkWidthForVis( config.getLinkWidthForVis() ); } if (! Double.isNaN(network.getEffectiveLaneWidth())){ this.linkWidthCalculator.setLaneWidth(network.getEffectiveLaneWidth()); } reset(-1); }
@Override void initializeFactory(AgentCounter agentCounter, MobsimTimer mobsimTimer, NetsimInternalInterface netsimEngine1) { double effectiveCellSize = ((Network)network).getEffectiveCellSize() ; SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator(); linkWidthCalculator.setLinkWidthForVis( qsimConfig.getLinkWidthForVis() ); if (! Double.isNaN(network.getEffectiveLaneWidth())){ linkWidthCalculator.setLaneWidth( network.getEffectiveLaneWidth() ); } AbstractAgentSnapshotInfoBuilder snapshotBuilder = QNetsimEngine.createAgentSnapshotInfoBuilder( scenario, linkWidthCalculator ); this.context = new NetsimEngineContext(events, effectiveCellSize, agentCounter, snapshotBuilder, qsimConfig, mobsimTimer, linkWidthCalculator ) ; this.netsimEngine = netsimEngine1 ; } @Override QNodeI createNetsimNode(Node node) {
@Override void initializeFactory( AgentCounter agentCounter, MobsimTimer mobsimTimer, NetsimInternalInterface netsimEngine1 ) { this.netsimEngine = netsimEngine1; double effectiveCellSize = network.getEffectiveCellSize() ; SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator(); linkWidthCalculator.setLinkWidthForVis( qsimConfig.getLinkWidthForVis() ); if (! Double.isNaN(network.getEffectiveLaneWidth())){ linkWidthCalculator.setLaneWidth( network.getEffectiveLaneWidth() ); } AbstractAgentSnapshotInfoBuilder agentSnapshotInfoBuilder = QNetsimEngine.createAgentSnapshotInfoBuilder( scenario, linkWidthCalculator ); context = new NetsimEngineContext( events, effectiveCellSize, agentCounter, agentSnapshotInfoBuilder, qsimConfig, mobsimTimer, linkWidthCalculator ); } @Override
private void recalculatePositions() { SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator(); linkWidthCalculator.setLaneWidth(OTFClientControl.getInstance().getOTFVisConfig().getEffectiveLaneWidth()); linkWidthCalculator.setLinkWidthForVis(OTFClientControl.getInstance().getOTFVisConfig().getLinkWidth()); for (VisLinkWLanes linkData : this.lanesLinkData.values()){ this.laneModelBuilder.recalculatePositions(linkData, linkWidthCalculator); } }
@Override void initializeFactory(AgentCounter agentCounter, MobsimTimer mobsimTimer, NetsimInternalInterface netsimEngine1) { this.netsimEngine = netsimEngine1 ; double effectiveCellSize = network.getEffectiveCellSize() ; SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator(); linkWidthCalculator.setLinkWidthForVis( qsimConfig.getLinkWidthForVis() ); if (! Double.isNaN(network.getEffectiveLaneWidth())){ linkWidthCalculator.setLaneWidth( network.getEffectiveLaneWidth() ); } AbstractAgentSnapshotInfoBuilder agentSnapshotInfoBuilder = QNetsimEngine.createAgentSnapshotInfoBuilder( scenario, linkWidthCalculator ); context = new NetsimEngineContext( events, effectiveCellSize, agentCounter, agentSnapshotInfoBuilder, qsimConfig, mobsimTimer, linkWidthCalculator ); delegate.initializeFactory(agentCounter, mobsimTimer, netsimEngine1); }
@Override void initializeFactory(AgentCounter agentCounter, MobsimTimer mobsimTimer, NetsimInternalInterface arg2) { network = arg2.getNetsimNetwork().getNetwork(); double effectiveCellSize = ( network).getEffectiveCellSize() ; SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator(); linkWidthCalculator.setLinkWidthForVis( qsimConfig.getLinkWidthForVis() ); if (! Double.isNaN(network.getEffectiveLaneWidth())){ linkWidthCalculator.setLaneWidth( network.getEffectiveLaneWidth() ); } AbstractAgentSnapshotInfoBuilder snapshotInfoBuilder = QNetsimEngine.createAgentSnapshotInfoBuilder( scenario, linkWidthCalculator ); this.context = new NetsimEngineContext( events, effectiveCellSize, agentCounter, snapshotInfoBuilder, qsimConfig, mobsimTimer, linkWidthCalculator ) ; this.netsimEngine = arg2 ; }
@Override void initializeFactory( AgentCounter agentCounter, MobsimTimer mobsimTimer, NetsimInternalInterface netsimEngine1 ) { this.netsimEngine = netsimEngine1; double effectiveCellSize = scenario.getNetwork().getEffectiveCellSize() ; SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator(); linkWidthCalculator.setLinkWidthForVis( scenario.getConfig().qsim().getLinkWidthForVis() ); linkWidthCalculator.setLaneWidth( scenario.getNetwork().getEffectiveLaneWidth() ); AbstractAgentSnapshotInfoBuilder agentSnapshotInfoBuilder = QNetsimEngine.createAgentSnapshotInfoBuilder( scenario, linkWidthCalculator ); context = new NetsimEngineContext( events, effectiveCellSize, agentCounter, agentSnapshotInfoBuilder, scenario.getConfig().qsim(), mobsimTimer, linkWidthCalculator ); } @Override
@Override void initializeFactory(AgentCounter agentCounter, MobsimTimer mobsimTimer, NetsimInternalInterface simEngine1) { SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator(); linkWidthCalculator.setLinkWidthForVis( scenario.getConfig().qsim().getLinkWidthForVis() ); linkWidthCalculator.setLaneWidth( scenario.getNetwork().getEffectiveLaneWidth() ); AbstractAgentSnapshotInfoBuilder agentSnapshotInfoBuilder = QNetsimEngine.createAgentSnapshotInfoBuilder( scenario, linkWidthCalculator ); this.netsimEngine = simEngine1; this.context = new NetsimEngineContext( events, scenario.getNetwork().getEffectiveCellSize(), agentCounter, agentSnapshotInfoBuilder, scenario.getConfig().qsim(), mobsimTimer, linkWidthCalculator ); delegate.initializeFactory(agentCounter, mobsimTimer, simEngine1); }
public static OnTheFlyServer startServerAndRegisterWithQSim(Config config, Scenario scenario, EventsManager events, QSim qSim, NonPlanAgentQueryHelper nonPlanAgentQueryHelper) { OnTheFlyServer server = OnTheFlyServer.createInstance(scenario, events, qSim, nonPlanAgentQueryHelper); if (config.transit().isUseTransit()) { Network network = scenario.getNetwork(); TransitSchedule transitSchedule = scenario.getTransitSchedule(); // TransitQSimEngine transitEngine = qSim.getTransitEngine(); // AgentTracker agentTracker = transitEngine.getAgentTracker(); // AgentSnapshotInfoFactory snapshotInfoFactory = qSim.getVisNetwork().getagentsnapshotinfofactory(); SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator(); linkWidthCalculator.setLinkWidthForVis( config.qsim().getLinkWidthForVis() ); if (! Double.isNaN(network.getEffectiveLaneWidth())){ linkWidthCalculator.setLaneWidth( network.getEffectiveLaneWidth() ); } AgentSnapshotInfoFactory snapshotInfoFactory = new AgentSnapshotInfoFactory(linkWidthCalculator); for ( AgentTracker agentTracker : qSim.getAgentTrackers() ) { FacilityDrawer.Writer facilityWriter = new FacilityDrawer.Writer(network, transitSchedule, agentTracker, snapshotInfoFactory); server.addAdditionalElement(facilityWriter); } } server.pause(); return server; }
linkWidthCalculator.setLinkWidthForVis( config.qsim().getLinkWidthForVis() ); if (! Double.isNaN(network.getEffectiveLaneWidth())){ linkWidthCalculator.setLaneWidth( network.getEffectiveLaneWidth() );
public void drawLink() { GL2 gl = GLContext.getCurrentGL().getGL2(); if (drawLinkAsLine) { gl.glLineWidth(1); gl.glBegin(GL2.GL_LINES); gl.glVertex2f(quad[0].x, quad[0].y); gl.glVertex2f(quad[1].x, quad[1].y); gl.glEnd(); } else { linkWidthCalculator.setLaneWidth(OTFClientControl.getInstance().getOTFVisConfig().getEffectiveLaneWidth()); linkWidthCalculator.setLinkWidthForVis(OTFClientControl.getInstance().getOTFVisConfig().getLinkWidth()); float width = (float) linkWidthCalculator.calculateLinkWidth(this.nrLanes); final Point2D.Float ortho = calcOrtho(this.quad[0].x, this.quad[0].y, this.quad[1].x, this.quad[1].y, width); // (yy this is where the width of the links for drawing is set) this.quad[2] = new Point2D.Float(this.quad[0].x + ortho.x, this.quad[0].y + ortho.y); this.quad[3] = new Point2D.Float(this.quad[1].x + ortho.x, this.quad[1].y + ortho.y); //Draw quad TextureCoords co = new TextureCoords(0,0,1,1); gl.glBegin(GL2.GL_QUADS); gl.glTexCoord2f(co.right(),co.bottom()); gl.glVertex3f(quad[0].x, quad[0].y, 0); gl.glTexCoord2f(co.right(),co.top()); gl.glVertex3f(quad[1].x, quad[1].y, 0); gl.glTexCoord2f(co.left(), co.top()); gl.glVertex3f(quad[3].x, quad[3].y, 0); gl.glTexCoord2f(co.left(),co.bottom()); gl.glVertex3f(quad[2].x, quad[2].y, 0); gl.glEnd(); } }