/** * 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 }
/** * 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 }