Package org.onebusaway.transit_data_federation.impl.transit_graph

Examples of org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl


  private void loadStopTimeIndices() {

    // Clear any existing indices
    for (StopEntry stop : _graphDao.getAllStops()) {
      StopEntryImpl stopImpl = (StopEntryImpl) stop;
      stopImpl.getStopTimeIndices().clear();
      stopImpl.getFrequencyStopTimeIndices().clear();
    }

    BlockStopTimeIndicesFactory factory = new BlockStopTimeIndicesFactory();
    factory.setVerbose(true);
    List<BlockStopTimeIndex> indices = factory.createIndices(_graphDao.getAllBlocks());

    for (BlockStopTimeIndex index : indices) {
      StopEntryImpl stop = (StopEntryImpl) index.getStop();
      stop.addStopTimeIndex(index);
    }

    List<FrequencyBlockStopTimeIndex> frequencyIndices = factory.createFrequencyIndices(_graphDao.getAllBlocks());

    for (FrequencyBlockStopTimeIndex index : frequencyIndices) {
      StopEntryImpl stop = (StopEntryImpl) index.getStop();
      stop.addFrequencyStopTimeIndex(index);
    }
  }
View Full Code Here


  private void loadStopTripIndices() {

    // Clear any existing indices
    for (StopEntry stop : _graphDao.getAllStops()) {
      StopEntryImpl stopImpl = (StopEntryImpl) stop;
      stopImpl.getStopTripIndices().clear();
      stopImpl.getFrequencyStopTripIndices().clear();
    }

    for (BlockSequenceIndex index : _blockSequenceIndices) {

      BlockSequence sequence = index.getSequences().get(0);

      int offset = 0;

      for (BlockStopTimeEntry bst : sequence.getStopTimes()) {

        StopTimeEntry stopTime = bst.getStopTime();
        StopEntryImpl stop = (StopEntryImpl) stopTime.getStop();

        BlockStopSequenceIndex blockStopTripIndex = new BlockStopSequenceIndex(
            index, offset);

        stop.addBlockStopTripIndex(blockStopTripIndex);
        offset++;
      }
    }

    for (FrequencyBlockTripIndex index : _frequencyBlockTripIndices) {

      BlockTripEntry trip = index.getTrips().get(0);

      int offset = 0;

      for (BlockStopTimeEntry bst : trip.getStopTimes()) {

        StopTimeEntry stopTime = bst.getStopTime();
        StopEntryImpl stop = (StopEntryImpl) stopTime.getStop();

        FrequencyStopTripIndex stopTripIndex = new FrequencyStopTripIndex(
            index, offset);
        stop.addFrequencyStopTripIndex(stopTripIndex);
        offset++;
      }
    }
  }
