feat(new tool): Geo Distance Computer

Fix part of #1416
This commit is contained in:
sharevb authored and ShareVB committed 2025-01-26 21:37:23 +01:00
1 parent 3a272f60c9
commit fcee9d88a8
6 files changed
+583 -514

No files matched your search

+2
View File
@@ -126,6 +126,7 @@ declare module '@vue/runtime-core' {
FolderStructureDiagram: typeof import('./src/tools/folder-structure-diagram/folder-structure-diagram.vue')['default']
ForceConverter: typeof import('./src/tools/force-converter/force-converter.vue')['default']
FormatTransformer: typeof import('./src/components/FormatTransformer.vue')['default']
GeoDistanceCalculator: typeof import('./src/tools/geo-distance-calculator/geo-distance-calculator.vue')['default']
GitMemo: typeof import('./src/tools/git-memo/git-memo.vue')['default']
'GitMemo.content': typeof import('./src/tools/git-memo/git-memo.content.md')['default']
GzipConverter: typeof import('./src/tools/gzip-converter/gzip-converter.vue')['default']
@@ -251,6 +252,7 @@ declare module '@vue/runtime-core' {
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
+2
View File
@@ -62,6 +62,7 @@
"@tiptap/pm": "2.9.1",
"@tiptap/starter-kit": "2.9.1",
"@tiptap/vue-3": "2.9.1",
"@types/haversine": "^1.1.8",
"@unicode/unicode-15.1.0": "^1.6.0",
"@vicons/material": "^0.12.0",
"@vicons/tabler": "^0.12.0",
@@ -122,6 +123,7 @@
"generate-schema": "^2.6.0",
"get-timezone-offset": "^1.0.5",
"hash-wasm": "^4.11.0",
"haversine": "^1.1.1",
"heic-convert": "^2.1.0",
"highlight.js": "^11.7.0",
"iarna-toml-esm": "^3.0.5",
+483 -513
View File
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,80 @@
<script setup lang="ts">
import haversine from 'haversine';
import SpanCopyable from '@/components/SpanCopyable.vue';
import { useQueryParamOrStorage } from '@/composable/queryParams';
const latitude1 = useQueryParamOrStorage({ name: 'lat1', storageName: 'geo-dist:lat1', defaultValue: 0 });
const longitude1 = useQueryParamOrStorage({ name: 'lng1', storageName: 'geo-dist:lng1', defaultValue: 0 });
const latitude2 = useQueryParamOrStorage({ name: 'lat2', storageName: 'geo-dist:lat2', defaultValue: 0 });
const longitude2 = useQueryParamOrStorage({ name: 'lng2', storageName: 'geo-dist:lng2', defaultValue: 0 });
const start = computed(() => ({ latitude: latitude1.value, longitude: longitude1.value }));
const end = computed(() => ({ latitude: latitude2.value, longitude: longitude2.value }));
const { coords: userCoords } = useGeolocation();
const distanceKM = computed(() => haversine(start.value, end.value, { unit: 'km' }));
const distanceMeter = computed(() => haversine(start.value, end.value, { unit: 'meter' }));
const distanceMile = computed(() => haversine(start.value, end.value, { unit: 'mile' }));
const distanceNMI = computed(() => haversine(start.value, end.value, { unit: 'nmi' }));
</script>
<template>
<div>
<c-card title="Distance computer" mb-2>
<n-form-item label="Geolocation 1 (latitude, longitude):">
<n-space justify="space-between">
<n-input-number v-model:value="latitude1" :min="-90" :max="90" placeholder="Latitude..." />
<n-input-number v-model:value="longitude1" :min="-180" :max="180" placeholder="Longitude..." />
</n-space>
</n-form-item>
<n-form-item label="Geolocation 2 (latitude, longitude):" gap-2>
<n-space justify="space-between">
<n-input-number v-model:value="latitude2" :min="-90" :max="90" placeholder="Latitude..." />
<n-input-number v-model:value="longitude2" :min="-180" :max="180" placeholder="Longitude..." />
</n-space>
</n-form-item>
<n-divider />
<n-form-item label="Distance (km):" label-width="120px" label-placement="left">
<SpanCopyable :value="distanceKM.toString()" />
</n-form-item>
<n-form-item label="Distance (mile):" label-width="120px" label-placement="left">
<SpanCopyable :value="distanceMile.toString()" />
</n-form-item>
<n-form-item label="Distance (meter):" label-width="120px" label-placement="left">
<SpanCopyable :value="distanceMeter.toString()" />
</n-form-item>
<n-form-item label="Distance (nmi):" label-width="120px" label-placement="left">
<SpanCopyable :value="distanceNMI.toString()" />
</n-form-item>
</c-card>
<c-card title="Your position">
<n-space justify="center">
<n-form-item label="Latitude:" label-placement="left">
<SpanCopyable :value="userCoords?.latitude?.toString() || 'Unknown'" />
</n-form-item>
<n-form-item label="Longitude:" label-placement="left">
<SpanCopyable :value="userCoords?.longitude?.toString() || 'Unknown'" />
</n-form-item>
</n-space>
<n-space justify="center">
<n-form-item label="Altitude:" label-placement="left">
<SpanCopyable :value="userCoords?.altitude?.toString() || 'Unknown'" />
</n-form-item>
<n-form-item label="Heading:" label-placement="left">
<SpanCopyable :value="userCoords?.heading?.toString() || 'Unknown'" />
</n-form-item>
<n-form-item label="Speed:" label-placement="left">
<SpanCopyable :value="userCoords?.speed?.toString() || 'Unknown'" />
</n-form-item>
<n-form-item label="Accuracy:" label-placement="left">
<SpanCopyable :value="userCoords?.accuracy?.toString() || 'Unknown'" />
</n-form-item>
</n-space>
</c-card>
</div>
</template>
@@ -0,0 +1,12 @@
import { WorldLatitude } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Geo distance calculator',
path: '/geo-distance-calculator',
description: 'Compute distance between two geo location (and display current user location information)',
keywords: ['geo', 'distance', 'calculator'],
component: () => import('./geo-distance-calculator.vue'),
icon: WorldLatitude,
createdAt: new Date('2025-01-01'),
});
+4 -1
View File
@@ -25,6 +25,7 @@ import { tool as angleConverter } from './angle-converter';
import { tool as floatingPointNumberConverter } from './floating-point-number-converter';
import { tool as snowflakeIdExtractor } from './snowflake-id-extractor';
import { tool as emailNormalizer } from './email-normalizer';
import { tool as geoDistanceCalculator } from './geo-distance-calculator';
import { tool as xVrSpamcauseDecoder } from './x-vr-spamcause-decoder';
import { tool as bounceParser } from './bounce-parser';
import { tool as codeHighlighter } from './code-highlighter';
@@ -505,7 +506,8 @@ export const toolsByCategory: ToolCategory[] = [
ttlCalculator,
percentageCalculator,
angleConverter,
percentageCalculator],
percentageCalculator,
],
},
{
name: 'Measurement',
@@ -527,6 +529,7 @@ export const toolsByCategory: ToolCategory[] = [
powerConverter,
energyComputer,
benchmarkBuilder,
geoDistanceCalculator,
],
},
{