Пример #1
0
 /**
  * Get the point list for the tables
  *
  * @param inTrackInfo TrackInfo object
  */
 private static ArrayList<DataPoint> getPointList(TrackInfo inTrackInfo) {
   // Get the list of waypoints (if any)
   ArrayList<DataPoint> pointList = new ArrayList<DataPoint>();
   inTrackInfo.getTrack().getWaypoints(pointList);
   // Get the current point (if any)
   DataPoint currPoint = inTrackInfo.getCurrentPoint();
   if (currPoint != null && !currPoint.isWaypoint()) {
     // Add current point to start of list
     pointList.add(0, currPoint);
   }
   return pointList;
 }
Пример #2
0
  /** Get the data and populate the instance arrays */
  public void init() {
    initArrays();
    _metric = Config.getConfigBoolean(Config.KEY_METRIC_UNITS);
    _hasData = false;
    _minValue = _maxValue = 0.0;
    if (_track != null) {
      DataPoint prevPrevPoint = null, prevPoint = null, point = null;
      for (int i = 0; i < _track.getNumPoints(); i++) {
        point = _track.getPoint(i);
        if (prevPrevPoint != null
            && prevPrevPoint.hasTimestamp()
            && prevPoint != null
            && prevPoint.hasTimestamp()
            && point != null
            && point.hasTimestamp()) {
          // All three points have timestamps
          double seconds = point.getTimestamp().getSecondsSince(prevPrevPoint.getTimestamp());
          if (seconds > 0) {
            double distInRads =
                DataPoint.calculateRadiansBetween(prevPrevPoint, prevPoint)
                    + DataPoint.calculateRadiansBetween(prevPoint, point);
            double dist =
                Distance.convertRadiansToDistance(
                    distInRads, _metric ? Units.KILOMETRES : Units.MILES);
            // Store the value and maintain max and min values
            double value = dist / seconds * 60.0 * 60.0;
            _pointValues[i - 1] = value;
            if (value < _minValue || _minValue == 0.0) {
              _minValue = value;
            }
            if (value > _maxValue) {
              _maxValue = value;
            }

            _hasData = true;
            _pointHasData[i - 1] = true;
          }
        }
        // Exchange points
        prevPrevPoint = prevPoint;
        prevPoint = point;
      }
    }
  }