mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-02 08:42:31 +00:00
* Add support for nautical units * Make panel reactive to unit changes even after pushing down conversions into utility functions. * Fix issue: km->mph conversion was not done right. * Add support for nautical units to the Time dialog. * Add support for nautical units to the embedding view and embedding playground. * add missing parameter and rename * "npx prettier" pass on the files changed in this PR Does not include changes to `website/src/lib/db.ts`, because there would otherwise be lots of unrelated formatting changes * Change elevation unit to meters for 'nautical' distances. * hide elevation decimals --------- Co-authored-by: bdbkun <1308709+mbof@users.noreply.github.com> Co-authored-by: vcoppe <vianney.coppe@gmail.com>
This commit is contained in:
@@ -333,6 +333,7 @@
|
|||||||
<Menubar.RadioGroup bind:value={$distanceUnits}>
|
<Menubar.RadioGroup bind:value={$distanceUnits}>
|
||||||
<Menubar.RadioItem value="metric">{$_('menu.metric')}</Menubar.RadioItem>
|
<Menubar.RadioItem value="metric">{$_('menu.metric')}</Menubar.RadioItem>
|
||||||
<Menubar.RadioItem value="imperial">{$_('menu.imperial')}</Menubar.RadioItem>
|
<Menubar.RadioItem value="imperial">{$_('menu.imperial')}</Menubar.RadioItem>
|
||||||
|
<Menubar.RadioItem value="nautical">{$_('menu.nautical')}</Menubar.RadioItem>
|
||||||
</Menubar.RadioGroup>
|
</Menubar.RadioGroup>
|
||||||
</Menubar.SubContent>
|
</Menubar.SubContent>
|
||||||
</Menubar.Sub>
|
</Menubar.Sub>
|
||||||
|
@@ -2,9 +2,12 @@
|
|||||||
import { settings } from '$lib/db';
|
import { settings } from '$lib/db';
|
||||||
import {
|
import {
|
||||||
celsiusToFahrenheit,
|
celsiusToFahrenheit,
|
||||||
distancePerHourToSecondsPerDistance,
|
getConvertedDistance,
|
||||||
kilometersToMiles,
|
getConvertedElevation,
|
||||||
metersToFeet,
|
getConvertedVelocity,
|
||||||
|
getDistanceUnits,
|
||||||
|
getElevationUnits,
|
||||||
|
getVelocityUnits,
|
||||||
secondsToHHMMSS
|
secondsToHHMMSS
|
||||||
} from '$lib/units';
|
} from '$lib/units';
|
||||||
|
|
||||||
@@ -20,31 +23,18 @@
|
|||||||
|
|
||||||
<span class={$$props.class}>
|
<span class={$$props.class}>
|
||||||
{#if type === 'distance'}
|
{#if type === 'distance'}
|
||||||
{#if $distanceUnits === 'metric'}
|
{getConvertedDistance(value, $distanceUnits).toFixed(decimals ?? 2)}
|
||||||
{value.toFixed(decimals ?? 2)} {showUnits ? $_('units.kilometers') : ''}
|
{showUnits ? getDistanceUnits($distanceUnits) : ''}
|
||||||
{:else}
|
|
||||||
{kilometersToMiles(value).toFixed(decimals ?? 2)} {showUnits ? $_('units.miles') : ''}
|
|
||||||
{/if}
|
|
||||||
{:else if type === 'elevation'}
|
{:else if type === 'elevation'}
|
||||||
{#if $distanceUnits === 'metric'}
|
{getConvertedElevation(value, $distanceUnits).toFixed(decimals ?? 0)}
|
||||||
{value.toFixed(decimals ?? 0)} {showUnits ? $_('units.meters') : ''}
|
{showUnits ? getElevationUnits($distanceUnits) : ''}
|
||||||
{:else}
|
|
||||||
{metersToFeet(value).toFixed(decimals ?? 0)} {showUnits ? $_('units.feet') : ''}
|
|
||||||
{/if}
|
|
||||||
{:else if type === 'speed'}
|
{:else if type === 'speed'}
|
||||||
{#if $distanceUnits === 'metric'}
|
|
||||||
{#if $velocityUnits === 'speed'}
|
{#if $velocityUnits === 'speed'}
|
||||||
{value.toFixed(decimals ?? 2)} {showUnits ? $_('units.kilometers_per_hour') : ''}
|
{getConvertedVelocity(value, $velocityUnits, $distanceUnits).toFixed(decimals ?? 2)}
|
||||||
|
{showUnits ? getVelocityUnits($velocityUnits, $distanceUnits) : ''}
|
||||||
{:else}
|
{:else}
|
||||||
{secondsToHHMMSS(distancePerHourToSecondsPerDistance(value))}
|
{secondsToHHMMSS(getConvertedVelocity(value, $velocityUnits, $distanceUnits))}
|
||||||
{showUnits ? $_('units.minutes_per_kilometer') : ''}
|
{showUnits ? getVelocityUnits($velocityUnits, $distanceUnits) : ''}
|
||||||
{/if}
|
|
||||||
{:else if $velocityUnits === 'speed'}
|
|
||||||
{kilometersToMiles(value).toFixed(decimals ?? 2)}
|
|
||||||
{showUnits ? $_('units.miles_per_hour') : ''}
|
|
||||||
{:else}
|
|
||||||
{secondsToHHMMSS(distancePerHourToSecondsPerDistance(kilometersToMiles(value)))}
|
|
||||||
{showUnits ? $_('units.minutes_per_mile') : ''}
|
|
||||||
{/if}
|
{/if}
|
||||||
{:else if type === 'temperature'}
|
{:else if type === 'temperature'}
|
||||||
{#if $temperatureUnits === 'celsius'}
|
{#if $temperatureUnits === 'celsius'}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { PUBLIC_MAPBOX_TOKEN } from "$env/static/public";
|
import { PUBLIC_MAPBOX_TOKEN } from '$env/static/public';
|
||||||
import { basemaps } from "$lib/assets/layers";
|
import { basemaps } from '$lib/assets/layers';
|
||||||
|
|
||||||
export type EmbeddingOptions = {
|
export type EmbeddingOptions = {
|
||||||
token: string;
|
token: string;
|
||||||
@@ -7,21 +7,21 @@ export type EmbeddingOptions = {
|
|||||||
basemap: string;
|
basemap: string;
|
||||||
elevation: {
|
elevation: {
|
||||||
show: boolean;
|
show: boolean;
|
||||||
height: number,
|
height: number;
|
||||||
controls: boolean,
|
controls: boolean;
|
||||||
fill: 'slope' | 'surface' | undefined,
|
fill: 'slope' | 'surface' | undefined;
|
||||||
speed: boolean,
|
speed: boolean;
|
||||||
hr: boolean,
|
hr: boolean;
|
||||||
cad: boolean,
|
cad: boolean;
|
||||||
temp: boolean,
|
temp: boolean;
|
||||||
power: boolean,
|
power: boolean;
|
||||||
},
|
};
|
||||||
distanceMarkers: boolean,
|
distanceMarkers: boolean;
|
||||||
directionMarkers: boolean,
|
directionMarkers: boolean;
|
||||||
distanceUnits: 'metric' | 'imperial',
|
distanceUnits: 'metric' | 'imperial' | 'nautical';
|
||||||
velocityUnits: 'speed' | 'pace',
|
velocityUnits: 'speed' | 'pace';
|
||||||
temperatureUnits: 'celsius' | 'fahrenheit',
|
temperatureUnits: 'celsius' | 'fahrenheit';
|
||||||
theme: 'system' | 'light' | 'dark',
|
theme: 'system' | 'light' | 'dark';
|
||||||
};
|
};
|
||||||
|
|
||||||
export const defaultEmbeddingOptions = {
|
export const defaultEmbeddingOptions = {
|
||||||
@@ -37,21 +37,24 @@ export const defaultEmbeddingOptions = {
|
|||||||
hr: false,
|
hr: false,
|
||||||
cad: false,
|
cad: false,
|
||||||
temp: false,
|
temp: false,
|
||||||
power: false,
|
power: false
|
||||||
},
|
},
|
||||||
distanceMarkers: false,
|
distanceMarkers: false,
|
||||||
directionMarkers: false,
|
directionMarkers: false,
|
||||||
distanceUnits: 'metric',
|
distanceUnits: 'metric',
|
||||||
velocityUnits: 'speed',
|
velocityUnits: 'speed',
|
||||||
temperatureUnits: 'celsius',
|
temperatureUnits: 'celsius',
|
||||||
theme: 'system',
|
theme: 'system'
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getDefaultEmbeddingOptions(): EmbeddingOptions {
|
export function getDefaultEmbeddingOptions(): EmbeddingOptions {
|
||||||
return JSON.parse(JSON.stringify(defaultEmbeddingOptions));
|
return JSON.parse(JSON.stringify(defaultEmbeddingOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getMergedEmbeddingOptions(options: any, defaultOptions: any = defaultEmbeddingOptions): EmbeddingOptions {
|
export function getMergedEmbeddingOptions(
|
||||||
|
options: any,
|
||||||
|
defaultOptions: any = defaultEmbeddingOptions
|
||||||
|
): EmbeddingOptions {
|
||||||
const mergedOptions = JSON.parse(JSON.stringify(defaultOptions));
|
const mergedOptions = JSON.parse(JSON.stringify(defaultOptions));
|
||||||
for (const key in options) {
|
for (const key in options) {
|
||||||
if (typeof options[key] === 'object' && options[key] !== null && !Array.isArray(options[key])) {
|
if (typeof options[key] === 'object' && options[key] !== null && !Array.isArray(options[key])) {
|
||||||
@@ -63,10 +66,17 @@ export function getMergedEmbeddingOptions(options: any, defaultOptions: any = de
|
|||||||
return mergedOptions;
|
return mergedOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCleanedEmbeddingOptions(options: any, defaultOptions: any = defaultEmbeddingOptions): any {
|
export function getCleanedEmbeddingOptions(
|
||||||
|
options: any,
|
||||||
|
defaultOptions: any = defaultEmbeddingOptions
|
||||||
|
): any {
|
||||||
const cleanedOptions = JSON.parse(JSON.stringify(options));
|
const cleanedOptions = JSON.parse(JSON.stringify(options));
|
||||||
for (const key in cleanedOptions) {
|
for (const key in cleanedOptions) {
|
||||||
if (typeof cleanedOptions[key] === 'object' && cleanedOptions[key] !== null && !Array.isArray(cleanedOptions[key])) {
|
if (
|
||||||
|
typeof cleanedOptions[key] === 'object' &&
|
||||||
|
cleanedOptions[key] !== null &&
|
||||||
|
!Array.isArray(cleanedOptions[key])
|
||||||
|
) {
|
||||||
cleanedOptions[key] = getCleanedEmbeddingOptions(cleanedOptions[key], defaultOptions[key]);
|
cleanedOptions[key] = getCleanedEmbeddingOptions(cleanedOptions[key], defaultOptions[key]);
|
||||||
if (Object.keys(cleanedOptions[key]).length === 0) {
|
if (Object.keys(cleanedOptions[key]).length === 0) {
|
||||||
delete cleanedOptions[key];
|
delete cleanedOptions[key];
|
||||||
@@ -78,7 +88,9 @@ export function getCleanedEmbeddingOptions(options: any, defaultOptions: any = d
|
|||||||
return cleanedOptions;
|
return cleanedOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const allowedEmbeddingBasemaps = Object.keys(basemaps).filter(basemap => !['ordnanceSurvey'].includes(basemap));
|
export const allowedEmbeddingBasemaps = Object.keys(basemaps).filter(
|
||||||
|
(basemap) => !['ordnanceSurvey'].includes(basemap)
|
||||||
|
);
|
||||||
|
|
||||||
export function getURLForGoogleDriveFile(fileId: string): string {
|
export function getURLForGoogleDriveFile(fileId: string): string {
|
||||||
return `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media&key=AIzaSyA2ZadQob_hXiT2VaYIkAyafPvz_4ZMssk`;
|
return `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media&key=AIzaSyA2ZadQob_hXiT2VaYIkAyafPvz_4ZMssk`;
|
||||||
@@ -87,7 +99,7 @@ export function getURLForGoogleDriveFile(fileId: string): string {
|
|||||||
export function convertOldEmbeddingOptions(options: URLSearchParams): any {
|
export function convertOldEmbeddingOptions(options: URLSearchParams): any {
|
||||||
let newOptions: any = {
|
let newOptions: any = {
|
||||||
token: PUBLIC_MAPBOX_TOKEN,
|
token: PUBLIC_MAPBOX_TOKEN,
|
||||||
files: [],
|
files: []
|
||||||
};
|
};
|
||||||
if (options.has('state')) {
|
if (options.has('state')) {
|
||||||
let state = JSON.parse(options.get('state')!);
|
let state = JSON.parse(options.get('state')!);
|
||||||
@@ -122,7 +134,7 @@ export function convertOldEmbeddingOptions(options: URLSearchParams): any {
|
|||||||
}
|
}
|
||||||
if (options.has('slope')) {
|
if (options.has('slope')) {
|
||||||
newOptions.elevation = {
|
newOptions.elevation = {
|
||||||
fill: 'slope',
|
fill: 'slope'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return newOptions;
|
return newOptions;
|
||||||
|
@@ -221,6 +221,10 @@
|
|||||||
<RadioGroup.Item value="imperial" id="imperial" />
|
<RadioGroup.Item value="imperial" id="imperial" />
|
||||||
<Label for="imperial">{$_('menu.imperial')}</Label>
|
<Label for="imperial">{$_('menu.imperial')}</Label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<RadioGroup.Item value="nautical" id="nautical" />
|
||||||
|
<Label for="nautical">{$_('menu.nautical')}</Label>
|
||||||
|
</div>
|
||||||
</RadioGroup.Root>
|
</RadioGroup.Root>
|
||||||
</Label>
|
</Label>
|
||||||
<Label class="flex flex-col items-start gap-2">
|
<Label class="flex flex-col items-start gap-2">
|
||||||
|
@@ -10,7 +10,8 @@
|
|||||||
import {
|
import {
|
||||||
distancePerHourToSecondsPerDistance,
|
distancePerHourToSecondsPerDistance,
|
||||||
getConvertedVelocity,
|
getConvertedVelocity,
|
||||||
milesToKilometers
|
milesToKilometers,
|
||||||
|
nauticalMilesToKilometers
|
||||||
} from '$lib/units';
|
} from '$lib/units';
|
||||||
import { CalendarDate, type DateValue } from '@internationalized/date';
|
import { CalendarDate, type DateValue } from '@internationalized/date';
|
||||||
import { CalendarClock, CirclePlay, CircleStop, CircleX, Timer, Zap } from 'lucide-svelte';
|
import { CalendarClock, CirclePlay, CircleStop, CircleX, Timer, Zap } from 'lucide-svelte';
|
||||||
@@ -129,6 +130,8 @@
|
|||||||
}
|
}
|
||||||
if ($distanceUnits === 'imperial') {
|
if ($distanceUnits === 'imperial') {
|
||||||
speedValue = milesToKilometers(speedValue);
|
speedValue = milesToKilometers(speedValue);
|
||||||
|
} else if ($distanceUnits === 'nautical') {
|
||||||
|
speedValue = nauticalMilesToKilometers(speedValue);
|
||||||
}
|
}
|
||||||
return speedValue;
|
return speedValue;
|
||||||
}
|
}
|
||||||
@@ -190,8 +193,10 @@
|
|||||||
<span class="text-sm shrink-0">
|
<span class="text-sm shrink-0">
|
||||||
{#if $distanceUnits === 'imperial'}
|
{#if $distanceUnits === 'imperial'}
|
||||||
{$_('units.miles_per_hour')}
|
{$_('units.miles_per_hour')}
|
||||||
{:else}
|
{:else if $distanceUnits === 'metric'}
|
||||||
{$_('units.kilometers_per_hour')}
|
{$_('units.kilometers_per_hour')}
|
||||||
|
{:else if $distanceUnits === 'nautical'}
|
||||||
|
{$_('units.knots')}
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
{:else}
|
{:else}
|
||||||
@@ -204,8 +209,10 @@
|
|||||||
<span class="text-sm shrink-0">
|
<span class="text-sm shrink-0">
|
||||||
{#if $distanceUnits === 'imperial'}
|
{#if $distanceUnits === 'imperial'}
|
||||||
{$_('units.minutes_per_mile')}
|
{$_('units.minutes_per_mile')}
|
||||||
{:else}
|
{:else if $distanceUnits === 'metric'}
|
||||||
{$_('units.minutes_per_kilometer')}
|
{$_('units.minutes_per_kilometer')}
|
||||||
|
{:else if $distanceUnits === 'nautical'}
|
||||||
|
{$_('units.minutes_per_nautical_mile')}
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
@@ -80,7 +80,7 @@ export function dexieSettingStore<T>(key: string, initial: T, initialize: boolea
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const settings = {
|
export const settings = {
|
||||||
distanceUnits: dexieSettingStore<'metric' | 'imperial'>('distanceUnits', 'metric'),
|
distanceUnits: dexieSettingStore<'metric' | 'imperial' | 'nautical'>('distanceUnits', 'metric'),
|
||||||
velocityUnits: dexieSettingStore<'speed' | 'pace'>('velocityUnits', 'speed'),
|
velocityUnits: dexieSettingStore<'speed' | 'pace'>('velocityUnits', 'speed'),
|
||||||
temperatureUnits: dexieSettingStore<'celsius' | 'fahrenheit'>('temperatureUnits', 'celsius'),
|
temperatureUnits: dexieSettingStore<'celsius' | 'fahrenheit'>('temperatureUnits', 'celsius'),
|
||||||
elevationProfile: dexieSettingStore('elevationProfile', true),
|
elevationProfile: dexieSettingStore('elevationProfile', true),
|
||||||
|
@@ -16,6 +16,14 @@ export function metersToFeet(value: number) {
|
|||||||
return value * 3.28084;
|
return value * 3.28084;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function kilometersToNauticalMiles(value: number) {
|
||||||
|
return value * 0.539957;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function nauticalMilesToKilometers(value: number) {
|
||||||
|
return value * 1.852;
|
||||||
|
}
|
||||||
|
|
||||||
export function celsiusToFahrenheit(value: number) {
|
export function celsiusToFahrenheit(value: number) {
|
||||||
return value * 1.8 + 32;
|
return value * 1.8 + 32;
|
||||||
}
|
}
|
||||||
@@ -92,21 +100,52 @@ export function getTemperatureWithUnits(value: number, convert: boolean = true)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the units
|
// Get the units
|
||||||
export function getDistanceUnits() {
|
export function getDistanceUnits(targetDistanceUnits = get(distanceUnits)) {
|
||||||
return get(distanceUnits) === 'metric' ? get(_)('units.kilometers') : get(_)('units.miles');
|
switch (targetDistanceUnits) {
|
||||||
|
case 'metric':
|
||||||
|
return get(_)('units.kilometers');
|
||||||
|
case 'imperial':
|
||||||
|
return get(_)('units.miles');
|
||||||
|
case 'nautical':
|
||||||
|
return get(_)('units.nautical_miles');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getVelocityUnits() {
|
export function getVelocityUnits(
|
||||||
if (get(velocityUnits) === 'speed') {
|
targetVelocityUnits = get(velocityUnits),
|
||||||
return get(distanceUnits) === 'metric' ? get(_)('units.kilometers_per_hour') : get(_)('units.miles_per_hour');
|
targetDistanceUnits = get(distanceUnits)
|
||||||
|
) {
|
||||||
|
if (targetVelocityUnits === 'speed') {
|
||||||
|
switch (targetDistanceUnits) {
|
||||||
|
case 'metric':
|
||||||
|
return get(_)('units.kilometers_per_hour');
|
||||||
|
case 'imperial':
|
||||||
|
return get(_)('units.miles_per_hour');
|
||||||
|
case 'nautical':
|
||||||
|
return get(_)('units.knots');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return get(distanceUnits) === 'metric' ? get(_)('units.minutes_per_kilometer') : get(_)('units.minutes_per_mile');
|
switch (targetDistanceUnits) {
|
||||||
|
case 'metric':
|
||||||
|
return get(_)('units.minutes_per_kilometer');
|
||||||
|
case 'imperial':
|
||||||
|
return get(_)('units.minutes_per_mile');
|
||||||
|
case 'nautical':
|
||||||
|
return get(_)('units.minutes_per_nautical_mile');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getElevationUnits() {
|
export function getElevationUnits(targetDistanceUnits = get(distanceUnits)) {
|
||||||
return get(distanceUnits) === 'metric' ? get(_)('units.meters') : get(_)('units.feet');
|
switch (targetDistanceUnits) {
|
||||||
|
case 'metric':
|
||||||
|
return get(_)('units.meters');
|
||||||
|
case 'imperial':
|
||||||
|
return get(_)('units.feet');
|
||||||
|
case 'nautical':
|
||||||
|
// See https://github.com/gpxstudio/gpx.studio/pull/66#issuecomment-2306568997
|
||||||
|
return get(_)('units.meters');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getHeartRateUnits() {
|
export function getHeartRateUnits() {
|
||||||
@@ -126,19 +165,51 @@ export function getTemperatureUnits() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert only the value
|
// Convert only the value
|
||||||
export function getConvertedDistance(value: number) {
|
export function getConvertedDistance(value: number, targetDistanceUnits = get(distanceUnits)) {
|
||||||
return get(distanceUnits) === 'metric' ? value : kilometersToMiles(value);
|
switch (targetDistanceUnits) {
|
||||||
|
case 'metric':
|
||||||
|
return value;
|
||||||
|
case 'imperial':
|
||||||
|
return kilometersToMiles(value);
|
||||||
|
case 'nautical':
|
||||||
|
return kilometersToNauticalMiles(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getConvertedElevation(value: number) {
|
export function getConvertedElevation(value: number, targetDistanceUnits = get(distanceUnits)) {
|
||||||
return get(distanceUnits) === 'metric' ? value : metersToFeet(value);
|
switch (targetDistanceUnits) {
|
||||||
|
case 'metric':
|
||||||
|
return value;
|
||||||
|
case 'imperial':
|
||||||
|
return metersToFeet(value);
|
||||||
|
case 'nautical':
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getConvertedVelocity(value: number) {
|
export function getConvertedVelocity(
|
||||||
if (get(velocityUnits) === 'speed') {
|
value: number,
|
||||||
return get(distanceUnits) === 'metric' ? value : kilometersToMiles(value);
|
targetVelocityUnits = get(velocityUnits),
|
||||||
|
targetDistanceUnits = get(distanceUnits)
|
||||||
|
) {
|
||||||
|
if (targetVelocityUnits === 'speed') {
|
||||||
|
switch (targetDistanceUnits) {
|
||||||
|
case 'metric':
|
||||||
|
return value;
|
||||||
|
case 'imperial':
|
||||||
|
return kilometersToMiles(value);
|
||||||
|
case 'nautical':
|
||||||
|
return kilometersToNauticalMiles(value);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return get(distanceUnits) === 'metric' ? distancePerHourToSecondsPerDistance(value) : distancePerHourToSecondsPerDistance(kilometersToMiles(value));
|
switch (targetDistanceUnits) {
|
||||||
|
case 'metric':
|
||||||
|
return distancePerHourToSecondsPerDistance(value);
|
||||||
|
case 'imperial':
|
||||||
|
return distancePerHourToSecondsPerDistance(kilometersToMiles(value));
|
||||||
|
case 'nautical':
|
||||||
|
return distancePerHourToSecondsPerDistance(kilometersToNauticalMiles(value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
"distance_units": "Distance units",
|
"distance_units": "Distance units",
|
||||||
"metric": "Metric",
|
"metric": "Metric",
|
||||||
"imperial": "Imperial",
|
"imperial": "Imperial",
|
||||||
|
"nautical": "Nautical",
|
||||||
"velocity_units": "Velocity units",
|
"velocity_units": "Velocity units",
|
||||||
"temperature_units": "Temperature units",
|
"temperature_units": "Temperature units",
|
||||||
"celsius": "Celsius",
|
"celsius": "Celsius",
|
||||||
@@ -363,12 +364,15 @@
|
|||||||
"feet": "ft",
|
"feet": "ft",
|
||||||
"kilometers": "km",
|
"kilometers": "km",
|
||||||
"miles": "mi",
|
"miles": "mi",
|
||||||
|
"nautical_miles": "nm",
|
||||||
"celsius": "°C",
|
"celsius": "°C",
|
||||||
"fahrenheit": "°F",
|
"fahrenheit": "°F",
|
||||||
"kilometers_per_hour": "km/h",
|
"kilometers_per_hour": "km/h",
|
||||||
"miles_per_hour": "mph",
|
"miles_per_hour": "mph",
|
||||||
"minutes_per_kilometer": "min/km",
|
"minutes_per_kilometer": "min/km",
|
||||||
"minutes_per_mile": "min/mi",
|
"minutes_per_mile": "min/mi",
|
||||||
|
"minutes_per_nautical_mile": "min/nm",
|
||||||
|
"knots": "kn",
|
||||||
"heartrate": "bpm",
|
"heartrate": "bpm",
|
||||||
"cadence": "rpm",
|
"cadence": "rpm",
|
||||||
"power": "W"
|
"power": "W"
|
||||||
|
Reference in New Issue
Block a user