Commit dbd6ed90 authored by Andres Käver's avatar Andres Käver
Browse files

domain update

parent f62062f9
Pipeline #799 passed with stages
in 1 minute and 15 seconds
......@@ -3,6 +3,13 @@ export interface IGpsSession {
name: string;
description: string;
recordedAt: string;
duration: number;
speed: number;
distance: number;
climb: number;
descent: number;
paceMin: number;
paceMax: number;
gpsLocationsCount: number;
userFirstLastName: string;
}
......@@ -35,7 +35,7 @@ function addToBucket(buckets: L.LatLngExpression[][][], bucketNo: number, latLon
return buckets;
}
// minSpeed and maxSpeed - seconds per km
export function getColorCodedPolylines(locations: IGpsLocation[], minPace: number = 6, maxPace: number = 18, paceBuckets: number = 256): L.LatLngExpression[][][] {
export function getColorCodedPolylines(locations: IGpsLocation[], minPace: number = 6*60, maxPace: number = 18*60, paceBuckets: number = 256): L.LatLngExpression[][][] {
if (!locations || locations.length == 0) return [];
const result: L.LatLngExpression[][][] = [];
......@@ -59,14 +59,14 @@ export function getColorCodedPolylines(locations: IGpsLocation[], minPace: numbe
if (distance < 1 || duration < 1000) continue;
// calculate the speed in minutes per km
const paceMinutesPerKm = duration / distance / 60;
let bucketNo = Math.round(((paceMinutesPerKm - minPace) / paceStep));
const paceSecondsPerKm = duration / distance ;
let bucketNo = Math.round(((paceSecondsPerKm - minPace) / paceStep));
if (bucketNo < 0) {
bucketNo = 0
} else if (bucketNo >= paceBuckets){
bucketNo = paceBuckets - 1;
}
console.log(paceMinutesPerKm, bucketNo);
//console.log(paceSecondsPerKm, bucketNo);
addToBucket(result, bucketNo, [location.latitude, location.longitude], [prevLocation.latitude, prevLocation.longitude]);
//log.debug('distance duration pace', distance, duration, paceMinutesPerKm);
......
......@@ -67,7 +67,9 @@ export class HomeIndex {
}
this.map = L.map('map').setView([59.3953607, 24.6643414], 15);
//this.map = L.map('map').setView([59.3953607, 24.6643414], 15);
this.map = L.map('map').setView([59.3245441,25.6506961], 14);
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{
......@@ -76,6 +78,31 @@ export class HomeIndex {
).addTo(this.map);
const imageUrl = '/apuparra.png';
// start
// latitude: 59.3245441
//longitude: 25.6506961
// finish
//latitude: 59.3176531
//longitude: 25.6569272
/*
const topLat= 59.337;
const topLng = 25.645;
const width = 0.035;
const height = 0.025;
const imageBounds: L.LatLngBoundsExpression = [
[topLat, topLng],
[topLat - height, topLng + width]];
L.imageOverlay(imageUrl, imageBounds).addTo(this.map);
L.imageOverlay(imageUrl, imageBounds).bringToFront();
*/
this.gpsSessionService.getAll().then(
response => {
if (response.data) {
......@@ -166,7 +193,10 @@ export class HomeIndex {
const polylinePoints: L.LatLngExpression[] = [];
this.trackLength = 0;
const paceBuckets = getColorCodedPolylines(this.gpsLocations, 6, 18, this.paceColorGradient.length);
const minPace = this.selectedGpsSession?.paceMin ? this.selectedGpsSession?.paceMin : 6*60;
const maxPace = this.selectedGpsSession?.paceMax ? this.selectedGpsSession?.paceMax : 18*60;
const paceBuckets = getColorCodedPolylines(this.gpsLocations, minPace, maxPace, this.paceColorGradient.length);
this.gpsLocations.forEach((location, index) => {
polylinePoints.push([location.latitude, location.longitude]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment