@Test public final void testAddLanePair() { final int laneCount = 1; final double roadLength = 1000.0; final RoadMapping m = RoadMappingConcrete.create(laneCount, roadLength); final RoadSegment r1 = new RoadSegment(roadLength, laneCount, m, RoadSegmentDirection.FORWARD); final RoadSegment r2 = new RoadSegment(roadLength, laneCount, m, RoadSegmentDirection.FORWARD); Link.addLanePair(Lanes.LANE1, r1, Lanes.LANE1, r2); assertEquals(r2, r1.sinkRoadSegment(Lanes.LANE1)); assertEquals(Lanes.LANE1, r1.sinkLane(Lanes.LANE1)); assertEquals(r1, r2.sourceRoadSegment(Lanes.LANE1)); assertEquals(Lanes.LANE1, r2.sourceLane(Lanes.LANE1)); }
public static void addLanePair(int fromLane, RoadSegment fromRoadsegment, int toLane, RoadSegment toRoadSegment) { if (toRoadSegment.sourceLaneSegment(toLane) != null && toRoadSegment.sourceLaneSegment(toLane).roadSegment() != fromRoadsegment) { throw new IllegalArgumentException("Ambiguous network input! Cannot connect source roadSegment=" + fromRoadsegment + "\nto lane=" + toLane + " of sink roadSegment=" + toRoadSegment + ".\n Sink already is=" + toRoadSegment.sourceLaneSegment(toLane).roadSegment()); } toRoadSegment.setSourceLaneSegmentForLane(fromRoadsegment.laneSegment(fromLane), toLane); if (fromRoadsegment.sinkLaneSegment(fromLane) != null && fromRoadsegment.sinkLaneSegment(fromLane).roadSegment() != toRoadSegment) { throw new IllegalArgumentException("Ambiguous network input! Cannot connect sink roadSegment=" + toRoadSegment + "\nfrom lane=" + fromLane + " of source roadSegment=" + toRoadSegment + ".\n Source already is=" + fromRoadsegment.sinkLaneSegment(fromLane).roadSegment()); } fromRoadsegment.setSinkLaneSegmentForLane(toRoadSegment.laneSegment(toLane), fromLane); }
Link { public static void addLanePair(int fromLane, RoadSegment fromRoadsegment, int toLane, RoadSegment toRoadSegment) { if (toRoadSegment.sourceLaneSegment(toLane) != null && toRoadSegment.sourceLaneSegment(toLane).roadSegment() != fromRoadsegment) { throw new IllegalArgumentException("Ambiguous network input! Cannot connect source roadSegment=" + fromRoadsegment + "\nto lane=" + toLane + " of sink roadSegment=" + toRoadSegment + ".\n Sink already is=" + toRoadSegment.sourceLaneSegment(toLane).roadSegment()); } toRoadSegment.setSourceLaneSegmentForLane(fromRoadsegment.laneSegment(fromLane), toLane); if (fromRoadsegment.sinkLaneSegment(fromLane) != null && fromRoadsegment.sinkLaneSegment(fromLane).roadSegment() != toRoadSegment) { throw new IllegalArgumentException("Ambiguous network input! Cannot connect sink roadSegment=" + toRoadSegment + "\nfrom lane=" + fromLane + " of source roadSegment=" + toRoadSegment + ".\n Source already is=" + fromRoadsegment.sinkLaneSegment(fromLane).roadSegment()); } fromRoadsegment.setSinkLaneSegmentForLane(toRoadSegment.laneSegment(toLane), fromLane); } }
Link { public static void addLanePair(int fromLane, RoadSegment fromRoadsegment, int toLane, RoadSegment toRoadSegment) { if (toRoadSegment.sourceLaneSegment(toLane) != null && toRoadSegment.sourceLaneSegment(toLane).roadSegment() != fromRoadsegment) { throw new IllegalArgumentException("Ambiguous network input! Cannot connect source roadSegment=" + fromRoadsegment + "\nto lane=" + toLane + " of sink roadSegment=" + toRoadSegment + ".\n Sink already is=" + toRoadSegment.sourceLaneSegment(toLane).roadSegment()); } toRoadSegment.setSourceLaneSegmentForLane(fromRoadsegment.laneSegment(fromLane), toLane); if (fromRoadsegment.sinkLaneSegment(fromLane) != null && fromRoadsegment.sinkLaneSegment(fromLane).roadSegment() != toRoadSegment) { throw new IllegalArgumentException("Ambiguous network input! Cannot connect sink roadSegment=" + toRoadSegment + "\nfrom lane=" + fromLane + " of source roadSegment=" + toRoadSegment + ".\n Source already is=" + fromRoadsegment.sinkLaneSegment(fromLane).roadSegment()); } fromRoadsegment.setSinkLaneSegmentForLane(toRoadSegment.laneSegment(toLane), fromLane); } private  Link(); }
Link { public static void addLanePair(int fromLane, RoadSegment fromRoadsegment, int toLane, RoadSegment toRoadSegment) { if (toRoadSegment.sourceLaneSegment(toLane) != null && toRoadSegment.sourceLaneSegment(toLane).roadSegment() != fromRoadsegment) { throw new IllegalArgumentException("Ambiguous network input! Cannot connect source roadSegment=" + fromRoadsegment + "\nto lane=" + toLane + " of sink roadSegment=" + toRoadSegment + ".\n Sink already is=" + toRoadSegment.sourceLaneSegment(toLane).roadSegment()); } toRoadSegment.setSourceLaneSegmentForLane(fromRoadsegment.laneSegment(fromLane), toLane); if (fromRoadsegment.sinkLaneSegment(fromLane) != null && fromRoadsegment.sinkLaneSegment(fromLane).roadSegment() != toRoadSegment) { throw new IllegalArgumentException("Ambiguous network input! Cannot connect sink roadSegment=" + toRoadSegment + "\nfrom lane=" + fromLane + " of source roadSegment=" + toRoadSegment + ".\n Source already is=" + fromRoadsegment.sinkLaneSegment(fromLane).roadSegment()); } fromRoadsegment.setSinkLaneSegmentForLane(toRoadSegment.laneSegment(toLane), fromLane); } private  Link(); static void addLanePair(int fromLane, RoadSegment fromRoadsegment, int toLane, RoadSegment toRoadSegment); static RoadSegment addJoin(RoadSegment sourceRoad, RoadSegment sinkRoad); static void addMerge(RoadSegment fromRoad1, RoadSegment fromRoad2, RoadSegment toRoad); static void addFork(RoadSegment fromRoad, RoadSegment toRoad1, RoadSegment toRoad2); }
Link { public static void addLanePair(int fromLane, RoadSegment fromRoadsegment, int toLane, RoadSegment toRoadSegment) { if (toRoadSegment.sourceLaneSegment(toLane) != null && toRoadSegment.sourceLaneSegment(toLane).roadSegment() != fromRoadsegment) { throw new IllegalArgumentException("Ambiguous network input! Cannot connect source roadSegment=" + fromRoadsegment + "\nto lane=" + toLane + " of sink roadSegment=" + toRoadSegment + ".\n Sink already is=" + toRoadSegment.sourceLaneSegment(toLane).roadSegment()); } toRoadSegment.setSourceLaneSegmentForLane(fromRoadsegment.laneSegment(fromLane), toLane); if (fromRoadsegment.sinkLaneSegment(fromLane) != null && fromRoadsegment.sinkLaneSegment(fromLane).roadSegment() != toRoadSegment) { throw new IllegalArgumentException("Ambiguous network input! Cannot connect sink roadSegment=" + toRoadSegment + "\nfrom lane=" + fromLane + " of source roadSegment=" + toRoadSegment + ".\n Source already is=" + fromRoadsegment.sinkLaneSegment(fromLane).roadSegment()); } fromRoadsegment.setSinkLaneSegmentForLane(toRoadSegment.laneSegment(toLane), fromLane); } private  Link(); static void addLanePair(int fromLane, RoadSegment fromRoadsegment, int toLane, RoadSegment toRoadSegment); static RoadSegment addJoin(RoadSegment sourceRoad, RoadSegment sinkRoad); static void addMerge(RoadSegment fromRoad1, RoadSegment fromRoad2, RoadSegment toRoad); static void addFork(RoadSegment fromRoad, RoadSegment toRoad1, RoadSegment toRoad2);  }