Skip to content

Commit

Permalink
fix: add LatLng type for streams and start/end positions
Browse files Browse the repository at this point in the history
  • Loading branch information
andipaetzold committed Nov 12, 2021
1 parent f454a67 commit f48b946
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from './resources'
import { RefreshTokenRequest } from './types'

export * from './types'
export * from './enums'
export * from './models'

Expand Down
5 changes: 3 additions & 2 deletions src/models/detailedActivity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ActivityType, ResourceState } from '../enums'
import { LatLng } from '../types'

import {
ActivityZone,
Expand Down Expand Up @@ -29,8 +30,8 @@ export interface DetailedActivity {
start_date_local: string
timezone: string
utc_offset: number
start_latlng: number[]
end_latlng: number[]
start_latlng: LatLng
end_latlng: LatLng
location_city: string
location_state: string
location_country: string
Expand Down
5 changes: 3 additions & 2 deletions src/models/detailedSegment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PolylineMap, SummaryPRSegmentEffort, SummarySegmentEffort } from '.'
import { LatLng } from '../types';

enum ActivityType {
Ride = 'Ride',
Expand All @@ -14,8 +15,8 @@ export interface DetailedSegment {
maximum_grade: number
elevation_high: number
elevation_low: number
start_latlng: number[]
end_latlng: number[]
start_latlng: LatLng
end_latlng: LatLng
climb_category: number
city: string
state: string
Expand Down
6 changes: 4 additions & 2 deletions src/models/explorerSegment.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { LatLng } from "../types";

enum ClimbCategoryDesc {
NC = 'NC',
ONE = '1',
Expand All @@ -13,8 +15,8 @@ export interface ExplorerSegment {
climb_category: number
climb_category_desc: ClimbCategoryDesc
avg_grade: number
start_latlng: number[]
end_latlng: number[]
start_latlng: LatLng
end_latlng: LatLng
elev_difference: number
distance: number
points: string
Expand Down
35 changes: 21 additions & 14 deletions src/models/stream.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
export interface Stream {
type:
| 'time'
| 'distance'
| 'latlng'
| 'altitude'
| 'velocity_smooth'
| 'heartrate'
| 'cadence'
| 'watts'
| 'temp'
| 'moving'
| 'grade_smooth'
import { LatLng, StreamKeys } from '..'

export interface BaseStream<StreamKey extends StreamKeys, Data> {
type: StreamKey
original_size: number
resolution: 'low' | 'medium' | 'high'
series_type: 'distance' | 'time'
data: number[]
data: Data[]
}

export type Stream = BaseStream<
| 'time'
| 'distance'
| 'altitude'
| 'velocity_smooth'
| 'heartrate'
| 'cadence'
| 'watts'
| 'temp'
| 'moving'
| 'grade_smooth',
number
>

export type LatLngStream = BaseStream<'latlng', LatLng>
4 changes: 2 additions & 2 deletions src/models/streamSet.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Stream } from '.'
import { LatLngStream, Stream } from '.'

export interface StreamSet {
time: Stream
distance: Stream
latlng: Stream
latlng: LatLngStream
altitude: Stream
velocity_smooth: Stream
heartrate: Stream
Expand Down
5 changes: 3 additions & 2 deletions src/models/summaryActivity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ActivityType, ResourceState } from '../enums'
import { LatLng } from '../types'

import { MetaAthlete, PolylineMap } from '.'

Expand All @@ -19,8 +20,8 @@ export interface SummaryActivity {
start_date_local: string
timezone: string
utc_offset: number
start_latlng: number[]
end_latlng: number[]
start_latlng: LatLng
end_latlng: LatLng
location_city: string
location_state: string
location_country: string
Expand Down
5 changes: 3 additions & 2 deletions src/models/summarySegment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SummarySegmentEffort } from '.'
import { LatLng } from '../types';

enum ActivityType {
Ride = 'Ride',
Expand All @@ -14,8 +15,8 @@ export interface SummarySegment {
maximum_grade: number
elevation_high: number
elevation_low: number
start_latlng: number[]
end_latlng: number[]
start_latlng: LatLng
end_latlng: LatLng
climb_category: number
city: string
state: string
Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ export interface RefreshTokenResponse {
expires_in: number
refresh_token: string
}

/**
* Latitude, Longitude
*/
export type LatLng = [number, number]

0 comments on commit f48b946

Please sign in to comment.