Examples of StopTime


Examples of models.transit.StopTime

            for (StopTimeWithDeletion stopTime : trip.stopTimes) {
                if (Boolean.TRUE.equals(stopTime.deleted)) {
                    StopTime.delete("id = ? AND trip = ?", stopTime.id, updatedTrip);
                }
                else {
                    StopTime updatedStopTime = StopTime.em().merge(stopTime.toStopTime());
                    // this was getting lost somehow
                    updatedStopTime.trip = updatedTrip;
                    updatedStopTime.save();
                }
            }
           
            updatedTrip.save();
View Full Code Here

Examples of models.transit.StopTime

     */
    public static class StopTimeWithDeletion extends StopTime {
        public Boolean deleted;
       
        public StopTime toStopTime () {
            StopTime ret = new StopTime();
            ret.id = this.id;
            ret.arrivalTime = this.arrivalTime;
            ret.departureTime = this.departureTime;
            ret.dropOffType = this.dropOffType;
            ret.patternStop = this.patternStop;
View Full Code Here

Examples of models.transit.StopTime

                
                   if(columnIndex > 5)
                   {
                     if(!column.isEmpty())
                     {
                       StopTime stopTime = new StopTime();
                      
                       stopTime.trip = trip;
                      
                       // check for board/alight only flag
                       if(column.contains(">")) {
                        
                         column = column.replace(">", "");
                        
                         // board only
                         stopTime.dropOffType = StopTimePickupDropOffType.NONE;
                       }
                      
                       if(column.contains("<")) {
                        
                         column = column.replace("<", "");
                        
                         // alight only
                         stopTime.pickupType = StopTimePickupDropOffType.NONE;
                       }
                      
                       column = column.trim();
                      
                       if(column.equals("+"))
                         stopTime.departureTime = firstTimepoint + columnStopDelta.get(columnIndex);
                       else if(column.equals("-"))
                         stopTime.departureTime = null;
                       else
                       {
                         Integer currentTime;
                          
                        
                         try
                         {
                           currentTime = (dfTime.parse(column).getHours() * 60 * 60 ) + (dfTime.parse(column).getMinutes() * 60) + (dfTime.parse(column).getSeconds());
                         }
                         catch(ParseException e)
                         {
                           try
                           {
                             currentTime = (dfsTime.parse(column).getHours() * 60 * 60 ) + (dfsTime.parse(column).getMinutes() * 60) + (dfsTime.parse(column).getSeconds());
                           }
                           catch(ParseException e2)
                           {
                             continue;
                           }
                         }
                        
                         // in case of time that decreases add a day to offset for trips that cross midnight boundary
                         if(previousTime > currentTime)                       
                           dayOffset += 24 * 60 * 60;
                          
                         stopTime.departureTime = currentTime + dayOffset;
                        
                         previousTime = currentTime;
                        
                         if(firstTimepoint == null)
                           {
                           firstTimepoint = stopTime.departureTime;
                           }
                        
                       }
                      
                       stopTime.arrivalTime = stopTime.departureTime;
                      
                       stopTime.patternStop = columnStopIndex.get(columnIndex);
                       stopTime.stop = columnStopIndex.get(columnIndex).stop;
                       stopTime.stopSequence = columnCount + 1;
                      
                       stopTime.save();
                      
                       columnCount++;
                     }
                   }
                    
View Full Code Here

Examples of org.onebusaway.gtfs.model.StopTime

      if (stop == null) {
        _prunedStopTimesCount++;
        continue;
      }

      StopTime stopTime = new StopTime();
      stopTime.setTrip(trip);
      stopTime.setStop(stop);
      if (timePoint.getArrivalTime() != 0 || timePoint.getDepartureTime() != 0
          || first) {
        stopTime.setArrivalTime(timePoint.getArrivalTime() * 60);
        stopTime.setDepartureTime(timePoint.getDepartureTime() * 60);
      }
      if (!timePoint.isPickUpAllowed()) {
        stopTime.setPickupType(1);
      }
      if (!timePoint.isDropOffAllowed()) {
        stopTime.setDropOffType(1);
      }

      stopTime.setStopSequence(_dao.getAllStopTimes().size());
      _dao.saveEntity(stopTime);
      first = false;
    }
    return true;
  }
View Full Code Here

