@Override public void process(LsfIndex source) { LsfIterator<EstimatedState> it = index.getIterator(EstimatedState.class, 200); boolean ascending = false; EstimatedState lastMin = it.next(); while (lastMin.getDepth() > 0.5 && it.hasNext() || lastMin.getVx() > 0.2) lastMin = it.next(); EstimatedState lastMax = lastMin; if (lastMin == null || !it.hasNext()) return; ascending = it.next().getAlt() >= lastMin.getAlt(); while (it.hasNext()) { EstimatedState state = it.next(); if (state.getDepth() > 0.5 || state.getVx() > 0.2) continue; if (state.getAlt() == -1) continue; if (ascending) { if (state.getAlt() >= lastMax.getAlt()) lastMax = state; else { addWave(lastMin, lastMax); ascending = false; lastMin = lastMax; } } else { if (state.getAlt() <= lastMin.getAlt()) lastMin = state; else { addWave(lastMax, lastMin); ascending = true; lastMax = lastMin; } } } }