AbstractAgentSnapshotInfoBuilder( Scenario sc, SnapshotLinkWidthCalculator linkWidthCalculator ){ this.snapshotInfoFactory = new AgentSnapshotInfoFactory( linkWidthCalculator ); this.scenario = sc ; }
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; }
/** * Test the calculation of a vehicles position if the actual link length is * longer than the euklidean distance. * * @author mrieser */ public void testDistanceOnLink_longLink() { Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create("2", Node.class), new Coord((double) 1000, (double) 1000)); final Node fromNode = node1; final Node toNode = node2; Link link1 = NetworkUtils.createAndAddLink(network,Id.create("1", Link.class), fromNode, toNode, (double) 2000, (double) 10, (double) 9999, (double) 1 ); // place the vehicle at one quarter of the link SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator(); AgentSnapshotInfo posInfo = new AgentSnapshotInfoFactory(linkWidthCalculator).createAgentSnapshotInfo(Id.create(1, Person.class), link1, 500, 0); assertEquals(260.60660171779824, posInfo.getEasting(), epsilon); assertEquals(239.3933982822018, posInfo.getNorthing(), epsilon); // These numbers became a little weird when I moved vehicles away from the center of a link. Kai, Dec/08 // These numbers changed again when I mad the orthogonal offset adaptive. kai, aug/10 // Made the orthogonal offsets non-adaptive again. kai, feb'13 }
linkWidthCalculator.setLaneWidth( network.getEffectiveLaneWidth() ); AgentSnapshotInfoFactory snapshotInfoFactory = new AgentSnapshotInfoFactory(linkWidthCalculator);
/** * Test the calculation of a vehicles position if the actual link length is * shorter than the euklidean distance. * * @author mrieser */ public void testDistanceOnLink_shortLink() { Network network = NetworkUtils.createNetwork(); Node node1 = NetworkUtils.createAndAddNode(network, Id.create("1", Node.class), new Coord((double) 0, (double) 0)); Node node2 = NetworkUtils.createAndAddNode(network, Id.create("2", Node.class), new Coord((double) 1000, (double) 1000)); final Node fromNode = node1; final Node toNode = node2; Link link1 = NetworkUtils.createAndAddLink(network,Id.create("1", Link.class), fromNode, toNode, (double) 1000, (double) 10, (double) 9999, (double) 1 ); // place the vehicle at one quarter of the link SnapshotLinkWidthCalculator linkWidthCalculator = new SnapshotLinkWidthCalculator(); AgentSnapshotInfo posInfo = new AgentSnapshotInfoFactory(linkWidthCalculator).createAgentSnapshotInfo(Id.create(1, Person.class), link1, 250, 0); assertEquals(260.60660171779824, posInfo.getEasting(), epsilon); assertEquals(239.3933982822018, posInfo.getNorthing(), epsilon); // These numbers became a little weird when I moved vehicles away from the center of a link. Kai, Dec/08 // These numbers changed again when I mad the orthogonal offset adaptive. kai, aug/10 // Made the orthogonal offsets non-adaptive again. kai, feb'13 }