Fix speed unit

This commit is contained in:
Lucas Verney 2018-09-17 11:51:35 +02:00
parent 2732f7eba3
commit 085f34dbe8
2 changed files with 11 additions and 4 deletions

View File

@ -1,8 +1,8 @@
<template> <template>
<v-layout row fill-height wrap> <v-layout row fill-height wrap>
<v-flex xs12 class="speed-badge text-xs-center white" v-if="speed !== null && speed !== undefined"> <v-flex xs12 class="speed-badge text-xs-center white" v-if="speedInKmH !== null">
<v-layout column> <v-layout column>
<v-flex xs8 class="title mt-1">{{ speed }}</v-flex> <v-flex xs8 class="title mt-1">{{ speedInKmH }}</v-flex>
<v-flex xs4 class="caption">km/h</v-flex> <v-flex xs4 class="caption">km/h</v-flex>
</v-layout> </v-layout>
</v-flex> </v-flex>
@ -112,6 +112,13 @@ export default {
// Get the currently shown report details ID // Get the currently shown report details ID
return this.$store.state.reportDetails.id; return this.$store.state.reportDetails.id;
}, },
speedInKmH() {
// Convert speed from m/s to km/h
if (this.speed !== null && this.speed !== undefined) {
return this.speed * 3600 / 1000;
}
return null;
},
tileServer() { tileServer() {
const tileServerSetting = this.$store.state.settings.tileServer; const tileServerSetting = this.$store.state.settings.tileServer;
if (tileServerSetting in constants.TILE_SERVERS) { if (tileServerSetting in constants.TILE_SERVERS) {
@ -444,7 +451,7 @@ export default {
polyline: Array, polyline: Array,
positionLatLng: Array, positionLatLng: Array,
reportLatLng: Array, reportLatLng: Array,
speed: Number, speed: Number, // in m/s
zoom: { zoom: {
type: Number, type: Number,
required: true, required: true,

View File

@ -38,7 +38,7 @@ export function mockLocationRandom() {
} }
let speed = null; let speed = null;
if (Math.random() > 0.25) { if (Math.random() > 0.25) {
speed = Math.random() * 20; speed = Math.random() * 9; // in meters/s
} }
const newLocation = { const newLocation = {
coords: { coords: {