コード例 #1
0
  @Test
  public void testLanes() throws Exception {

    List<RouteSegmentResult> routeSegments = fe.searchRoute(ctx, startPoint, endPoint, null);
    Set<Long> reachedSegments = new TreeSet<Long>();
    Assert.assertNotNull(routeSegments);
    int prevSegment = -1;
    for (int i = 0; i <= routeSegments.size(); i++) {
      if (i == routeSegments.size() || routeSegments.get(i).getTurnType() != null) {
        if (prevSegment >= 0) {
          String lanes = getLanesString(routeSegments.get(prevSegment));
          String turn = routeSegments.get(prevSegment).getTurnType().toXmlString();
          String turnLanes = turn + ":" + lanes;
          String name = routeSegments.get(prevSegment).getDescription();

          long segmentId = routeSegments.get(prevSegment).getObject().getId();
          String expectedResult = expectedResults.get(segmentId);
          if (expectedResult != null) {
            if (!Algorithms.objectEquals(expectedResult, turnLanes)
                && !Algorithms.objectEquals(expectedResult, lanes)
                && !Algorithms.objectEquals(expectedResult, turn)) {
              Assert.assertEquals("Segment " + segmentId, expectedResult, turnLanes);
            }
          }

          System.out.println("segmentId: " + segmentId + " description: " + name);
        }
        prevSegment = i;
      }

      if (i < routeSegments.size()) {
        reachedSegments.add(routeSegments.get(i).getObject().getId());
      }
    }

    Set<Long> expectedSegments = expectedResults.keySet();
    for (Long expSegId : expectedSegments) {
      Assert.assertTrue(
          "Expected segment "
              + expSegId
              + " weren't reached in route segments "
              + reachedSegments.toString(),
          reachedSegments.contains(expSegId));
    }
  }
コード例 #2
0
  @BeforeClass
  public static void setUp() throws Exception {
    String fileName = "../../resources/Turn_lanes_test.obf";

    File fl = new File(fileName);

    RandomAccessFile raf = new RandomAccessFile(fl, "r");

    fe = new RoutePlannerFrontEnd(false);
    RoutingConfiguration.Builder builder = RoutingConfiguration.getDefault();
    Map<String, String> params = new LinkedHashMap<String, String>();
    params.put("car", "true");
    params.put("short_way", "true");
    RoutingConfiguration config =
        builder.build("car", RoutingConfiguration.DEFAULT_MEMORY_LIMIT * 3, params);
    BinaryMapIndexReader[] binaryMapIndexReaders = {new BinaryMapIndexReader(raf, fl)};
    ctx =
        fe.buildRoutingContext(
            config, null, binaryMapIndexReaders, RoutePlannerFrontEnd.RouteCalculationMode.NORMAL);
    ctx.leftSideNavigation = false;
    RouteResultPreparation.PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST = true;
  }