Examples of ConstraintsBean


Examples of org.onebusaway.transit_data.model.tripplanning.ConstraintsBean

    List<TimedPlaceBean> beans = new ArrayList<TimedPlaceBean>();

    double walkingVelocity = travelTimes.getWalkingVelocity() / 1000;

    ConstraintsBean walkConstraints = new ConstraintsBean(constraints);
    walkConstraints.setModes(CollectionsLibrary.set(Modes.WALK));

    for (LocalSearchResult result : localResults) {

      double placeLat = result.getLat();
      double placeLon = result.getLon();

      List<TripToStop> closestStops = new ArrayList<TripToStop>();

      for (int index = 0; index < travelTimes.getSize(); index++) {

        String stopIdAsString = travelTimes.getStopId(index);
        AgencyAndId stopId = AgencyAndIdLibrary.convertFromString(stopIdAsString);

        long currentTripDuration = travelTimes.getTravelTime(index);
        double stopLat = travelTimes.getStopLat(index);
        double stopLon = travelTimes.getStopLon(index);
        double d = SphericalGeometryLibrary.distance(stopLat, stopLon,
            placeLat, placeLon);
        double t = currentTripDuration + d / walkingVelocity;
        if (d <= constraints.getMaxWalkingDistance() && t < maxTripLength) {
          closestStops.add(new TripToStop(stopId, currentTripDuration, t, index));
        }
      }

      if (closestStops.isEmpty())
        continue;

      Collections.sort(closestStops);

      double minTime = 0;
      TripToStop minStop = null;

      TransitLocationBean place = new TransitLocationBean();
      place.setLat(result.getLat());
      place.setLon(result.getLon());

      for (TripToStop o : closestStops) {

        long currentTripDuration = o.getTransitTimeToStop();
        double minTimeToPlace = o.getMinTansitTimeToPlace();

        // Short circuit if there is no way any of the remaining trips is going
        // to be better than our current winner
        if (minStop != null && minTimeToPlace > minTime)
          break;

        int remainingTime = (int) ((maxTripLength - currentTripDuration) / 1000);
        walkConstraints.setMaxTripDuration(remainingTime);

        int index = o.getIndex();
        TransitLocationBean stopLocation = new TransitLocationBean();
        stopLocation.setLat(travelTimes.getStopLat(index));
        stopLocation.setLon(travelTimes.getStopLon(index));
View Full Code Here

Examples of org.onebusaway.transit_data.model.tripplanning.ConstraintsBean

      }

      long tTotal = 0;
      int index = 0;

      ConstraintsBean constraints = new ConstraintsBean();
      constraints.setMaxComputationTime(20000);
      constraints.setResultCount(3);
      constraints.setUseRealTime(true);
     
      for (Pair<CoordinatePoint> pair : points) {
        TransitLocationBean from = new TransitLocationBean(pair.getFirst());
        TransitLocationBean to = new TransitLocationBean(pair.getSecond());
        long tIn = System.currentTimeMillis();
View Full Code Here

Examples of org.onebusaway.transit_data.model.tripplanning.ConstraintsBean

      throws ServiceException {

    MinTravelTimeToStopsBean minTravelTimeToStops = _transitDataService.getMinTravelTimeToStopsFrom(
        location, time, constraints);

    ConstraintsBean c = constraints.getConstraints();

    double maxWalkDistance = c.getMaxWalkingDistance();
    double walkingVelocity = minTravelTimeToStops.getWalkingVelocity() / 1000;

    CoordinateBounds b = SphericalGeometryLibrary.bounds(location, 800);
    double latStep = b.getMaxLat() - b.getMinLat();
    double lonStep = b.getMaxLon() - b.getMinLon();
    GridFactory gridFactory = new GridFactory(latStep, lonStep);
    TimedGridFactory timedGridFactory = new TimedGridFactory(latStep / 4,
        lonStep / 4, walkingVelocity);

    long maxTripLength = c.getMaxTripDuration() * 1000;

    for (int i = 0; i < minTravelTimeToStops.getSize(); i++) {

      double stopLat = minTravelTimeToStops.getStopLat(i);
      double stopLon = minTravelTimeToStops.getStopLon(i);
View Full Code Here

Examples of org.onebusaway.transit_data.model.tripplanning.ConstraintsBean

  public static final String PARAM_MAX_WALKING_DISTANCE = "walk";

  public static void addConstraintsToParams(
      TransitShedConstraintsBean constraints, Map<String, String> params) {

    ConstraintsBean c = constraints.getConstraints();

    params.put(PARAM_MAX_TRANSFERS, Integer.toString(c.getMaxTransfers()));
    params.put(PARAM_MAX_TRIP_LENGTH,
        Integer.toString(c.getMaxTripDuration() / 60));
    params.put(PARAM_MAX_WALKING_DISTANCE,
        Double.toString(c.getMaxWalkingDistance()));
  }
View Full Code Here

Examples of org.onebusaway.transit_data.model.tripplanning.ConstraintsBean

  }

  public static void addParamsToConstraints(Context context,
      TransitShedConstraintsBean constraints) {

    ConstraintsBean c = constraints.getConstraints();

    String maxWalkingDistance = context.getParam(PARAM_MAX_WALKING_DISTANCE);
    if (maxWalkingDistance != null)
      c.setMaxWalkingDistance(Double.parseDouble(maxWalkingDistance));

    String maxTransfers = context.getParam(PARAM_MAX_TRANSFERS);
    if (maxTransfers != null)
      c.setMaxTransfers(Integer.parseInt(maxTransfers));

    String maxTripLength = context.getParam(PARAM_MAX_TRIP_LENGTH);
    if (maxTripLength != null)
      c.setMaxTripDuration(Integer.parseInt(maxTripLength) * 60);
  }
View Full Code Here

Examples of org.onebusaway.transit_data.model.tripplanning.ConstraintsBean

    _time = System.currentTimeMillis();

    _constraints.setMaxInitialWaitTime(DEFAULT_SEARCH_WINDOW * 60);

    ConstraintsBean c = _constraints.getConstraints();
    c.setMaxTransfers(DEFAULT_TRANSFERS);
    c.setMaxTripDuration(DEFAULT_TRIP_DURATION * 60);
    c.setMaxWalkingDistance(DEFAULT_WALKING_DISTANCE);
  }
View Full Code Here

Examples of org.onebusaway.transit_data.model.tripplanning.ConstraintsBean

    Date time = new Date(_time);
    _dateTextBox.setText(_dateFormat.format(time));
    _timeTextBox.setText(_timeFormat.format(time));

    ConstraintsBean c = _constraints.getConstraints();
    setClosestIndex(_maxTransfersListBox, c.getMaxTransfers());
    setClosestIndex(_maxTripLengthBox, c.getMaxTripDuration() / 60);
    setClosestIndex(_maxWalkDistance, (int) c.getMaxWalkingDistance());
  }
View Full Code Here

Examples of org.onebusaway.transit_data.model.tripplanning.ConstraintsBean

    System.out.println("date=" + date);

    _time = date.getTime();

    ConstraintsBean c = _constraints.getConstraints();

    int maxTransfersIndex = _maxTransfersListBox.getSelectedIndex();
    if (maxTransfersIndex != -1)
      c.setMaxTransfers(Integer.parseInt(_maxTransfersListBox.getValue(maxTransfersIndex)));

    int maxTripDurationIndex = _maxTripLengthBox.getSelectedIndex();
    if (maxTripDurationIndex != -1)
      c.setMaxTripDuration(Integer.parseInt(_maxTripLengthBox.getValue(maxTripDurationIndex)) * 60);

    int maxWalkDistanceindex = _maxWalkDistance.getSelectedIndex();
    if (maxWalkDistanceindex != -1)
      c.setMaxWalkingDistance(Integer.parseInt(_maxWalkDistance.getValue(maxWalkDistanceindex)));
  }
View Full Code Here

Examples of org.onebusaway.transit_data.model.tripplanning.ConstraintsBean

            new SearchLocationUpdatedState()));

        LatLng location = model.getLocation();
        long time = model.getTime();
        TransitShedConstraintsBean constraints = model.getConstraints();
        ConstraintsBean c = constraints.getConstraints();
        WebappServiceAsync service = WebappServiceAsync.SERVICE;

        int timeSegmentSize = (c.getMaxTripDuration() 600);

        CoordinatePoint p = new CoordinatePoint(location.getLatitude(),
            location.getLongitude());
        service.getMinTravelTimeToStopsFrom(p, time, constraints,
            timeSegmentSize, _minTransitTimeResultHandler);
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.