Exemplo n.º 1
0
  /**
   * Ensures that the set of roads in the network matches a predefined set.
   *
   * @throws IOException
   */
  @Test
  public void testGetRoads() throws IOException, InterruptedException {
    Set<String> expectedLaneIDs = new HashSet<String>();
    expectedLaneIDs.add("beg_0");
    expectedLaneIDs.add(":beg_0_0");
    expectedLaneIDs.add(":beg_1_0");
    expectedLaneIDs.add("beg2left_0");
    expectedLaneIDs.add(":begleft_0_0");
    expectedLaneIDs.add("middle_0");
    expectedLaneIDs.add("left_0");
    expectedLaneIDs.add(":endleft_0_0");
    expectedLaneIDs.add("left2end_0");
    expectedLaneIDs.add(":end_0_0");
    expectedLaneIDs.add(":end_1_0");
    expectedLaneIDs.add("end_0");
    expectedLaneIDs.add(":absEnd_0_0");
    expectedLaneIDs.add("rend_0");

    Collection<Lane> lanes = conn.getLaneRepository().getAll().values();
    Set<String> laneIDs = new HashSet<String>();
    for (Lane lane : lanes) {
      laneIDs.add(lane.getID());
    }

    assertEquals(expectedLaneIDs, laneIDs);
  }
Exemplo n.º 2
0
 /**
  * This test demonstrates the usage of the {@link Lane} object to get geometric information.
  *
  * @throws IOException
  */
 @Test
 public void testGetShape() throws IOException {
   Lane lane = conn.getLaneRepository().getByID("beg_0");
   PathIterator it = lane.getShape().getPathIterator(null);
   assertFalse(it.isDone());
   double[] coords = new double[2];
   assertEquals(PathIterator.SEG_MOVETO, it.currentSegment(coords));
   assertEquals(0, coords[0], DELTA);
   assertEquals(-1.65, coords[1], DELTA);
   it.next();
   assertEquals(PathIterator.SEG_LINETO, it.currentSegment(coords));
   assertEquals(498.55, coords[0], DELTA);
   assertEquals(-1.65, coords[1], DELTA);
   it.next();
   assertTrue(it.isDone());
 }
Exemplo n.º 3
0
  /**
   * This test demonstrates the usage of the {@link Link} object by testing the links between a lane
   * and the lanes a vehicle can go through.
   *
   * @throws IOException
   */
  @Test
  public void testLaneLinks() throws IOException {
    Lane begLane = conn.getLaneRepository().getByID("beg_0");
    List<Link> links = begLane.getLinks();
    Set<String> linkIDs = new HashSet<String>();
    Set<String> intLinkIDs = new HashSet<String>();
    for (Link link : links) {
      linkIDs.add(link.getNextNonInternalLane().getID());
      intLinkIDs.add(link.getNextInternalLane().getID());
    }

    assertEquals(2, linkIDs.size());
    assertTrue(linkIDs.contains("middle_0"));
    assertTrue(intLinkIDs.contains(":beg_0_0"));
    assertTrue(linkIDs.contains("beg2left_0"));
    assertTrue(intLinkIDs.contains(":beg_1_0"));
  }
Exemplo n.º 4
0
 private static Point2D getLastPointOfALane(Lane lane) throws IOException {
   Path2D shape = lane.queryReadShape().get();
   PathIterator it = shape.getPathIterator(null);
   double[] coords = new double[6];
   while (!it.isDone()) {
     it.currentSegment(coords);
     it.next();
   }
   Point2D lastPoint = new Point2D.Double(coords[0], coords[1]);
   return lastPoint;
 }
Exemplo n.º 5
0
 /**
  * This test demonstrates the usage of the {@link Lane} object to get topological information.
  *
  * @throws IOException
  */
 @Test
 public void testGetBelongingEdge() throws IOException {
   Lane lane = conn.getLaneRepository().getByID("beg_0");
   Edge edge = lane.getParentEdge();
   assertEquals("beg", edge.getID());
 }