Package org.onebusaway.transit_data_federation.services.transit_graph

Examples of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry


  }

  @Test
  public void testGenerateStopNarratives() {

    StopEntry stopEntry = stop("stopA", 47.0, -122.0);

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

    Stop stop = new Stop();
    stop.setId(stopEntry.getId());
    stop.setCode("A");
    stop.setDesc("Stop A is the best");
    stop.setLat(stopEntry.getStopLat());
    stop.setLon(stopEntry.getStopLon());
    stop.setName("Stop A");
    stop.setUrl("http://agency.gov/stop-a");

    Mockito.when(_gtfsDao.getAllStops()).thenReturn(Arrays.asList(stop));

    List<BlockStopTimeIndex> indices = Collections.emptyList();
    Mockito.when(_blockIndexService.getStopTimeIndicesForStop(stopEntry)).thenReturn(
        indices);

    _task.generateStopNarratives(_provider);

    StopNarrative narrative = _provider.getNarrativeForStopId(stopEntry.getId());
    assertEquals(stop.getCode(), narrative.getCode());
    assertEquals(stop.getDesc(), narrative.getDescription());
    assertNull(narrative.getDirection());
    assertEquals(stop.getLocationType(), narrative.getLocationType());
    assertEquals(stop.getName(), narrative.getName());
View Full Code Here


  }

  @Test
  public void testGenerateStopNarrativesWithHardCodedDirection() {

    StopEntry stopEntry = stop("stopA", 47.0, -122.0);

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

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

    List<BlockStopTimeIndex> indices = Collections.emptyList();
    Mockito.when(_blockIndexService.getStopTimeIndicesForStop(stopEntry)).thenReturn(
        indices);

    _task.generateStopNarratives(_provider);

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

    double w = 0;

    if (isFromSourceStop) {

      if (parentNode != null) {
        StopEntry fromStop = parentNode.getToStop();
        StopEntry toStop = node.getFromStop();
        double transferWeight = computeTransferWeight(
            fromStop.getStopLocation(), toStop.getStopLocation());
        w += transferWeight;
      }

      StopEntry fromStop = node.getFromStop();
      StopEntry toStop = node.getToStop();

      int transitWeight = computeTransitWeight(fromStop.getStopLocation(),
          toStop.getStopLocation());
      w += transitWeight;
    }

    /**
     * What's our best option?
     */
    double minOption = node.getMinRemainingWeight();

    if (minOption < 0) {

      minOption = Double.POSITIVE_INFINITY;

      /**
       * We could exit if we're allowed, walking to our destination
       */
      if (node.isExitAllowed()) {

        StopEntry toStop = node.getToStop();

        double transferWeight = computeTransferWeight(toStop.getStopLocation(),
            target);
        minOption = Math.min(transferWeight, minOption);
      }

      /**
       * Or we could transfer to another transfer pattern
       */
      Collection<TransferNode> transfers = node.getTransfers();
      for (TransferNode subTree : transfers) {
        if (!visitedNodes.contains(subTree)) {
          double subWeight = getWeightForTransferNode(node, subTree, true,
              target, visitedNodes);
          minOption = Math.min(subWeight, minOption);
        }
      }
      Collection<HubNode> hubs = node.getHubs();
      for (HubNode hubNode : hubs) {
        StopEntry hubStop = hubNode.getHubStop();
        CoordinatePoint hubLocation = hubStop.getStopLocation();
        double transferWeight = computeTransferWeight(
            node.getToStop().getStopLocation(), hubLocation);
        double transitWeight = computeTransitWeight(hubLocation, target);
        double subWeight = transferWeight + transitWeight;
        minOption = Math.min(subWeight, minOption);
View Full Code Here

  @Override
  @Cacheable
  public Set<AgencyAndId> getRouteCollectionIdsForStop(AgencyAndId stopId) {

    StopEntry stopEntry = _transitGraphDao.getStopEntryForId(stopId);
    if (stopEntry == null)
      throw new InternalErrorServiceException("no such stop: id=" + stopId);

    Set<AgencyAndId> routeCollectionIds = new HashSet<AgencyAndId>();
View Full Code Here

    Map<AgencyAndId, CompactedTransferPattern> patternsByStopId = ObjectSerializationLibrary.readObject(path);
    _log.info("transfer patterns loaded");

    for (Map.Entry<AgencyAndId, CompactedTransferPattern> entry : patternsByStopId.entrySet()) {
      AgencyAndId stopId = entry.getKey();
      StopEntry stop = _transitGraphDao.getStopEntryForId(stopId, true);
      CompactedTransferPattern pattern = entry.getValue();
      pattern.setAllStops(_transitGraphDao.getAllStops());
      _transferPatternsByStop.put(stop, pattern);
    }
  }
View Full Code Here

    Map<StopEntry, List<TransferParent>> hubParentsByStop = pattern.getTransfersForHubStops(root);

    for (Map.Entry<StopEntry, List<TransferParent>> entry : hubParentsByStop.entrySet()) {

      StopEntry hubStop = entry.getKey();
      List<TransferParent> parents = entry.getValue();

      TransferParent nodes = transferPatternData.getNodesForHubStop(hubStop);

      if (nodes == null) {
View Full Code Here

  }

  private List<StopEntry> getStopsInOrder(StopSequenceCollection block) {
    DirectedGraph<StopEntry> graph = new DirectedGraph<StopEntry>();
    for (StopSequence sequence : block.getStopSequences()) {
      StopEntry prev = null;
      for (StopEntry stop : sequence.getStops()) {
        if (prev != null) {
          // We do this to avoid cycles
          if (!graph.isConnected(stop, prev))
            graph.addEdge(prev, stop);
View Full Code Here

  @Override
  public List<StopTimeInstance> getStopTimeInstancesInTimeRange(
      AgencyAndId stopId, Date from, Date to) {

    StopEntry stopEntry = _graph.getStopEntryForId(stopId, true);
    return getStopTimeInstancesInTimeRange(stopEntry, from, to,
        EFrequencyStopTimeBehavior.INCLUDE_UNSPECIFIED);
  }
View Full Code Here

  @Override
  public Range getDepartureForStopAndServiceDate(AgencyAndId stopId,
      ServiceDate serviceDate) {

    StopEntry stop = _graph.getStopEntryForId(stopId, true);

    List<BlockStopTimeIndex> indices = _blockIndexService.getStopTimeIndicesForStop(stop);

    Range interval = new Range();
View Full Code Here

   ****************************************************************************/

  private void writeObject(ObjectOutputStream out) throws IOException {
    AgencyAndId[] ids = new AgencyAndId[_stops.length];
    for (int i = 0; i < ids.length; i++) {
      StopEntry entry = _stops[i];
      ids[i] = entry.getId();
    }
    out.writeObject(ids);
    out.writeObject(_values);
  }
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry

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.