Package models.transit

Examples of models.transit.TripPattern


   
    for(Map<String, ArrayList<TripPattern>> routes : tripPatternMap.values())
    {
      for(ArrayList<TripPattern> groupedPatterns : routes.values())
      {
        TripPattern longestPattern = null;
       
        for(TripPattern p : groupedPatterns)
        {
          if(longestPattern == null)
            longestPattern = p;
          else
          {
            if(longestPattern.shape.shape.getLength() < p.shape.shape.getLength())
              longestPattern = p;
          }
        }
       
        longestPattern.longest = true;
        longestPattern.save();
      }
    }
  }
View Full Code Here


    public static void getTripPattern(Long id, Long routeId) {

        try {
            if(id != null)
            {
                TripPattern tripPattern = TripPattern.findById(id);
                if(tripPattern != null)
                    renderJSON(Api.toJson(tripPattern, false));
                else
                    notFound();
            }
View Full Code Here

            badRequest();
        }
    }

    public static void createTripPattern() {
        TripPattern tripPattern;

        try {
            tripPattern = mapper.readValue(params.get("body"), TripPattern.class);
           
            if(tripPattern.encodedShape != null) {
              TripShape ts = TripShape.createFromEncoded(tripPattern.encodedShape);
              tripPattern.shape = ts; 
            }
           
            tripPattern.save();

            renderJSON(Api.toJson(tripPattern, false));
        } catch (Exception e) {
            e.printStackTrace();
            badRequest();
View Full Code Here

    }


    public static void updateTripPattern() {

        TripPattern tripPattern;

        try {
            tripPattern = mapper.readValue(params.get("body"), TripPattern.class);

            if(tripPattern.id == null)
                badRequest();
           
            TripPattern originalTripPattern = TripPattern.findById(tripPattern.id);
           
            if(originalTripPattern == null)
              badRequest();
           
            if(tripPattern.encodedShape != null) {
              if(originalTripPattern.shape != null) {
                originalTripPattern.shape.updateShapeFromEncoded(tripPattern.encodedShape);
                tripPattern.shape = originalTripPattern.shape;
              }
              else {
                  TripShape ts = TripShape.createFromEncoded(tripPattern.encodedShape);
                 
                  tripPattern.shape = ts;
              }
             
            }
            else {
                tripPattern.shape = null;

                // need to remove old shapes...
            }

            TripPattern updatedTripPattern = TripPattern.em().merge(tripPattern);
            updatedTripPattern.save();
           
            Set<Long> patternStopIds = new HashSet<Long>();
            for(TripPatternStop patternStop : updatedTripPattern.patternStops) {
                patternStopIds.add(patternStop.id);
            }
View Full Code Here

    public static void deleteTripPattern(Long id) {
        if(id == null)
            badRequest();

        TripPattern tripPattern = TripPattern.findById(id);

        if(tripPattern == null)
            badRequest();

        tripPattern.delete();
        
        ok();
    }
View Full Code Here

        ok();
    }
   
    public static void calcTripPatternTimes(Long id, Double velocity, int defaultDwell) {
     
      TripPattern tripPattern = TripPattern.findById(id);
     
      List<TripPatternStop> patternStops = TripPatternStop.find("pattern = ? ORDER BY stopSequence", tripPattern).fetch();
     
      Double distanceAlongLine = 0.0;
     
View Full Code Here

                    Agency agency = Agency.findById(agencyId);
                    renderJSON(Api.toJson(Trip.find("pattern.route.agency = ?", agency).fetch(), false));
                }
               
                else if (patternId != null && calendarId != null) {
                    TripPattern pattern = TripPattern.findById(patternId);
                    ServiceCalendar calendar = ServiceCalendar.findById(calendarId);
                    renderJSON(Api.toJson(Trip.find("byPatternAndServiceCalendar", pattern, calendar).fetch(), false));
                }
               
                else if(patternId != null) {
                    TripPattern pattern = TripPattern.findById(patternId);
                    renderJSON(Api.toJson(Trip.find("pattern = ?", pattern).fetch(), false));
                }
                else {
                    renderJSON(Api.toJson(Trip.all().fetch(), false));
                }
View Full Code Here

      response.setHeader("Content-Disposition", "attachment; filename=\"schedule_" + patternId + ".csv\"");
      response.setHeader("Content-type", "text/csv");
     
      SimpleDateFormat dfTime = new SimpleDateFormat("hh:mm a");
     
      TripPattern pattern = TripPattern.findById(patternId);
      ServiceCalendar calendar = ServiceCalendar.findById(calendarId);
     
      // ensure that the trip pattern sequence isn't broken
      pattern.resequenceTripStops();
     
      List<Trip> trips  = Trip.find("pattern = ? and serviceCalendar = ? ORDER by id", pattern, calendar).fetch();
      List<TripPatternStop> stopList  = TripPatternStop.find("pattern = ? ORDER BY stopSequence", pattern).fetch();
       
      StringWriter csvString = new StringWriter();
View Full Code Here

    {      
     
    SimpleDateFormat dfTime = new SimpleDateFormat("hh:mm a");
    SimpleDateFormat dfsTime = new SimpleDateFormat("hh:mm:ss a");
    
    TripPattern pattern = TripPattern.findById(patternId);
    ServiceCalendar calendar = ServiceCalendar.findById(calendarId);
   
    List<Trip> trips = Trip.find("pattern = ? and serviceCalendar = ?", pattern, calendar).fetch();

    for(Trip trip : trips) {
View Full Code Here

TOP

Related Classes of models.transit.TripPattern

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.