コード例 #1
0
  public void testStreetLocationFinder() {
    StreetVertexIndexServiceImpl finder = new StreetVertexIndexServiceImpl(graph);
    finder.setup();
    // test that the local stop finder finds stops
    assertTrue(finder.getLocalTransitStops(new Coordinate(-74.005000001, 40.01), 100).size() > 0);

    // test that the closest vertex finder returns the closest vertex
    StreetLocation some =
        (StreetLocation) finder.getClosestVertex(new Coordinate(-74.00, 40.00), null);
    assertNotNull(some);
    assertTrue(
        "wheelchair accessibility is correctly set (vertices)", some.isWheelchairAccessible());

    // test that the closest vertex finder correctly splits streets
    StreetLocation start =
        (StreetLocation) finder.getClosestVertex(new Coordinate(-74.01, 40.004), null);
    assertNotNull(start);
    assertTrue(
        "wheelchair accessibility is correctly set (splitting)", start.isWheelchairAccessible());

    List<DirectEdge> extras = start.getExtra();
    assertEquals(10, extras.size());

    TraverseOptions biking = new TraverseOptions(new TraverseModeSet(TraverseMode.BICYCLE));
    StreetLocation end =
        (StreetLocation) finder.getClosestVertex(new Coordinate(-74.0, 40.008), biking);
    assertNotNull(end);

    extras = end.getExtra();
    assertEquals(10, extras.size());

    // test that the closest vertex finder also adds an edge to transit
    // stops (if you are really close to the transit stop relative to the
    // street)
    StreetLocation location =
        (StreetLocation)
            finder.getClosestVertex(new Coordinate(-74.004999, 40.00999), new TraverseOptions());
    assertTrue(location.isWheelchairAccessible());
    boolean found = false;
    for (Edge extra : location.getExtra()) {
      if (extra instanceof FreeEdge && ((FreeEdge) extra).getToVertex().equals(station1)) {
        found = true;
      }
    }
    assertTrue(found);
  }
コード例 #2
0
 // this could be handled by method overloading on Vertex
 public boolean isWheelchairAccessible(Vertex v) {
   if (v instanceof TransitStop) {
     TransitStop ts = (TransitStop) v;
     return ts.hasWheelchairEntrance();
   } else if (v instanceof StreetLocation) {
     StreetLocation sl = (StreetLocation) v;
     return sl.isWheelchairAccessible();
   }
   return true;
 }
コード例 #3
0
 @Override
 public boolean isAccessible(String place, TraverseOptions options) {
   /* fixme: take into account slope for wheelchair accessibility */
   Vertex vertex = getVertexForPlace(place, options);
   if (vertex instanceof TransitStop) {
     TransitStop ts = (TransitStop) vertex;
     return ts.hasWheelchairEntrance();
   } else if (vertex instanceof StreetLocation) {
     StreetLocation sl = (StreetLocation) vertex;
     return sl.isWheelchairAccessible();
   }
   return true;
 }