Repository navigation
SlopeBadPointFilter
Up | Previous | Next | Русский
Below is the full source of the class in documentation form. The comments inside the block explain the purpose of the parts of the class, but they are not stored in the working file SlopeBadPointFilter.java: the production code stays clean and the explanations live in the wiki.
package com.velitask.plugin.official.processing.filters;
import com.velitask.sdk.data.SlopeSensorAtom;
import com.velitask.units.angle.Angle;
/* Bad slope points: the limits are checked only after a short segment. */
public final class SlopeBadPointFilter extends BadPointFilter<SlopeSensorAtom> {
/* Stable step name in plans and settings. */
public static final String NAME = "slopeBadPoint";
/* A short segment: not longer than one metre (in millimetres). */
private static final long SHORT_DISTANCE_MM = 1000;
public SlopeBadPointFilter() {
/* Step version 2; the sensor atom is SlopeSensorAtom. */
super(NAME, 2, SlopeSensorAtom.class);
}
@Override
/* Slope in percent: slopePercent is stored in hundredths of a percent. */
protected double value(SlopeSensorAtom atom) {
return Angle.slopePercentToPercent(atom.slopePercent);
}
@Override
/* The limits apply only if the previous atom is not longer than 1 m. */
protected boolean outOfRange(SlopeSensorAtom atom, SlopeSensorAtom previous) {
return previous != null
&& previous.distanceDelta <= SHORT_DISTANCE_MM
&& super.outOfRange(atom, previous);
}
}SlopeBadPointFilter is the "Bad slope points" filter for the computed slope sensor (SlopeSensorAtom). It rejects slope values that cannot be trusted: right after a pause, outside the limits on a very short segment, with a too fast jump or a single spike. The general algorithm and the parameters are in BadPointFilter.
-
Name and version:
slopeBadPoint, version 2. The version was raised (in the changelog, the "Fixed" section about GoPro import and tracks with slope): for already imported sources the slope is recomputed the next time the project is opened. -
valueisAngle.slopePercentToPercent(atom.slopePercent): the field is stored in hundredths of a percent, the result is percent (1550 → 15.5). -
outOfRangeis overridden: the limitsminandmaxare checked only if there is a previous atom (previous != null) and itsdistanceDeltais not greater than 1000 mm (SHORT_DISTANCE_MM, one metre); after that the base checksuper.outOfRangeis called. -
The previous atom is taken from the input array (
atoms[i - 1]), not from the accepted ones.
Where it is used. The step stands first in the scenario of the computed SLOPE sensor in FitImportPlan and GoproImportPlan: useRange = true, min = -45, max = 45. In both plans the slope scenario is marked disabled().
- The first atom never goes through the limits check (there is no previous atom).
- A segment longer than a metre is not checked against the limits. On it, the jump and the spike checks protect against an unrealistic slope, if they are on.
- The limit applies to the slope percent, not to the angle in degrees: ±45 % is about ±24°.