Package org.onebusaway.transit_data_federation.impl.transit_graph

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


    _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);
View Full Code Here


    tripA.setShapeId(shapeIdA);

    TripEntryImpl tripB = trip("tripB");
    tripB.setShapeId(shapeIdB);

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

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

    BlockStopTimeEntry blockStopTimeA = Mockito.mock(BlockStopTimeEntry.class);
    Mockito.when(blockStopTimeA.getStopTime()).thenReturn(stopTimeA);

    BlockStopTimeEntry blockStopTimeB = Mockito.mock(BlockStopTimeEntry.class);
View Full Code Here

    assertEquals(trip.getTripHeadsign(), narrative.getTripHeadsign());
    assertEquals(trip.getTripShortName(), narrative.getTripShortName());

    StopEntryImpl stopEntry = stop("stop", 47.0, -122.0);
    TripEntryImpl tripEntry = trip("trip");
    StopTimeEntryImpl stopTimeEntry = stopTime(0, stopEntry, tripEntry, 0, 0.0);

    StopTimeNarrative stopTimeNarrative = _provider.getNarrativeForStopTimeEntry(stopTimeEntry);
    assertEquals(stopTime.getRouteShortName(),
        stopTimeNarrative.getRouteShortName());
    assertEquals(stopTime.getStopHeadsign(),
View Full Code Here

    BlockEntryImpl blockA = block("blockA");
    TripEntryImpl tripA = trip("tripA", "sA", 3000);

    stopTime(0, stopA, tripA, time(16, 30), time(16, 35), 1000);
    StopTimeEntryImpl stopTimeAB = stopTime(1, stopB, tripA, time(16, 40),
        time(16, 45), 2000);

    BlockConfigurationEntry blockConfigA = blockConfiguration(blockA,
        serviceIds(lsids("sA"), lsids()), tripA);
    BlockStopTimeEntry bstAA = blockConfigA.getStopTimes().get(0);
    BlockStopTimeEntry bstAB = blockConfigA.getStopTimes().get(1);

    /****
     * Block B
     ****/

    BlockEntryImpl blockB = block("blockB");
    TripEntryImpl tripB = trip("tripB", "sA", 3000);

    stopTime(2, stopA, tripB, time(16, 40), time(16, 45), 1000);
    StopTimeEntryImpl stopTimeBB = stopTime(3, stopB, tripB, time(16, 50),
        time(16, 55), 2000);

    BlockConfigurationEntry blockConfigB = blockConfiguration(blockB,
        serviceIds(lsids("sA"), lsids()), tripB);
    BlockStopTimeEntry bstBA = blockConfigB.getStopTimes().get(0);
View Full Code Here

    return stopTime;
  }

  public static StopTimeEntryImpl stopTime() {
    return new StopTimeEntryImpl();
  }
