Repository navigation
GpxImportPlan
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 GpxImportPlan.java: the production code stays clean and the explanations live in the wiki.
package com.velitask.plugin.official.processing.plans;
import java.util.Map;
import com.velitask.plugin.official.processing.compress.SameValueCompress;
import com.velitask.plugin.official.processing.filters.BadPointFilter;
import com.velitask.plugin.official.processing.filters.CyclingPowerBadPointFilter;
import com.velitask.plugin.official.processing.filters.HeartBadPointFilter;
import com.velitask.plugin.official.processing.filters.SlopeBadPointFilter;
import com.velitask.plugin.official.processing.gaps.ExplicitGaps;
import com.velitask.plugin.official.processing.gaps.StepGaps;
import com.velitask.sdk.SensorType;
import com.velitask.sdk.scenario.ImportPlan;
/* Import plan for GPX files. */
public final class GpxImportPlan extends ImportPlan {
/* Import format identifier. */
public static final String FORMAT_ID = "gpx";
public GpxImportPlan() {
super(FORMAT_ID);
}
@Override
protected void define() {
/* Pauses by gap for the track and elevation: a gap of 10 s or more, step factor 5, */
/* if the track moved at 2 m/s or faster during the gap, it is not a pause. */
Map<String, Object> movingTrack = Map.of(
StepGaps.MIN_STEP_SEC, 10,
StepGaps.STEP_FACTOR, 5,
StepGaps.MAX_SPEED, 2
);
/* Coordinates: pauses by recording gap, then compression of identical values. */
sensor(SensorType.GEO)
.step(StepGaps.NAME, movingTrack)
.step(SameValueCompress.NAME);
/* Elevation: the same pauses, geo track taken from the coordinates. */
sensor(SensorType.ELEVATION)
.step(StepGaps.NAME, movingTrack, track(SensorType.GEO))
.step(SameValueCompress.NAME);
/* Temperature is recorded less often: minimal gap 60 s. */
sensor(SensorType.TEMPERATURE)
.step(StepGaps.NAME, Map.of(StepGaps.MIN_STEP_SEC, 60, StepGaps.STEP_FACTOR, 5), track(SensorType.GEO))
.step(SameValueCompress.NAME);
/* Heart rate: rejection outside 1..220, pauses from the file by the geo track. */
sensor(SensorType.HEART)
.step(HeartBadPointFilter.NAME,
Map.of(BadPointFilter.USE_RANGE, true, BadPointFilter.MIN, 1, BadPointFilter.MAX, 220))
.step(ExplicitGaps.NAME, track(SensorType.GEO))
.step(SameValueCompress.NAME);
sensor(SensorType.CADENC)
.step(ExplicitGaps.NAME, track(SensorType.GEO))
.step(SameValueCompress.NAME);
/* Power: spike rejection, pauses from the file by the geo track. */
sensor(SensorType.CYCLING_POWER)
.step(CyclingPowerBadPointFilter.NAME,
Map.of(BadPointFilter.WINDOW_SEC, 5, BadPointFilter.DEVIATION, 1000, BadPointFilter.FLOOR, 1500))
.step(ExplicitGaps.NAME, track(SensorType.GEO))
.step(SameValueCompress.NAME);
/* Computed distance and G-force: compression only. */
computed(SensorType.DISTANCE)
.step(SameValueCompress.NAME);
computed(SensorType.GFORCE)
.step(SameValueCompress.NAME);
/* Slope: rejection outside -45..45 %, then compression. */
computed(SensorType.SLOPE)
.step(SlopeBadPointFilter.NAME,
Map.of(BadPointFilter.USE_RANGE, true, BadPointFilter.MIN, -45, BadPointFilter.MAX, 45))
.step(SameValueCompress.NAME);
}
}Import plan for GPX tracks: coordinates, elevation, temperature, heart rate, cadence and power from the file, plus computed distance, G-force and slope. All scenarios are on.
The plan processes no data itself. It tells the application which steps (formulas) to apply to each sensor of the source, in what order and with which parameter values. The steps themselves are in the packages processing/gaps, processing/filters and processing/compress, and the list of plans is collected by BuiltinScenarios. The title and description of the format in the import settings are the strings Plugin.ImportPlan.gpx.title ("GPX") and Plugin.ImportPlan.gpx.description.
Data. The format identifier is "gpx" (the FORMAT_ID constant), it is passed to the constructor of the base ImportPlan. The define() method declares the sensor scenarios in two ways: sensor(type) is a sensor that the source reads from the file, and computed(type) is a sensor that the application computes from others (the SensorType.GEO channel). .disabled() means the scenario is off by default, and the user can turn it on in the import settings. .step(name, values, bindings) adds a step: the name is the NAME of the step, Map.of(...) holds the parameter values, track(...) is the sensor that provides the geo track to a pause step, reference(...) is the reference sensor. A step without a Map takes the default values.
Pauses for coordinates, elevation and temperature are searched by StepGaps ("Pauses by recording gap"): a pause is a gap between points that is longer than the usual recording step multiplied by the factor and not shorter than the minimal gap. Heart rate, cadence and power use ExplicitGaps ("Pauses from the file") with the track bound to the coordinates.
Settings. The step values below are taken from the plan code; the units are as in the step parameter description (speed in km/h, distances in metres, time in seconds, balance and slope in percent, acceleration in mm/s², rotation in °/s).
| Sensor | Steps and values |
|---|---|
Coordinates (GEO) |
"Pauses by recording gap": minimal gap 10 s, usual step factor 5, moving speed during a gap 2 m/s; "Data compression" |
Elevation (ELEVATION) |
"Pauses by recording gap": the same values (10 s, 5, 2 m/s), track is GEO; "Data compression" |
Temperature (TEMPERATURE) |
"Pauses by recording gap": minimal gap 60 s, factor 5, track is GEO (the speed during a gap is not set, the step default applies); "Data compression" |
Heart rate (HEART) |
"Bad heart rate points": limit check on, from 1 to 220; "Pauses from the file" (track is GEO); "Data compression" |
Cadence (CADENC) |
"Pauses from the file" (track is GEO); "Data compression" |
Power (CYCLING_POWER) |
"Bad power points": spike search window 5 s, deviation 1000, lower threshold 1500; "Pauses from the file" (track is GEO); "Data compression" |
Distance, computed (computed DISTANCE) |
"Data compression" |
G-force, computed (computed GFORCE) |
"Data compression" |
Slope, computed (computed SLOPE) |
"Bad slope points": limit check on, from -45 to 45; "Data compression" |
The GPX plan has no scenario for speed (SPEED). There are no scenarios that are off.
Drawing. Not applicable: the plan only sets the order and the values of the processing.
- The
movingTrackvalues are shared by the coordinates and the elevation in the plan code; in the import settings the user changes the values of each sensor separately. - Speed is not processed in the GPX plan: there is no
SPEEDscenario. - The user can change the values and turn scenarios on or off; the plan sets only the default values.
- A public no-argument constructor is required: without it the user could not change the plan values in the settings. The class is
final.