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

99 lines (98 loc) 5.06 kB
import { ActivityInterface } from '../../activities/activity.interface'; import { StreamInterface } from '../../streams/stream.interface'; import { DataInterface } from '../../data/data.interface'; import { ActivityTypes } from '../../activities/activity.types'; import { StatsClassInterface } from '../../stats/stats.class.interface'; export declare class ActivityUtilities { private static geoLibAdapter; static getDataTypeAvg(activity: ActivityInterface, streamType: string, startDate?: Date, endDate?: Date): number; static getAverage(data: number[]): number; static getDataTypeMax(activity: ActivityInterface, streamType: string, startDate?: Date, endDate?: Date): number; static getDataTypeMin(activity: ActivityInterface, streamType: string, startDate?: Date, endDate?: Date): number; static getDataTypeMinToMaxDifference(activity: ActivityInterface, streamType: string, startDate?: Date, endDate?: Date): number; static getDataTypeFirst(activity: ActivityInterface, streamType: string, startDate?: Date, endDate?: Date): number; static getDataTypeLast(activity: ActivityInterface, streamType: string, startDate?: Date, endDate?: Date): number; static cropDistance(startDistance: number, endDistance: number, activity: ActivityInterface): ActivityInterface; /** * Crops left,right on time. * Start and end date need to be relative to the activity start / end time * @param activity * @param startDate * @param endDate */ static cropTime(activity: ActivityInterface, startDate?: Date, endDate?: Date): ActivityInterface; static getStreamDataTypesBasedOnDataType(streamToBaseOn: StreamInterface, streams: StreamInterface[]): { [type: string]: number | null; }[]; static getStreamDataTypesBasedOnTime(startDate: Date, endDate: Date, streams: StreamInterface[]): { [type: number]: { [type: string]: number | null; }; }; static getDataLength(startDate: Date, endDate: Date): number; static generateMissingStreamsAndStatsForActivity(activity: ActivityInterface): void; static getSummaryStatsForActivities(activities: ActivityInterface[]): DataInterface[]; static getIntensityZonesStatsAggregated(statClassInstances: StatsClassInterface[]): DataInterface[]; static getActivityDataTypeGain(activity: ActivityInterface, streamType: string, starDate?: Date, endDate?: Date, minDiff?: number): number; static getActivityDataTypeLoss(activity: ActivityInterface, streamType: string, starDate?: Date, endDate?: Date, minDiff?: number): number; static getGainOrLoss(data: number[], gain: boolean, minDiff?: number): number; static getMax(data: number[]): number; static getMin(data: number[]): number; static calculateTotalDistanceForActivity(activity: ActivityInterface, startDate?: Date, endDate?: Date): number; /** * Returns streams that derive from speed based on the activity type * @param speedStream * @param activityType */ private static createByActivityTypeSpeedBasedStreams; /** * Returns streams that derive from grade adjusted speed based on the activity type * @param gradeAdjustedSpeedStream * @param activityType */ private static createByActivityTypeAltiDistanceSpeedBasedStreams; /** * @todo unit test (get the pun?) * This creates streams that are deriving as unit based streams * For example it will create pace from speed, swim pace from speed but also speed in km/h as a unitstream * @param streams * @param activityType * @param unitStreamTypes DynamicDataLoader.allUnitDerivedDataTypes this acts like a whitelist for the unit derived units ONLY! */ static createUnitStreamsFromStreams(streams: StreamInterface[], activityType: ActivityTypes, unitStreamTypes?: string[]): StreamInterface[]; /** * Generates missing streams for an activity such as distance etc if they are missing * This will always create a steam even if the distance is 0 * @param activity */ private static generateMissingStreamsForActivity; /** * Back and forth fills an activity's stream data so they can be more "tree" like * It does this for: * * [DataAltitude.type, * DataHeartRate.type, * DataCadence.type, * DataDistance.type] * * Example * * Distance[0, 10, 30, 40, 50,null,60] #null here is legit eg missing record * Altitude[100, 101, null, 103, null, null, 106] * Should be * Altitude[100,101,101,103,103,103,106] * * @param activity */ private static addMissingDataToStreams; private static getActivityDataTypeGainOrLoss; private static getActivityDataTypeMinOrMax; /** * Generates the stats for an activity * @todo move to factory with next version * @param activity */ private static generateMissingStatsForActivity; private static generateMissingSpeedDerivedStatsForActivity; private static generateMissingUnitStatsForActivity; }