"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
This commit is contained in:
parent
7db43d3e35
commit
62da9b7f37
3 changed files with 249 additions and 230 deletions
|
|
@ -23,18 +23,18 @@
|
||||||
|
|
||||||
<span class={$$props.class}>
|
<span class={$$props.class}>
|
||||||
{#if type === 'distance'}
|
{#if type === 'distance'}
|
||||||
{ getConvertedDistance(value, $distanceUnits).toFixed(decimals ?? 2) }
|
{getConvertedDistance(value, $distanceUnits).toFixed(decimals ?? 2)}
|
||||||
{ showUnits ? getDistanceUnits($distanceUnits) : '' }
|
{showUnits ? getDistanceUnits($distanceUnits) : ''}
|
||||||
{:else if type === 'elevation'}
|
{:else if type === 'elevation'}
|
||||||
{ getConvertedElevation(value, $distanceUnits).toFixed(decimals ?? 2) }
|
{getConvertedElevation(value, $distanceUnits).toFixed(decimals ?? 2)}
|
||||||
{ showUnits ? getElevationUnits($distanceUnits) : '' }
|
{showUnits ? getElevationUnits($distanceUnits) : ''}
|
||||||
{:else if type === 'speed'}
|
{:else if type === 'speed'}
|
||||||
{#if $velocityUnits === 'speed'}
|
{#if $velocityUnits === 'speed'}
|
||||||
{ getConvertedVelocity(value, $velocityUnits, $distanceUnits).toFixed(decimals ?? 2) }
|
{getConvertedVelocity(value, $velocityUnits, $distanceUnits).toFixed(decimals ?? 2)}
|
||||||
{ showUnits ? getVelocityUnits($velocityUnits, $distanceUnits) : '' }
|
{showUnits ? getVelocityUnits($velocityUnits, $distanceUnits) : ''}
|
||||||
{:else}
|
{:else}
|
||||||
{ secondsToHHMMSS(getConvertedVelocity(value, $velocityUnits, $distanceUnits)) }
|
{secondsToHHMMSS(getConvertedVelocity(value, $velocityUnits, $distanceUnits))}
|
||||||
{ showUnits ? getVelocityUnits($velocityUnits, $distanceUnits) : '' }
|
{showUnits ? getVelocityUnits($velocityUnits, $distanceUnits) : ''}
|
||||||
{/if}
|
{/if}
|
||||||
{:else if type === 'temperature'}
|
{:else if type === 'temperature'}
|
||||||
{#if $temperatureUnits === 'celsius'}
|
{#if $temperatureUnits === 'celsius'}
|
||||||
|
|
@ -43,6 +43,6 @@
|
||||||
{celsiusToFahrenheit(value)} {showUnits ? $_('units.fahrenheit') : ''}
|
{celsiusToFahrenheit(value)} {showUnits ? $_('units.fahrenheit') : ''}
|
||||||
{/if}
|
{/if}
|
||||||
{:else if type === 'time'}
|
{:else if type === 'time'}
|
||||||
{ secondsToHHMMSS(value) }
|
{secondsToHHMMSS(value)}
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -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' | 'nautical',
|
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;
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,10 @@ export function getDistanceUnits(targetDistanceUnits = get(distanceUnits)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getVelocityUnits(targetVelocityUnits = get(velocityUnits), targetDistanceUnits = get(distanceUnits)) {
|
export function getVelocityUnits(
|
||||||
|
targetVelocityUnits = get(velocityUnits),
|
||||||
|
targetDistanceUnits = get(distanceUnits)
|
||||||
|
) {
|
||||||
if (targetVelocityUnits === 'speed') {
|
if (targetVelocityUnits === 'speed') {
|
||||||
switch (targetDistanceUnits) {
|
switch (targetDistanceUnits) {
|
||||||
case 'metric':
|
case 'metric':
|
||||||
|
|
@ -169,7 +172,11 @@ export function getConvertedElevation(value: number, targetDistanceUnits = get(d
|
||||||
return targetDistanceUnits === 'metric' ? value : metersToFeet(value);
|
return targetDistanceUnits === 'metric' ? value : metersToFeet(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getConvertedVelocity(value: number, targetVelocityUnits = get(velocityUnits), targetDistanceUnits = get(distanceUnits)) {
|
export function getConvertedVelocity(
|
||||||
|
value: number,
|
||||||
|
targetVelocityUnits = get(velocityUnits),
|
||||||
|
targetDistanceUnits = get(distanceUnits)
|
||||||
|
) {
|
||||||
if (targetVelocityUnits === 'speed') {
|
if (targetVelocityUnits === 'speed') {
|
||||||
switch (targetDistanceUnits) {
|
switch (targetDistanceUnits) {
|
||||||
case 'metric':
|
case 'metric':
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue