Package models.transit

Examples of models.transit.Stop


             
              for(TripPatternStop stopTime : patternStopTimes)
              {
                if(!stopList.containsKey(stopTime.stop.id))
                {
                  Stop stop = stopTime.stop;
                 
                  AgencyAndId stopId = new AgencyAndId();
                 
                  stopId.setAgencyId(gtfsAgencyId);
             
                  if(stop.gtfsStopId != null && !stop.gtfsStopId.isEmpty())
                    stopId.setId(stop.gtfsStopId);
                  else
                    stopId.setId("STOP_" + stop.id.toString());
                 
                  org.onebusaway.gtfs.model.Stop s = new org.onebusaway.gtfs.model.Stop();
                 
                  s.setId(stopId);
                 
                  s.setCode(stop.stopCode);
                 
                  if(stop.stopName == null || stop.stopName.isEmpty())
                    s.setName(stop.id.toString());
                  else
                    s.setName(stop.stopName.replace("\n", "").replace("\r", ""));
                 
                  if(stop.stopDesc != null && !stop.stopName.isEmpty())
                    s.setDesc(stop.stopDesc.replace("\n", "").replace("\r", ""));
                 
                  s.setUrl(stop.stopUrl);
                 
                  s.setLon(stop.locationPoint().getX());
                  s.setLat(stop.locationPoint().getY());
                 
                 
                  if(stop.wheelchairBoarding != null && stop.wheelchairBoarding.equals(AttributeAvailabilityType.AVAILABLE))
                    s.setWheelchairBoarding(1);
                  else if(stop.wheelchairBoarding != null && stop.wheelchairBoarding.equals(AttributeAvailabilityType.UNAVAILABLE))
                    s.setWheelchairBoarding(2);
                  else
                    s.setWheelchairBoarding(0);
                 
                  store.saveEntity(s);
                                 
                  stopList.put(stop.id, s);
                }
               
                org.onebusaway.gtfs.model.StopTime st = new org.onebusaway.gtfs.model.StopTime();
               
                if(stopTime.defaultTravelTime != null) {
                 
                  // need to flag negative travel times in the patterns!
                  if(stopTime.defaultTravelTime < 0)
                    cumulativeTime -= stopTime.defaultTravelTime;
                  else
                    cumulativeTime += stopTime.defaultTravelTime; 
                }
                 
               
                st.setArrivalTime(cumulativeTime);
               
                if(stopTime.defaultDwellTime != null) {
                 
                  // need to flag negative dwell times in the patterns!
                  if(stopTime.defaultDwellTime < 0)
                    cumulativeTime -= stopTime.defaultDwellTime;
                  else
                    cumulativeTime += stopTime.defaultDwellTime;
                }
                 
               
                st.setDepartureTime(cumulativeTime);
               
                st.setTrip(t);
                st.setStop(stopList.get(stopTime.stop.id));
                st.setStopSequence(stopTime.stopSequence);
         
                     
                store.saveEntity(st);
              }

            }
            else
            {
           
              List<StopTime> stopTimes = StopTime.find("trip = ? order by stopSequence", trip).fetch();
             
              for(StopTime stopTime : stopTimes)
              {
                if(!stopList.containsKey(stopTime.stop.id))
                {
                  Stop stop = stopTime.stop;
                 
                  AgencyAndId stopId = new AgencyAndId();
                 
                  stopId.setAgencyId(gtfsAgencyId);
                 
                  if(stop.gtfsStopId != null && !stop.gtfsStopId.isEmpty())
                    stopId.setId(stop.gtfsStopId);
                  else
                    stopId.setId(stop.id.toString());
                 
                  org.onebusaway.gtfs.model.Stop s = new org.onebusaway.gtfs.model.Stop();
                 
                  s.setId(stopId);
                 
                  s.setCode(stop.stopCode);
                  if(stop.stopName == null || stop.stopName.isEmpty())
                    s.setName(stop.id.toString());
                  else
                    s.setName(stop.stopName.replace("\n", "").replace("\r", ""));
                 
                  if(stop.stopDesc != null && !stop.stopName.isEmpty())
                    s.setDesc(stop.stopDesc.replace("\n", "").replace("\r", ""));
                 
                  s.setUrl(stop.stopUrl);
                 
                  s.setLon(stop.locationPoint().getX());
                  s.setLat(stop.locationPoint().getY());
                 
                  if(stop.wheelchairBoarding != null && stop.wheelchairBoarding.equals(AttributeAvailabilityType.AVAILABLE))
                    s.setWheelchairBoarding(1);
                  else if(stop.wheelchairBoarding != null && stop.wheelchairBoarding.equals(AttributeAvailabilityType.UNAVAILABLE))
                    s.setWheelchairBoarding(2);
View Full Code Here


      if(agencyId != null)
        agency = Agency.findById(agencyId);
     
        try {
            if(id != null) {
                Stop stop = Stop.findById(id);
                if(stop != null)
                    renderJSON(Api.toJson(stop, false));
                else
                    notFound();
            }
View Full Code Here

            badRequest();
        }
    }

    public static void createStop() {
        Stop stop;

        try {
            stop = mapper.readValue(params.get("body"), Stop.class);

            if(Agency.findById(stop.agency.id) == null)
                badRequest();

            stop.save();

            // check if gtfsRouteId is specified, if not create from DB id
            if(stop.gtfsStopId == null) {
                stop.gtfsStopId = "STOP_" + stop.id.toString();
                stop.save();
            }

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

        }
    }


    public static void updateStop() {
        Stop stop;

        try {
            stop = mapper.readValue(params.get("body"), Stop.class);

            if(stop.id == null || Stop.findById(stop.id) == null)
                badRequest();

            // check if gtfsRouteId is specified, if not create from DB id
            if(stop.gtfsStopId == null)
                stop.gtfsStopId = "STOP_" + stop.id.toString();

            Stop updatedStop = Stop.em().merge(stop);
            updatedStop.save();

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

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

        Stop stop = Stop.findById(id);

        if(stop == null)
            badRequest();

        stop.delete();

        ok();
    }
View Full Code Here

    public static void mergeStops(Long stop1Id, @As(",") List<String> mergedStopIds) {
       
        if(stop1Id == null)
            badRequest();

        Stop stop1 = Stop.findById(stop1Id);

        for(String stopIdStr : mergedStopIds) {

            Stop stop2 = Stop.findById(Long.parseLong(stopIdStr));

            if(stop1 == null && stop2 == null)
                badRequest();

            stop1.merge(stop2);
View Full Code Here

              
               for(String column : csvLine
               {
                 if(columnIndex > 5)
                 {
                   Stop stop = Stop.findById(Long.parseLong(column));
                  
                   TripPatternStop patternStop = patternStops.get(0);
                   patternStops = patternStops.subList(1, patternStops.size());
                  
                   if(!patternStop.stop.id.equals(stop.id))
View Full Code Here

TOP

Related Classes of models.transit.Stop

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.