Package org.onebusaway.collections

Examples of org.onebusaway.collections.Range


    }
    return false;
  }

  private double computeRangeForStanox(int idA, int idB) {
    Range x = new Range();
    Range y = new Range();
    updateRangeForStanox(idA, x, y);
    updateRangeForStanox(idB, x, y);
    if (x.isEmpty()) {
      return 0;
    }
    double dx = x.getRange();
    double dy = y.getRange();
    return Math.sqrt(dx * dx + dy * dy);
  }
View Full Code Here


        regionToStyle.put(area, style);
      }
     
      Pair<Range> ranges = rangesByArea.get(area);
      if (ranges == null) {
        ranges = Tuples.pair(new Range(), new Range());
        rangesByArea.put(area, ranges);
      }
      Range xRange = ranges.getFirst();
      Range yRange = ranges.getSecond();
       
      for (String tiploc : model.getTiplocsForStanox(stanox)) {
        StationElement station = model.getStationForTiploc(tiploc);
        if (station != null) {
          writer.println(area + "," + style + "," + from + "," + to + ","
              + region + "," + stanox + "," + tiploc + "," + station.getLat()
              + "," + station.getLon() + "," + station.getName());
          xRange.addValue(station.getEasting());
          yRange.addValue(station.getNorthing());
        }
      }
    }
   
    Max<String> maxRange = new Max<String>();
View Full Code Here

    remainingNodes.addAll(_nodesById.values());
    while (!remainingNodes.isEmpty()) {
      Node first = remainingNodes.iterator().next();
      Set<Node> cluster = exploreCluster(first, remainingNodes);

      Range xRange = new Range();
      Range yRange = new Range();
      for (Node node : cluster) {
        xRange.addValue(node.x);
        yRange.addValue(node.y);
      }
      double dx = xRange.getRange();
      double dy = yRange.getRange();
      double d = Math.sqrt(dx * dx + dy * dy);
      if (d < minClusterSize) {
        _log.info("pruning cluster: nodes=" + cluster.size() + " distance=" + d);
        for (Node node : cluster) {
          _nodesById.remove(node.id);
View Full Code Here

  private ScheduleDeviationHistory constructHistory(AgencyAndId tripId,
      BlockLocationArchiveRecordMap recordsByInstance) {

    List<SortedMap<Integer, Double>> traces = new ArrayList<SortedMap<Integer, Double>>();
    Range tRange = new Range();

    sortAndArrangeTraces(recordsByInstance, traces, tRange);

    int step = computeSamplingStep(traces);

    int from = (int) (Math.ceil(tRange.getMin() / step) * step);
    int to = (int) (Math.floor(tRange.getMax() / step) * step);

    SortedMap<Integer, Double> mus = new TreeMap<Integer, Double>();
    SortedMap<Integer, Double> sigmas = new TreeMap<Integer, Double>();

    computeMeanAndStandardDeviationForTraces(traces, from, to, step, mus,
View Full Code Here

  public Range getTimeRange() {
    if (_elements.isEmpty())
      throw new NoSuchElementException();
    VehicleLocationCacheElement first = _elements.get(0);
    VehicleLocationCacheElement last = _elements.get(_elements.size() - 1);
    return new Range(first.getRecord().getTimeOfRecord(),
        last.getRecord().getTimeOfRecord());
  }
View Full Code Here

    StopEntry stop = _graph.getStopEntryForId(stopId, true);

    List<BlockStopTimeIndex> indices = _blockIndexService.getStopTimeIndicesForStop(stop);

    Range interval = new Range();

    for (BlockStopTimeIndex index : indices) {
      extendIntervalWithIndex(serviceDate, interval, index);
    }
View Full Code Here

      List<VehicleLocationCacheElements> inRange = new ArrayList<VehicleLocationCacheElements>();
      long offset = _predictionCacheMaxOffset * 1000;
      for (VehicleLocationCacheElements elements : entries) {
        if (elements.isEmpty())
          continue;
        Range range = elements.getTimeRange();
        long tFrom = (long) (range.getMin() - offset);
        long tTo = (long) (range.getMax() + offset);
        if (tFrom <= time.getCurrentTime() && time.getCurrentTime() <= tTo)
          inRange.add(elements);
      }
      if (!inRange.isEmpty())
        return inRange;
View Full Code Here

    values = noNans(values);

    if (values.length == 0)
      return new ScheduleDeviationHistogram(new int[0], new int[0]);

    Range r = new Range();
    for (double v : values)
      r.addValue(v);

    if (r.getRange() == 0)
      return new ScheduleDeviationHistogram(new int[] {(int) values[0]},
          new int[] {values.length});
   
    int halfStep = stepSizeInSeconds / 2;

    int from = (int) (Math.floor((r.getMin()-halfStep) / stepSizeInSeconds) * stepSizeInSeconds) + halfStep;
    int to = (int) (Math.ceil((r.getMax()+halfStep) / stepSizeInSeconds) * stepSizeInSeconds) - halfStep;
    int columns = (to - from) / stepSizeInSeconds;

    int[] scheduleDeviations = new int[columns];
    int[] counts = new int[columns];

View Full Code Here

  }

  private List<StopTimeInstance> getStopTimeInstancesForStopAndServiceDate(
      StopEntry stop, ServiceDate serviceDate) {

    Range interval = _stopTimeService.getDepartureForStopAndServiceDate(
        stop.getId(), serviceDate);

    if (interval.isEmpty())
      return Collections.emptyList();

    long tFrom = (long) interval.getMin();
    long tTo = (long) interval.getMax();

    return _stopTimeService.getStopTimeInstancesInTimeRange(stop, new Date(
        tFrom), new Date(tTo), EFrequencyStopTimeBehavior.INCLUDE_INTERPOLATED);
  }
View Full Code Here

TOP

Related Classes of org.onebusaway.collections.Range

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.