コード例 #1
0
ファイル: Trace.cpp プロジェクト: damianob/xcsoar
void
Trace::push_back(const AircraftState& state)
{
  assert(cached_size == delta_list.size());
  assert(cached_size == chronological_list.Count());

  if (empty()) {
    // first point determines origin for flat projection
    task_projection.reset(state.location);
    task_projection.update_fast();
  } else if (state.time < fixed(back().GetTime())) {
    // gone back in time

    if (unsigned(state.time) + 180 < back().GetTime()) {
      /* not fixable, clear the trace and restart from scratch */
      clear();
      return;
    }

    /* not much, try to fix it */
    EraseLaterThan(unsigned(state.time) - 10);
  } else if ((unsigned)state.time - back().GetTime() < 2)
    // only add one item per two seconds
    return;

  TracePoint tp(state);
  tp.project(task_projection);

  EnforceTimeWindow(tp.GetTime());

  if (size() >= max_size)
    Thin();

  assert(size() < max_size);

  TraceDelta &td = Insert(tp);
  td.InsertBefore(chronological_list);

  ++cached_size;

  if (!chronological_list.IsFirst(td))
    UpdateDelta(td.GetPrevious());

  ++append_serial;
}
コード例 #2
0
ファイル: Trace.hpp プロジェクト: StefanL74/XCSoar
 void EraseLaterThan(fixed time) {
   EraseLaterThan((unsigned)time);
 }