View Full Code Here

  public static StopTimeEntryImpl stopTime(int id, StopEntryImpl stop,
      TripEntryImpl trip, int arrivalTime, int departureTime,
      double shapeDistTraveled, int shapeIndex) {

    StopTimeEntryImpl stopTime = new StopTimeEntryImpl();
    stopTime.setId(id);
    stopTime.setStop(stop);

    stopTime.setArrivalTime(arrivalTime);
    stopTime.setDepartureTime(departureTime);
    stopTime.setShapeDistTraveled(shapeDistTraveled);
    stopTime.setShapePointIndex(shapeIndex);

    if (trip != null)
      addStopTime(trip, stopTime);

    return stopTime;
View Full Code Here

      PointAndIndex first = possibleAssignments.get(0).get(0);
      PointAndIndex second = possibleAssignments.get(1).get(0);
      if (first.distanceAlongShape > second.distanceAlongShape) {

        StopTimeEntryImpl firstStopTime = stopTimes.get(0);

        _log.warn("snapping first stop time id=" + firstStopTime.getId()
            + " to start of shape");

        XYPoint point = projectedShapePoints.get(0);

        StopEntryImpl stop = firstStopTime.getStop();
        XYPoint stopPoint = projection.forward(stop.getStopLocation());

        double d = stopPoint.getDistance(point);

        possibleAssignments.get(0).add(new PointAndIndex(point, 0, d, 0.0));
View Full Code Here

  private PointAndIndex getLastStopSnappedToEndOfShape(
      List<StopTimeEntryImpl> stopTimes, ShapePoints shapePoints,
      UTMProjection projection, List<XYPoint> projectedShapePoints) {

    int i = stopTimes.size() - 1;
    StopTimeEntryImpl lastStopTime = stopTimes.get(i);

    int lastShapePointIndex = projectedShapePoints.size() - 1;
    XYPoint lastShapePoint = projectedShapePoints.get(lastShapePointIndex);
    XYPoint stopLocation = projection.forward(lastStopTime.getStop().getStopLocation());

    double existingDistanceAlongShape = shapePoints.getDistTraveledForIndex(lastShapePointIndex);
    double extraDistanceAlongShape = lastShapePoint.getDistance(stopLocation);
    double distanceAlongShape = existingDistanceAlongShape
        + extraDistanceAlongShape;
View Full Code Here

          + "assignments, which usually indicates that there is something wrong with the underlying shape data.  "
          + "For more information on errors of this kind, see:\n"
          + "  https://github.com/OneBusAway/onebusaway-application-modules/wiki/Stop-to-Shape-Matching");
    }

    StopTimeEntryImpl first = stopTimes.get(0);
    TripEntryImpl trip = first.getTrip();
    StopTimeEntryImpl last = stopTimes.get(stopTimes.size() - 1);

    _log.error("error constructing stop-time distances along shape for trip="
        + trip.getId() + " shape=" + trip.getShapeId() + " firstStopTime="
        + first.getId() + " lastStopTime=" + last.getId());

    if (_shapeIdsWeHavePrinted.add(trip.getShapeId())) {
      StringBuilder b = new StringBuilder();
      for (int i = 0; i < shapePoints.getSize(); i++) {
        b.append(shapePoints.getLatForIndex(i));
View Full Code Here

  private void constructError(ShapePoints shapePoints,
      List<StopTimeEntryImpl> stopTimes,
      List<List<PointAndIndex>> possibleAssignments, UTMProjection projection)
      throws InvalidStopToShapeMappingException {

    StopTimeEntryImpl first = stopTimes.get(0);
    StopTimeEntryImpl last = stopTimes.get(stopTimes.size() - 1);

    _log.error("We were attempting to compute the distance along a particular trip for each stop time of that trip by "
        + "snapping them to the shape for that trip.  However, we could not find an assignment for each stop time "
        + "where the distance traveled along the shape for each stop time was strictly increasing (aka a stop time "
        + "seemed to travel backwards).  For more information on errors of this kind, see:\n"
        + "  https://github.com/OneBusAway/onebusaway-application-modules/wiki/Stop-to-Shape-Matching");

    TripEntryImpl trip = first.getTrip();
    _log.error("error constructing stop-time distances along shape for trip="
        + trip.getId() + " shape=" + trip.getShapeId() + " firstStopTime="
        + first.getId() + " lastStopTime=" + last.getId());

    StringBuilder b = new StringBuilder();
    int index = 0;

    b.append("# potential assignments:\n");
    b.append("# stopLat stopLon stopId\n");
    b.append("#   locationOnShapeLat locationOnShapeLon distanceAlongShape distanceFromShape shapePointIndex\n");
    b.append("#   ...\n");

    double prevMaxDistanceAlongShape = Double.NEGATIVE_INFINITY;

    for (List<PointAndIndex> possible : possibleAssignments) {
      StopTimeEntryImpl stopTime = stopTimes.get(index);
      StopEntryImpl stop = stopTime.getStop();
      b.append(stop.getStopLat());
      b.append(' ');
      b.append(stop.getStopLon());
      b.append(' ');
      b.append(index);
View Full Code Here

TOP

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

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.