@jjlmoya/utils-travel 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +59 -58
- package/src/category/i18n/de.ts +185 -0
- package/src/category/i18n/fr.ts +86 -1
- package/src/category/i18n/id.ts +185 -0
- package/src/category/i18n/it.ts +185 -0
- package/src/category/i18n/ja.ts +181 -0
- package/src/category/i18n/ko.ts +181 -0
- package/src/category/i18n/nl.ts +185 -0
- package/src/category/i18n/pl.ts +181 -0
- package/src/category/i18n/pt.ts +181 -0
- package/src/category/i18n/ru.ts +181 -0
- package/src/category/i18n/sv.ts +181 -0
- package/src/category/i18n/tr.ts +181 -0
- package/src/category/i18n/zh.ts +181 -0
- package/src/category/index.ts +13 -1
- package/src/tests/i18n_coverage.test.ts +36 -0
- package/src/tests/locale_completeness.test.ts +24 -3
- package/src/tests/no_h1_in_components.test.ts +42 -2
- package/src/tests/schemas_fulfillment.test.ts +23 -0
- package/src/tests/slug_uniqueness.test.ts +81 -0
- package/src/tests/title_quality.test.ts +55 -0
- package/src/tool/luggage-calculator/i18n/de.ts +616 -0
- package/src/tool/luggage-calculator/i18n/en.ts +2 -2
- package/src/tool/luggage-calculator/i18n/id.ts +616 -0
- package/src/tool/luggage-calculator/i18n/it.ts +616 -0
- package/src/tool/luggage-calculator/i18n/ja.ts +616 -0
- package/src/tool/luggage-calculator/i18n/ko.ts +616 -0
- package/src/tool/luggage-calculator/i18n/nl.ts +616 -0
- package/src/tool/luggage-calculator/i18n/pl.ts +616 -0
- package/src/tool/luggage-calculator/i18n/pt.ts +616 -0
- package/src/tool/luggage-calculator/i18n/ru.ts +616 -0
- package/src/tool/luggage-calculator/i18n/sv.ts +616 -0
- package/src/tool/luggage-calculator/i18n/tr.ts +616 -0
- package/src/tool/luggage-calculator/i18n/zh.ts +616 -0
- package/src/tool/luggage-calculator/index.ts +13 -1
- package/src/tool/mini-adventures/i18n/de.ts +161 -0
- package/src/tool/mini-adventures/i18n/en.ts +1 -1
- package/src/tool/mini-adventures/i18n/es.ts +1 -1
- package/src/tool/mini-adventures/i18n/id.ts +161 -0
- package/src/tool/mini-adventures/i18n/it.ts +161 -0
- package/src/tool/mini-adventures/i18n/ja.ts +161 -0
- package/src/tool/mini-adventures/i18n/ko.ts +161 -0
- package/src/tool/mini-adventures/i18n/nl.ts +161 -0
- package/src/tool/mini-adventures/i18n/pl.ts +161 -0
- package/src/tool/mini-adventures/i18n/pt.ts +161 -0
- package/src/tool/mini-adventures/i18n/ru.ts +161 -0
- package/src/tool/mini-adventures/i18n/sv.ts +161 -0
- package/src/tool/mini-adventures/i18n/tr.ts +161 -0
- package/src/tool/mini-adventures/i18n/zh.ts +161 -0
- package/src/tool/mini-adventures/index.ts +13 -1
- package/src/tool/suitcase-checklist/i18n/de.ts +261 -0
- package/src/tool/suitcase-checklist/i18n/en.ts +1 -1
- package/src/tool/suitcase-checklist/i18n/es.ts +1 -1
- package/src/tool/suitcase-checklist/i18n/fr.ts +1 -1
- package/src/tool/suitcase-checklist/i18n/id.ts +261 -0
- package/src/tool/suitcase-checklist/i18n/it.ts +261 -0
- package/src/tool/suitcase-checklist/i18n/ja.ts +261 -0
- package/src/tool/suitcase-checklist/i18n/ko.ts +261 -0
- package/src/tool/suitcase-checklist/i18n/nl.ts +261 -0
- package/src/tool/suitcase-checklist/i18n/pl.ts +261 -0
- package/src/tool/suitcase-checklist/i18n/pt.ts +261 -0
- package/src/tool/suitcase-checklist/i18n/ru.ts +261 -0
- package/src/tool/suitcase-checklist/i18n/sv.ts +261 -0
- package/src/tool/suitcase-checklist/i18n/tr.ts +261 -0
- package/src/tool/suitcase-checklist/i18n/zh.ts +261 -0
- package/src/tool/suitcase-checklist/index.ts +13 -1
- package/src/tool/tip-calculator/i18n/de.ts +264 -0
- package/src/tool/tip-calculator/i18n/id.ts +264 -0
- package/src/tool/tip-calculator/i18n/it.ts +264 -0
- package/src/tool/tip-calculator/i18n/ja.ts +264 -0
- package/src/tool/tip-calculator/i18n/ko.ts +264 -0
- package/src/tool/tip-calculator/i18n/nl.ts +264 -0
- package/src/tool/tip-calculator/i18n/pl.ts +264 -0
- package/src/tool/tip-calculator/i18n/pt.ts +264 -0
- package/src/tool/tip-calculator/i18n/ru.ts +264 -0
- package/src/tool/tip-calculator/i18n/sv.ts +264 -0
- package/src/tool/tip-calculator/i18n/tr.ts +264 -0
- package/src/tool/tip-calculator/i18n/zh.ts +264 -0
- package/src/tool/tip-calculator/index.ts +13 -1
- package/src/tool/optimal-routes/bibliography.astro +0 -14
- package/src/tool/optimal-routes/component.astro +0 -439
- package/src/tool/optimal-routes/i18n/en.ts +0 -42
- package/src/tool/optimal-routes/i18n/es.ts +0 -52
- package/src/tool/optimal-routes/index.ts +0 -63
- package/src/tool/optimal-routes/lib/RouteManager.ts +0 -181
- package/src/tool/optimal-routes/seo.astro +0 -14
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
export interface RoutePoint {
|
|
2
|
-
id: number;
|
|
3
|
-
lat: number;
|
|
4
|
-
lng: number;
|
|
5
|
-
marker: unknown;
|
|
6
|
-
name: string;
|
|
7
|
-
address?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export class RouteManager extends EventTarget {
|
|
11
|
-
private map: unknown = null;
|
|
12
|
-
private points: RoutePoint[] = [];
|
|
13
|
-
private routeLine: unknown = null;
|
|
14
|
-
private L: unknown = null;
|
|
15
|
-
|
|
16
|
-
constructor(L: unknown) {
|
|
17
|
-
super();
|
|
18
|
-
this.L = L;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
initMap(elementId: string) {
|
|
22
|
-
const el = document.getElementById(elementId);
|
|
23
|
-
if (!el || !this.L) return;
|
|
24
|
-
|
|
25
|
-
this.map = this.L.map(elementId).setView([40.416775, -3.70379], 6);
|
|
26
|
-
|
|
27
|
-
this.L.tileLayer("https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png", {
|
|
28
|
-
attribution: '© OpenStreetMap © CARTO',
|
|
29
|
-
subdomains: "abcd",
|
|
30
|
-
maxZoom: 20,
|
|
31
|
-
}).addTo(this.map);
|
|
32
|
-
|
|
33
|
-
this.map.on("click", (e: unknown) => {
|
|
34
|
-
this.addPoint(e.latlng.lat, e.latlng.lng);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
if ("geolocation" in navigator) {
|
|
38
|
-
navigator.geolocation.getCurrentPosition((pos) => {
|
|
39
|
-
this.map?.setView([pos.coords.latitude, pos.coords.longitude], 13);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private getNumberedIcon(num: number) {
|
|
45
|
-
return this.L.divIcon({
|
|
46
|
-
className: "ma-number-icon-container",
|
|
47
|
-
html: `<div class="ma-number-icon">${num}</div>`,
|
|
48
|
-
iconSize: [30, 30],
|
|
49
|
-
iconAnchor: [15, 30]
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async addPoint(lat: number, lng: number) {
|
|
54
|
-
if (!this.map) return;
|
|
55
|
-
|
|
56
|
-
const id = Date.now();
|
|
57
|
-
const index = this.points.length + 1;
|
|
58
|
-
|
|
59
|
-
const marker = this.L.marker([lat, lng], {
|
|
60
|
-
draggable: true,
|
|
61
|
-
icon: this.getNumberedIcon(index)
|
|
62
|
-
}).addTo(this.map);
|
|
63
|
-
|
|
64
|
-
const point: RoutePoint = { id, lat, lng, marker, name: `Punto ${index}`, address: "..." };
|
|
65
|
-
this.points.push(point);
|
|
66
|
-
|
|
67
|
-
this.notifyUpdate();
|
|
68
|
-
|
|
69
|
-
marker.on("dragend", () => {
|
|
70
|
-
const newPos = marker.getLatLng();
|
|
71
|
-
point.lat = newPos.lat;
|
|
72
|
-
point.lng = newPos.lng;
|
|
73
|
-
this.clearRoute();
|
|
74
|
-
this.updateAddress(point);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
await this.updateAddress(point);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private async updateAddress(point: RoutePoint) {
|
|
81
|
-
try {
|
|
82
|
-
const res = await fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${point.lat}&lon=${point.lng}&zoom=18&addressdetails=1`, {
|
|
83
|
-
headers: { "User-Agent": "RutasApp/1.0" }
|
|
84
|
-
});
|
|
85
|
-
const data = await res.json();
|
|
86
|
-
point.address = data.display_name.split(",")[0] || "Punto";
|
|
87
|
-
point.name = point.address as string;
|
|
88
|
-
this.notifyUpdate();
|
|
89
|
-
} catch {
|
|
90
|
-
point.address = "Desconocido";
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
deletePoint(id: number) {
|
|
95
|
-
const idx = this.points.findIndex(p => p.id === id);
|
|
96
|
-
if (idx !== -1) {
|
|
97
|
-
this.map?.removeLayer(this.points[idx].marker);
|
|
98
|
-
this.points.splice(idx, 1);
|
|
99
|
-
this.updateAllMarkers();
|
|
100
|
-
this.clearRoute();
|
|
101
|
-
this.notifyUpdate();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
private updateAllMarkers() {
|
|
106
|
-
this.points.forEach((p, i) => {
|
|
107
|
-
p.marker.setIcon(this.getNumberedIcon(i + 1));
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
private findLongestLegIndex(legs: unknown[]): number {
|
|
112
|
-
let maxIdx = -1;
|
|
113
|
-
let maxDist = -1;
|
|
114
|
-
(legs as Array<{ distance: number }>).forEach((l, i) => {
|
|
115
|
-
if (l.distance > maxDist) { maxDist = l.distance; maxIdx = i; }
|
|
116
|
-
});
|
|
117
|
-
return maxIdx;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
clearAll() {
|
|
121
|
-
this.points.forEach(p => this.map?.removeLayer(p.marker));
|
|
122
|
-
this.points = [];
|
|
123
|
-
this.clearRoute();
|
|
124
|
-
this.notifyUpdate();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
private clearRoute() {
|
|
128
|
-
if (this.routeLine && this.map) {
|
|
129
|
-
this.map.removeLayer(this.routeLine);
|
|
130
|
-
this.routeLine = null;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async optimizeRoute() {
|
|
135
|
-
if (this.points.length < 2) return;
|
|
136
|
-
this.dispatchEvent(new CustomEvent("loading", { detail: true }));
|
|
137
|
-
|
|
138
|
-
try {
|
|
139
|
-
const coords = this.points.map(p => `${p.lng},${p.lat}`).join(";");
|
|
140
|
-
const res = await fetch(`https://router.project-osrm.org/trip/v1/driving/${coords}?source=any&roundtrip=true&geometries=geojson&overview=full`);
|
|
141
|
-
const data = await res.json();
|
|
142
|
-
|
|
143
|
-
if (data.code !== "Ok") throw new Error();
|
|
144
|
-
|
|
145
|
-
const waypoints = data.waypoints;
|
|
146
|
-
const loopPoints = waypoints.map((wp: unknown) => this.points[wp.waypoint_index]);
|
|
147
|
-
|
|
148
|
-
const legs = data.trips[0].legs;
|
|
149
|
-
const maxIdx = this.findLongestLegIndex(legs);
|
|
150
|
-
const startIdx = (maxIdx + 1) % loopPoints.length;
|
|
151
|
-
this.points = [...loopPoints.slice(startIdx), ...loopPoints.slice(0, startIdx)];
|
|
152
|
-
|
|
153
|
-
this.updateAllMarkers();
|
|
154
|
-
this.notifyUpdate();
|
|
155
|
-
|
|
156
|
-
const routeRes = await fetch(`https://router.project-osrm.org/route/v1/driving/${this.points.map(p => `${p.lng},${p.lat}`).join(";")}?geometries=geojson&overview=full`);
|
|
157
|
-
const routeData = await routeRes.json();
|
|
158
|
-
|
|
159
|
-
this.clearRoute();
|
|
160
|
-
this.routeLine = this.L.geoJSON(routeData.routes[0].geometry, {
|
|
161
|
-
style: { color: "#0891b2", weight: 5, opacity: 0.8 }
|
|
162
|
-
}).addTo(this.map);
|
|
163
|
-
|
|
164
|
-
this.map?.fitBounds(this.routeLine.getBounds(), { padding: [50, 50] });
|
|
165
|
-
this.dispatchEvent(new CustomEvent("done", { detail: routeData.routes[0] }));
|
|
166
|
-
} catch {
|
|
167
|
-
this.dispatchEvent(new CustomEvent("error"));
|
|
168
|
-
} finally {
|
|
169
|
-
this.dispatchEvent(new CustomEvent("loading", { detail: false }));
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
panToPoint(id: number) {
|
|
174
|
-
const p = this.points.find(p => p.id === id);
|
|
175
|
-
if (p && this.map) this.map.flyTo([p.lat, p.lng], 16);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
private notifyUpdate() {
|
|
179
|
-
this.dispatchEvent(new CustomEvent("update", { detail: this.points }));
|
|
180
|
-
}
|
|
181
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import { SEORenderer } from "@jjlmoya/utils-shared";
|
|
3
|
-
import { optimalRoutes } from "./index";
|
|
4
|
-
import type { KnownLocale } from "../../types";
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
locale?: KnownLocale;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const { locale = "es" } = Astro.props;
|
|
11
|
-
const content = await optimalRoutes.i18n[locale]?.();
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
{content && <SEORenderer content={{ locale, sections: content.seo }} />}
|