incyclist-services 1.6.3 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ride/route/RLVDisplayService.d.ts +2 -1
- package/lib/ride/route/RLVDisplayService.js +22 -2
- package/lib/ride/route/RouteDisplayService.js +2 -2
- package/lib/routes/base/utils/route.d.ts +1 -0
- package/lib/routes/base/utils/route.js +10 -1
- package/lib/workouts/list/service.js +4 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { Observer } from "../../base/types";
|
|
|
3
3
|
import { LocalizationService } from "../../i18n";
|
|
4
4
|
import { RouteListService } from "../../routes";
|
|
5
5
|
import { Route } from "../../routes/base/model/route";
|
|
6
|
-
import { RouteInfoText } from "../../routes/base/types";
|
|
6
|
+
import { RouteInfoText, RoutePoint } from "../../routes/base/types";
|
|
7
7
|
import { VideoConversion, VideoSyncHelper } from "../../video";
|
|
8
8
|
import { CurrentPosition, CurrentRideDisplayProps, InfotextDisplayProps, OverlayDisplayProps, RLVDisplayProps } from "../base";
|
|
9
9
|
import { RouteDisplayService } from "./RouteDisplayService";
|
|
@@ -45,6 +45,7 @@ export declare class RLVDisplayService extends RouteDisplayService {
|
|
|
45
45
|
getDisplayProperties(props: CurrentRideDisplayProps): RLVDisplayProps;
|
|
46
46
|
protected getInfotextDisplayProps(): InfotextDisplayProps;
|
|
47
47
|
protected checkFinishOptions(position: CurrentPosition): boolean;
|
|
48
|
+
protected preparePointsForMerge(currentPoints: RoutePoint[], nextPoints: RoutePoint[]): void;
|
|
48
49
|
protected onNextVideo(): void;
|
|
49
50
|
protected checkInfotextDisplayProps(time: number): void;
|
|
50
51
|
protected getUIText(input: string): string;
|
|
@@ -49,6 +49,7 @@ const types_1 = require("../../base/types");
|
|
|
49
49
|
const i18n_1 = require("../../i18n");
|
|
50
50
|
const utils_1 = require("../../maps/MapArea/utils");
|
|
51
51
|
const routes_1 = require("../../routes");
|
|
52
|
+
const geo_1 = require("../../utils/geo");
|
|
52
53
|
const video_1 = require("../../video");
|
|
53
54
|
const RouteDisplayService_1 = require("./RouteDisplayService");
|
|
54
55
|
let RLVDisplayService = (() => {
|
|
@@ -209,6 +210,22 @@ let RLVDisplayService = (() => {
|
|
|
209
210
|
return false;
|
|
210
211
|
}
|
|
211
212
|
}
|
|
213
|
+
preparePointsForMerge(currentPoints, nextPoints) {
|
|
214
|
+
(0, routes_1.correctDistanceValues)(currentPoints);
|
|
215
|
+
(0, routes_1.correctDistanceValues)(nextPoints);
|
|
216
|
+
nextPoints.forEach(p => {
|
|
217
|
+
delete p.routeDistance;
|
|
218
|
+
delete p.cnt;
|
|
219
|
+
delete p.elevationGain;
|
|
220
|
+
delete p.slope;
|
|
221
|
+
});
|
|
222
|
+
const pLastCurrent = currentPoints[currentPoints.length - 1];
|
|
223
|
+
const pFirstNext = nextPoints[0];
|
|
224
|
+
const distance = (0, geo_1.distanceBetween)(pLastCurrent, pFirstNext);
|
|
225
|
+
const elevationGain = distance < 5 ? 0 : pLastCurrent.slope * distance / 100;
|
|
226
|
+
const elevationDelta = (pLastCurrent.elevation + elevationGain) - pFirstNext.elevation;
|
|
227
|
+
nextPoints.forEach(p => { p.elevation += elevationDelta; });
|
|
228
|
+
}
|
|
212
229
|
onNextVideo() {
|
|
213
230
|
const old = this.currentVideo;
|
|
214
231
|
const next = this.currentVideo.next;
|
|
@@ -225,8 +242,11 @@ let RLVDisplayService = (() => {
|
|
|
225
242
|
setTimeout(() => {
|
|
226
243
|
old.syncHelper.reset();
|
|
227
244
|
}, 2000);
|
|
228
|
-
|
|
229
|
-
|
|
245
|
+
const currentPoints = this.getCurrentRoute().details.points;
|
|
246
|
+
const nextPoints = next.route.details.points;
|
|
247
|
+
this.preparePointsForMerge(currentPoints, nextPoints);
|
|
248
|
+
(0, utils_1.concatPaths)(currentPoints, nextPoints, 'after');
|
|
249
|
+
(0, routes_1.validateRoute)(this.getCurrentRoute(), false);
|
|
230
250
|
this.emit('route-updated', this.getCurrentRoute());
|
|
231
251
|
this.logEvent({ message: 'switching to next video', route: this.getCurrentRoute().details.title,
|
|
232
252
|
segment: this.currentVideo.route.description.title, offset: this.offset, segmentDistance: this.currentVideo.route.description.distance,
|
|
@@ -89,12 +89,12 @@ let RouteDisplayService = (() => {
|
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
91
|
try {
|
|
92
|
+
const prevPosition = Object.assign({}, this.position);
|
|
92
93
|
const newPosition = this.updatePosition(activityPos);
|
|
93
94
|
if (!newPosition)
|
|
94
95
|
return;
|
|
95
96
|
const isCompleted = this.checkFinishOptions(newPosition);
|
|
96
97
|
if (!isCompleted) {
|
|
97
|
-
const prevPosition = this.position;
|
|
98
98
|
this.position = Object.assign({}, newPosition);
|
|
99
99
|
const { lat, lng, routeDistance, lap } = newPosition;
|
|
100
100
|
this.onPositionUpdate({ route: this.getOriginalRoute(), position: this.position });
|
|
@@ -275,7 +275,7 @@ let RouteDisplayService = (() => {
|
|
|
275
275
|
const current = this.toLapPoint(this.position);
|
|
276
276
|
props = { routeDistance: activityPos === null || activityPos === void 0 ? void 0 : activityPos.routeDistance, prev: current };
|
|
277
277
|
const next = (0, routes_1.getNextPosition)(this.getCurrentRoute(), props);
|
|
278
|
-
|
|
278
|
+
this.position = this.fromLapPoint(next);
|
|
279
279
|
}
|
|
280
280
|
return this.position;
|
|
281
281
|
}
|
|
@@ -7,6 +7,7 @@ export declare const validateSlopes: (points: Array<RoutePoint>) => void;
|
|
|
7
7
|
export declare const updateSlopes: (points: Array<RoutePoint>, validateOnly?: boolean) => void;
|
|
8
8
|
export declare const getSegments: (route: Route) => Array<RouteSegment>;
|
|
9
9
|
export declare const addDetails: (route: Route, details: RouteApiDetail) => void;
|
|
10
|
+
export declare const correctDistanceValues: (points: RoutePoint[]) => void;
|
|
10
11
|
export declare const validateRoute: (route: Route | RouteApiDetail, reset?: boolean) => void;
|
|
11
12
|
export declare const validateDistance: (points: Array<RoutePoint>) => void;
|
|
12
13
|
export declare const getTotalElevation: (route: RouteApiDetail) => number;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getNextVideoId = exports.hasNextVideo = exports.createFromJson = exports.getPointAtDistance = exports.getHeading = exports.getPosition = exports.getNextPosition = exports.getRouteHash = exports.getTotalDistance = exports.updateCnt = exports.updateElevationGain = exports.getElevationGainAt = exports.getTotalElevation = exports.validateDistance = exports.validateRoute = exports.addDetails = exports.getSegments = exports.updateSlopes = exports.validateSlopes = exports.checkIsLoop = void 0;
|
|
6
|
+
exports.getNextVideoId = exports.hasNextVideo = exports.createFromJson = exports.getPointAtDistance = exports.getHeading = exports.getPosition = exports.getNextPosition = exports.getRouteHash = exports.getTotalDistance = exports.updateCnt = exports.updateElevationGain = exports.getElevationGainAt = exports.getTotalElevation = exports.validateDistance = exports.validateRoute = exports.correctDistanceValues = exports.addDetails = exports.getSegments = exports.updateSlopes = exports.validateSlopes = exports.checkIsLoop = void 0;
|
|
7
7
|
const utils_1 = require("../../../utils");
|
|
8
8
|
const clone_1 = __importDefault(require("../../../utils/clone"));
|
|
9
9
|
const geo_1 = require("../../../utils/geo");
|
|
@@ -179,6 +179,15 @@ const addVideoDetails = (route, details) => {
|
|
|
179
179
|
route.description.hasGpx = details.points.find(p => p.lat && p.lng) !== undefined;
|
|
180
180
|
route.description.next = (_c = details.video) === null || _c === void 0 ? void 0 : _c.next;
|
|
181
181
|
};
|
|
182
|
+
const correctDistanceValues = (points) => {
|
|
183
|
+
points.forEach((p, idx) => {
|
|
184
|
+
if (idx == 0) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
p.distance = p.routeDistance - points[idx - 1].routeDistance;
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
exports.correctDistanceValues = correctDistanceValues;
|
|
182
191
|
const validateRoute = (route, reset = false) => {
|
|
183
192
|
var _a;
|
|
184
193
|
if (!((_a = route === null || route === void 0 ? void 0 : route.points) === null || _a === void 0 ? void 0 : _a.length))
|
|
@@ -93,7 +93,10 @@ let WorkoutListService = (() => {
|
|
|
93
93
|
this.getWorkoutCalendar().off('updated', this.onUpdate);
|
|
94
94
|
this.getWorkoutCalendar().reset();
|
|
95
95
|
}
|
|
96
|
-
getSelected() {
|
|
96
|
+
getSelected() {
|
|
97
|
+
const workoutShown = this.getAppState().getState('workoutShown');
|
|
98
|
+
return workoutShown ? this.selectedWorkout : undefined;
|
|
99
|
+
}
|
|
97
100
|
setScreenProps(props) { this.screenProps = props; }
|
|
98
101
|
getScreenProps() { return this.screenProps; }
|
|
99
102
|
open() {
|