UNPKG

@sports-alliance/sports-lib

Version:

A Library to for importing / exporting and processing GPX, TCX, FIT and JSON files from services such as Strava, Movescount, Garmin, Polar etc

74 lines (73 loc) 2.36 kB
import { SerializableClassInterface } from '../serializable/serializable.class.interface'; import { StreamJSONInterface } from './stream'; import { StreamFilterInterface } from './stream.filter.interface'; /** * A stream consists of an array of data like this for example * AltitudeStream: [100, 110, null, 112, 200, null, 300] * The sampling rate of streams is fixed to 1s * That means that on the above example the duration is seconds would be: * [1,2,3,4,5,6,6] * * null means no value and that means missing data. */ export interface StreamInterface extends SerializableClassInterface { /** * Type of the string. Can be any of the datatypes stored in the dataStore. * @todo make this an 'enum' */ type: string; /** * Instructs the stream to use a specific filter when asking for data * @param filter */ useFilter(filter: StreamFilterInterface): this; /** * Removes any filter that is used on the Streamm */ clearFilters(): this; /** * Checks if a stream has a filter */ hasFilter(): boolean; /** * Get's back the streams data as an array * @param onlyNumeric * @param filterInfinity */ getData(onlyNumeric?: boolean, filterInfinity?: boolean): (number | null)[]; /** * Sets the data for this stream * @param data */ setData(data: (number | null)[]): this; /** * Gets the data based / offset on a startDate * @param startDate * @param onlyNumeric * @param filterInfinity */ getStreamDataByTime(startDate: Date, onlyNumeric?: boolean, filterInfinity?: boolean): StreamDataItem[]; /** * Gets the data offset on a time * @param offset * @param onlyNumeric * @param filterInfinity */ getStreamDataByDuration(offset?: number, onlyNumeric?: boolean, filterInfinity?: boolean): StreamDataItem[]; /** * Checks if the speed is exportable * - It should not be speed derived stream * - It should not be unit derived stream * - It should not be GNSS distance and other types on blacklist */ isExportable(): boolean; toJSON(): StreamJSONInterface; } export interface StreamDataItem { /** * The time of the value * Can be time as of date or just time in ms */ time: number; value: number | null; }