View Full Code Here

  @Test
  public void test() {

    BlockIndexFactoryServiceImpl factory = new BlockIndexFactoryServiceImpl();

    StopEntryImpl stopA = stop("a", 47.0, -122.0);
    StopEntryImpl stopB = stop("b", 47.1, -122.1);
    StopEntryImpl stopC = stop("c", 47.2, -122.2);

    /****
     * Block A
     ****/

 
View Full Code Here

  @Test
  public void testFrequencies() {

    BlockIndexFactoryServiceImpl factory = new BlockIndexFactoryServiceImpl();

    StopEntryImpl stopA = stop("a", 47.0, -122.0);
    StopEntryImpl stopB = stop("b", 47.1, -122.1);

    /****
     * Block A
     ****/

 
View Full Code Here

  @Test
  public void testOverlappingFrequencies() {

    BlockIndexFactoryServiceImpl factory = new BlockIndexFactoryServiceImpl();

    StopEntryImpl stopA = stop("a", 47.0, -122.0);
    StopEntryImpl stopB = stop("b", 47.1, -122.1);

    /****
     * Block A
     ****/

 
View Full Code Here

  @Test
  public void testGenerateStopSearchIndex() throws CorruptIndexException,
      IOException, ParseException {

    StopEntryImpl stopA = stop("111", 0, 0);
    StopEntryImpl stopB = stop("222", 0, 0);
    StopEntryImpl stopC = stop("333", 0, 0);

    StopNarrative.Builder stopNarrativeA = StopNarrative.builder();
    stopNarrativeA.setCode("111");
    stopNarrativeA.setName("AAA Station");

    StopNarrative.Builder stopNarrativeB = StopNarrative.builder();
    stopNarrativeB.setName("BBB Station");

    StopNarrative.Builder stopNarrativeC = StopNarrative.builder();
    stopNarrativeC.setCode("444");
    stopNarrativeC.setName("CCC Station");

    Mockito.when(_transitGraphDao.getAllStops()).thenReturn(
        Arrays.asList((StopEntry) stopA, stopB, stopC));

    Mockito.when(_narrativeService.getStopForId(stopA.getId())).thenReturn(
        stopNarrativeA.create());
    Mockito.when(_narrativeService.getStopForId(stopB.getId())).thenReturn(
        stopNarrativeB.create());
    Mockito.when(_narrativeService.getStopForId(stopC.getId())).thenReturn(
        stopNarrativeC.create());

    _task.run();

    StopSearchServiceImpl searchService = new StopSearchServiceImpl();
View Full Code Here

    builder9.addAffects(affects9);
    _service.createOrUpdateServiceAlert(builder9, "1");

    RouteEntryImpl route = route("RouteX");
    routeCollection("RouteX", route);
    StopEntryImpl stop = stop("10020", 47.0, -122.0);
    TripEntryImpl trip = trip("TripA");
    trip.setRoute(route);
    trip.setDirectionId("1");
    stopTime(0, stop, trip, time(8, 53), 0);
    BlockEntryImpl block = block("block");
View Full Code Here

    builder9.addAffects(affects9);
    _service.createOrUpdateServiceAlert(builder9, "1");

    RouteEntryImpl route = route("RouteX");
    routeCollection("RouteX", route);
    StopEntryImpl stop = stop("10020", 47.0, -122.0);
    TripEntryImpl trip = trip("TripA");
    trip.setRoute(route);
    trip.setDirectionId("1");
    stopTime(0, stop, trip, time(8, 53), 0);
    BlockEntryImpl block = block("block");
View Full Code Here

  @Test
  public void testGetStopForId() {

    AgencyAndId stopId = new AgencyAndId("29", "1109");

    StopEntryImpl stopEntry = new StopEntryImpl(stopId, 47.1, -122.1);
    Mockito.when(_transitGraphDao.getStopEntryForId(stopId)).thenReturn(
        stopEntry);

    StopNarrative.Builder builder = StopNarrative.builder();
    builder.setCode("1109-b");
    builder.setDescription("stop description");
    builder.setLocationType(0);
    builder.setName("stop name");
    builder.setUrl("http://some/url");
    builder.setDirection("N");

    StopNarrative stop = builder.create();

    Mockito.when(_narrativeService.getStopForId(stopId)).thenReturn(stop);

    AgencyAndId routeId = new AgencyAndId("1", "route");

    Set<AgencyAndId> routeIds = new HashSet<AgencyAndId>();
    routeIds.add(routeId);

    Mockito.when(_routeService.getRouteCollectionIdsForStop(stopId)).thenReturn(
        routeIds);

    RouteBean.Builder routeBuilder = RouteBean.builder();
    routeBuilder.setId(AgencyAndIdLibrary.convertToString(routeId));
    RouteBean route = routeBuilder.create();
    Mockito.when(_routeBeanService.getRouteForId(routeId)).thenReturn(route);

    StopBean stopBean = _service.getStopForId(stopId);

    assertNotNull(stopBean);
    assertEquals(stopId.toString(), stopBean.getId());
    assertEquals(stop.getName(), stopBean.getName());
    assertEquals(stopEntry.getStopLat(), stopBean.getLat(), 0.0);
    assertEquals(stopEntry.getStopLon(), stopBean.getLon(), 0.0);
    assertEquals(stop.getCode(), stopBean.getCode());
    assertEquals(stop.getLocationType(), stopBean.getLocationType());

    List<RouteBean> routes = stopBean.getRoutes();
    assertEquals(1, routes.size());
View Full Code Here

  }

  @Test
  public void testGenerateStopNarrativesWithCalculatedDirection() {

    StopEntryImpl stopEntry = stop("stopA", 47.663146, -122.300928);

    Mockito.when(_transitGraphDao.getAllStops()).thenReturn(
        Arrays.asList((StopEntry) stopEntry));

    Stop stop = new Stop();
    stop.setId(stopEntry.getId());
    Mockito.when(_gtfsDao.getAllStops()).thenReturn(Arrays.asList(stop));

    AgencyAndId shapeId = aid("shapeA");
    ShapePointsFactory factory = new ShapePointsFactory();
    factory.addPoint(47.661225, -122.3009201);
    factory.addPoint(47.664375, -122.3008986);
    ShapePoints shapePoints = factory.create();

    _provider.setShapePointsForId(shapeId, shapePoints);

    TripEntryImpl trip = trip("trip");
    trip.setShapeId(shapeId);

    StopTimeEntryImpl stopTime = stopTime(0, stopEntry, trip, 0, 0.0);
    stopTime.setShapePointIndex(0);

    BlockStopTimeEntry blockStopTime = Mockito.mock(BlockStopTimeEntry.class);
    Mockito.when(blockStopTime.getStopTime()).thenReturn(stopTime);

    BlockStopTimeIndex index = Mockito.mock(BlockStopTimeIndex.class);
    Mockito.when(index.getStopTimes()).thenReturn(Arrays.asList(blockStopTime));

    List<BlockStopTimeIndex> indices = Arrays.asList(index);
    Mockito.when(_blockIndexService.getStopTimeIndicesForStop(stopEntry)).thenReturn(
        indices);

    _task.generateStopNarratives(_provider);

    StopNarrative narrative = _provider.getNarrativeForStopId(stopEntry.getId());
    assertEquals("N", narrative.getDirection());
  }
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.