Examples of org.onebusaway.gtfs.model.StopTime

    /** Assumes that stopTimes are already sorted by time. */
    public StopPattern (List<StopTime> stopTimes) {
        this (stopTimes.size());
        if (size == 0) return;
        for (int i = 0; i < size; ++i) {
            StopTime stopTime = stopTimes.get(i);
            stops[i] = stopTime.getStop();
            // should these just be booleans? anything but 1 means pick/drop is allowed.
            // pick/drop messages could be stored in individual trips
            pickups[i] = stopTime.getPickupType();
            dropoffs[i] = stopTime.getDropOffType();
        }
        /*
         * TriMet GTFS has many trips that differ only in the pick/drop status of their initial and
         * final stops. This may have something to do with interlining. They are turning pickups off
         * on the final stop of a trip to indicate that there is no interlining, because they supply
View Full Code Here

Examples of org.onebusaway.gtfs.model.StopTime

        thirdTrip.setRoute(thirdRoute);
        BikeAccess.setForTrip(thirdTrip, BikeAccess.ALLOWED);
        thirdTrip.setTripHeadsign("Handsome Molly");

        // Scheduled stop times for legs 1, 2 and 4, plus initialization and storage in a list
        StopTime trainStopDepartTime = new StopTime();
        StopTime trainStopDwellTime = new StopTime();
        StopTime trainStopInterlineFirstTime = new StopTime();
        StopTime trainStopInterlineSecondTime = new StopTime();
        StopTime trainStopArriveTime = new StopTime();
        StopTime ferryStopDepartTime = new StopTime();
        StopTime ferryStopArriveTime = new StopTime();

        trainStopDepartTime.setTrip(firstTrip);
        trainStopDepartTime.setStop(trainStopDepart);
        trainStopDepartTime.setStopSequence(Integer.MIN_VALUE);
        trainStopDepartTime.setDepartureTime(4);
        trainStopDepartTime.setPickupType(3);
        trainStopDwellTime.setTrip(firstTrip);
        trainStopDwellTime.setStop(trainStopDwell);
        trainStopDwellTime.setStopSequence(0);
        trainStopDwellTime.setArrivalTime(8);
        trainStopDwellTime.setDepartureTime(12);
        trainStopInterlineFirstTime.setTrip(firstTrip);
        trainStopInterlineFirstTime.setStop(trainStopInterline);
        trainStopInterlineFirstTime.setStopSequence(Integer.MAX_VALUE);
        trainStopInterlineFirstTime.setArrivalTime(16);
        trainStopInterlineSecondTime.setTrip(secondTrip);
        trainStopInterlineSecondTime.setStop(trainStopInterline);
        trainStopInterlineSecondTime.setStopSequence(0);
        trainStopInterlineSecondTime.setDepartureTime(20);
        trainStopArriveTime.setTrip(secondTrip);
        trainStopArriveTime.setStop(trainStopArrive);
        trainStopArriveTime.setStopSequence(1);
        trainStopArriveTime.setArrivalTime(24);
        trainStopArriveTime.setDropOffType(2);
        ferryStopDepartTime.setTrip(thirdTrip);
        ferryStopDepartTime.setStop(ferryStopDepart);
        ferryStopDepartTime.setStopSequence(-1);
        ferryStopDepartTime.setDepartureTime(32);
        ferryStopDepartTime.setPickupType(2);
        ferryStopArriveTime.setTrip(thirdTrip);
        ferryStopArriveTime.setStop(ferryStopArrive);
        ferryStopArriveTime.setStopSequence(0);
        ferryStopArriveTime.setArrivalTime(36);
        ferryStopArriveTime.setDropOffType(3);

        ArrayList<StopTime> firstStopTimes = new ArrayList<StopTime>();
        ArrayList<StopTime> secondStopTimes = new ArrayList<StopTime>();
        ArrayList<StopTime> thirdStopTimes = new ArrayList<StopTime>();
View Full Code Here

Examples of org.onebusaway.gtfs.model.StopTime

        ArrayList<Edge> hops = new ArrayList<Edge>(2);
        RoutingContext routingContext = new RoutingContext(routingRequest, graph, null, arrive);
        AgencyAndId agencyAndId = new AgencyAndId("Agency", "ID");
        Route route = new Route();
        ArrayList<StopTime> stopTimes = new ArrayList<StopTime>(3);
        StopTime stopDepartTime = new StopTime();
        StopTime stopDwellTime = new StopTime();
        StopTime stopArriveTime = new StopTime();
        Stop stopDepart = new Stop();
        Stop stopDwell = new Stop();
        Stop stopArrive = new Stop();
        Trip trip = new Trip();

        routingContext.serviceDays =
                new ArrayList<ServiceDay>(Collections.singletonList(serviceDay));
        route.setId(agencyAndId);
        stopDepart.setId(agencyAndId);
        stopDwell.setId(agencyAndId);
        stopArrive.setId(agencyAndId);
        stopDepartTime.setStop(stopDepart);
        stopDepartTime.setDepartureTime(0);
        stopDwellTime.setArrivalTime(20);
        stopDwellTime.setStop(stopDwell);
        stopDwellTime.setDepartureTime(40);
        stopArriveTime.setArrivalTime(60);
        stopArriveTime.setStop(stopArrive);
        stopTimes.add(stopDepartTime);
        stopTimes.add(stopDwellTime);
        stopTimes.add(stopArriveTime);
        trip.setId(agencyAndId);
        trip.setTripHeadsign("The right");
View Full Code Here

Examples of org.onebusaway.gtfs.model.StopTime

        RoutingContext routingContext = new RoutingContext(routingRequest, graph, null, arrive);
        AgencyAndId agencyAndId = new AgencyAndId("Agency", "ID");
        Route route = new Route();
        ArrayList<StopTime> stopTimes = new ArrayList<StopTime>(2);
        StopTime stopDepartTime = new StopTime();
        StopTime stopArriveTime = new StopTime();
        Stop stopDepart = new Stop();
        Stop stopArrive = new Stop();
        Trip trip = new Trip();

        routingContext.serviceDays =
                new ArrayList<ServiceDay>(Collections.singletonList(serviceDay));
        route.setId(agencyAndId);
        stopDepart.setId(new AgencyAndId("Station", "0"));
        stopArrive.setId(new AgencyAndId("Station", "1"));
        stopDepartTime.setStop(stopDepart);
        stopDepartTime.setDepartureTime(0);
        stopArriveTime.setArrivalTime(10);
        stopArriveTime.setStop(stopArrive);
        stopTimes.add(stopDepartTime);
        stopTimes.add(stopArriveTime);
        trip.setId(agencyAndId);

        TripTimes tripTimes = new TripTimes(trip, stopTimes, new Deduplicator());
View Full Code Here

Examples of org.onebusaway.gtfs.model.StopTime

        ArrayList<Edge> hops = new ArrayList<Edge>(2);
        RoutingContext routingContext = new RoutingContext(routingRequest, graph, null, arrive);
        AgencyAndId agencyAndId = new AgencyAndId("Agency", "ID");
        Route route = new Route();
        ArrayList<StopTime> stopTimes = new ArrayList<StopTime>(2);
        StopTime stopDepartTime = new StopTime();
        StopTime stopDwellTime = new StopTime();
        StopTime stopArriveTime = new StopTime();
        Stop stopDepart = new Stop();
        Stop stopDwell = new Stop();
        Stop stopArrive = new Stop();
        Trip trip = new Trip();

        routingContext.serviceDays =
                new ArrayList<ServiceDay>(Collections.singletonList(serviceDay));
        route.setId(agencyAndId);
        stopDepart.setId(new AgencyAndId("Station", "0"));
        stopDwell.setId(new AgencyAndId("Station", "1"));
        stopArrive.setId(new AgencyAndId("Station", "2"));
        stopDepartTime.setStop(stopDepart);
        stopDepartTime.setDepartureTime(0);
        stopDwellTime.setArrivalTime(20);
        stopDwellTime.setStop(stopDwell);
        stopDwellTime.setDepartureTime(40);
        stopArriveTime.setArrivalTime(60);
        stopArriveTime.setStop(stopArrive);
        stopTimes.add(stopDepartTime);
        stopTimes.add(stopDwellTime);
        stopTimes.add(stopArriveTime);
        trip.setId(agencyAndId);
View Full Code Here

Examples of org.onebusaway.gtfs.model.StopTime

       
        // one less geometry than stoptime as these are hops not stops (fencepost problem)
        LineString[] geoms = new LineString[stopTimes.size() - 1];
       
        /* Detect presence or absence of shape_dist_traveled on a per-trip basis */
        StopTime st0 = stopTimes.get(0);
        boolean hasShapeDist = st0.isShapeDistTraveledSet();
        if (hasShapeDist) {
            // this trip has shape_dist in stop_times
            for (int i = 0; i < stopTimes.size() - 1; ++i) {
                st0 = stopTimes.get(i);
                StopTime st1 = stopTimes.get(i + 1);
                geoms[i] = getHopGeometryViaShapeDistTraveled(graph, shapeId, st0, st1);
            }
            return geoms;
        }
        LineString shape = getLineStringForShapeId(shapeId);
        if (shape == null) {
            // this trip has a shape_id, but no such shape exists, and no shape_dist in stop_times
            // create straight line segments between stops for each hop
            for (int i = 0; i < stopTimes.size() - 1; ++i) {
                st0 = stopTimes.get(i);
                StopTime st1 = stopTimes.get(i + 1);
                LineString geometry = createSimpleGeometry(st0.getStop(), st1.getStop());
                geoms[i] = geometry;
            }
            return geoms;
        }
        // This trip does not have shape_dist in stop_times, but does have an associated shape.
        ArrayList<IndexedLineSegment> segments = new ArrayList<IndexedLineSegment>();
        for (int i = 0 ; i < shape.getNumPoints() - 1; ++i) {
            segments.add(new IndexedLineSegment(i, shape.getCoordinateN(i), shape.getCoordinateN(i + 1)));
        }
        // Find possible segment matches for each stop.
        List<List<IndexedLineSegment>> possibleSegmentsForStop = new ArrayList<List<IndexedLineSegment>>();
        int minSegmentIndex = 0;
        for (int i = 0; i < stopTimes.size() ; ++i) {
            Stop stop = stopTimes.get(i).getStop();
            Coordinate coord = new Coordinate(stop.getLon(), stop.getLat());
            List<IndexedLineSegment> stopSegments = new ArrayList<IndexedLineSegment>();
            double bestDistance = Double.MAX_VALUE;
            IndexedLineSegment bestSegment = null;
            int maxSegmentIndex = -1;
            int index = -1;
            int minSegmentIndexForThisStop = -1;
            for (IndexedLineSegment segment : segments) {
                index ++;
                if (segment.index < minSegmentIndex) {
                    continue;
                }
                double distance = segment.distance(coord);
                if (distance < maxStopToShapeSnapDistance) {
                    stopSegments.add(segment);
                    maxSegmentIndex = index;
                    if (minSegmentIndexForThisStop == -1)
                        minSegmentIndexForThisStop = index;
                } else if (distance < bestDistance) {
                    bestDistance = distance;
                    bestSegment = segment;
                    if (maxSegmentIndex != -1) {
                        maxSegmentIndex = index;
                    }
                }
            }
            if (stopSegments.size() == 0) {
                //no segments within 150m
                //fall back to nearest segment
                stopSegments.add(bestSegment);
                minSegmentIndex = bestSegment.index;
            } else {
                minSegmentIndex = minSegmentIndexForThisStop;
                Collections.sort(stopSegments, new IndexedLineSegmentComparator(coord));
            }

            for (int j = i - 1; j >= 0; j --) {
                for (Iterator<IndexedLineSegment> it = possibleSegmentsForStop.get(j).iterator(); it.hasNext(); ) {
                    IndexedLineSegment segment = it.next();
                    if (segment.index > maxSegmentIndex) {
                        it.remove();
                    }
                }
            }
            possibleSegmentsForStop.add(stopSegments);
        }

        List<LinearLocation> locations = getStopLocations(possibleSegmentsForStop, stopTimes, 0, -1);

        if (locations == null) {
            // this only happens on shape which have points very far from
            // their stop sequence. So we'll fall back to trivial stop-to-stop
            // linking, even though theoretically we could do better.

            for (int i = 0; i < stopTimes.size() - 1; ++i) {
                st0 = stopTimes.get(i);
                StopTime st1 = stopTimes.get(i + 1);
                LineString geometry = createSimpleGeometry(st0.getStop(), st1.getStop());
                geoms[i] = geometry;
                //this warning is not strictly correct, but will do
                LOG.warn(graph.addBuilderAnnotation(new BogusShapeGeometryCaught(shapeId, st0, st1)));
            }
            return geoms;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.