Skip to content

Commit 971a5ca

Browse files
committed
fix: fix export
1 parent 00c3f09 commit 971a5ca

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

alpine-mtb-map.kml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6248,7 +6248,7 @@
62486248
<b>Access</b><table class="access"><tr><th>From</th><th>Transport</th><th>Duration</th></tr><tr><td>Modane</td><td>Bus / car</td><td>~15 min</td></tr><tr><td>Chambery</td><td>Car</td><td>~1h40</td></tr></table><br/>
62496249
<i>Source: <a href="https://guide-ski.fr/valfrejus-ete-2026/">Valfrejus summer 2026 guide</a>. Verify prices, lift and trail status.</i>]]></description>
62506250
<styleUrl>#placemark-blue</styleUrl><Point><coordinates>6.652290,45.172610,1560</coordinates></Point>
6251-
<ExtendedData xmlns:mwm="https://omaps.app"><Data name="spot"><value>valfrejus</value></Data><Data name="tags"><value>beginner expert enduro dh chairlift gondola</value></Data><Data name="open_from"><value>07-04</value></Data><Data name="closed_from"><value>08-30</value></Data><mwm:icon>Mountain</mwm:icon><mwm:visibility>1</mwm:visibility></ExtendedData>
6251+
<ExtendedData xmlns:mwm="https://omaps.app"><Data name="spot"><value>valfrejus</value></Data><Data name="tags"><value>beginner expert natural enduro dh chairlift gondola</value></Data><Data name="open_from"><value>07-04</value></Data><Data name="closed_from"><value>08-30</value></Data><mwm:icon>Mountain</mwm:icon><mwm:visibility>1</mwm:visibility></ExtendedData>
62526252
</Placemark>
62536253
<Placemark>
62546254
<name>Valfrejus: Arrondaz gondola top</name>
@@ -6311,7 +6311,7 @@
63116311
<b>Access</b><table class="access"><tr><th>From</th><th>Transport</th><th>Duration</th></tr><tr><td>Albertville</td><td>Bus / car</td><td>~40 min</td></tr><tr><td>Chambery</td><td>Car</td><td>~1h25</td></tr></table><br/>
63126312
<i>Source: <a href="https://en.areches-beaufort.com/a-faire/vtt-cyclo/">Areches-Beaufort official tourism - mountain biking</a>. Verify prices, lift days and trail status.</i>]]></description>
63136313
<styleUrl>#placemark-blue</styleUrl><Point><coordinates>6.565900,45.685290,1023</coordinates></Point>
6314-
<ExtendedData xmlns:mwm="https://omaps.app"><Data name="spot"><value>areches-beaufort</value></Data><Data name="tags"><value>beginner expert enduro dh freeride no-lift chairlift</value></Data><Data name="open_from"><value>07-04</value></Data><Data name="closed_from"><value>08-30</value></Data><mwm:icon>Mountain</mwm:icon><mwm:visibility>1</mwm:visibility></ExtendedData>
6314+
<ExtendedData xmlns:mwm="https://omaps.app"><Data name="spot"><value>areches-beaufort</value></Data><Data name="tags"><value>beginner expert natural enduro dh freeride no-lift chairlift</value></Data><Data name="open_from"><value>07-04</value></Data><Data name="closed_from"><value>08-30</value></Data><mwm:icon>Mountain</mwm:icon><mwm:visibility>1</mwm:visibility></ExtendedData>
63156315
</Placemark>
63166316
<Placemark>
63176317
<name>Areches-Beaufort: Grand Mont chairlift top</name>
@@ -6478,7 +6478,7 @@
64786478
<b>Access</b><table class="access"><tr><th>From</th><th>Transport</th><th>Duration</th></tr><tr><td>St. Anton (railway station)</td><td>Walk</td><td>~10 min</td></tr><tr><td>Innsbruck</td><td>Train / car</td><td>~1h20</td></tr></table><br/>
64796479
<i>Source: <a href="https://www.skiarlberg.at/en/st-anton/summer/mountain-bike">Ski Arlberg - St. Anton mountain biking</a>. Verify prices, lift and trail status.</i>]]></description>
64806480
<styleUrl>#placemark-blue</styleUrl><Point><coordinates>10.263180,47.126660,1305</coordinates></Point>
6481-
<ExtendedData xmlns:mwm="https://omaps.app"><Data name="spot"><value>st-anton</value></Data><Data name="tags"><value>intermediate expert enduro dh freeride gondola cable-car</value></Data><Data name="open_from"><value>06-13</value></Data><Data name="closed_from"><value>10-04</value></Data><mwm:icon>Mountain</mwm:icon><mwm:visibility>1</mwm:visibility></ExtendedData>
6481+
<ExtendedData xmlns:mwm="https://omaps.app"><Data name="spot"><value>st-anton</value></Data><Data name="tags"><value>intermediate expert natural enduro dh freeride gondola cable-car</value></Data><Data name="open_from"><value>06-13</value></Data><Data name="closed_from"><value>10-04</value></Data><mwm:icon>Mountain</mwm:icon><mwm:visibility>1</mwm:visibility></ExtendedData>
64826482
</Placemark>
64836483
<Placemark>
64846484
<name>St. Anton: Rendlbahn top</name>
@@ -24050,7 +24050,7 @@
2405024050
<b>Access</b><table class="access"><tr><th>From</th><th>Transport</th><th>Duration</th></tr><tr><td>Varallo</td><td>Bus / car</td><td>~45 min</td></tr><tr><td>Milan</td><td>Car</td><td>~2h00</td></tr></table><br/>
2405124051
<i>Source: <a href="https://monterosaski.eu/en/experiences/lift-timetables-and-prices-alagna-valsesia-summer-2026-21492">Monterosa Ski - Alagna Valsesia summer 2026 timetables</a> and <a href="https://www.alagna.it/en/experiences/bike-valsesia-monterosa/">Alagna - Bike Valsesia Monterosa</a>. Verify prices, lift and trail status.</i>]]></description>
2405224052
<styleUrl>#placemark-blue</styleUrl><Point><coordinates>7.935130,45.853290,1214</coordinates></Point>
24053-
<ExtendedData xmlns:mwm="https://omaps.app"><Data name="spot"><value>alagna-valsesia</value></Data><Data name="tags"><value>beginner expert enduro dh freeride gondola cable-car</value></Data><Data name="open_from"><value>05-30</value></Data><Data name="closed_from"><value>09-13</value></Data><mwm:icon>Mountain</mwm:icon><mwm:visibility>1</mwm:visibility></ExtendedData>
24053+
<ExtendedData xmlns:mwm="https://omaps.app"><Data name="spot"><value>alagna-valsesia</value></Data><Data name="tags"><value>beginner expert natural enduro dh freeride gondola cable-car</value></Data><Data name="open_from"><value>05-30</value></Data><Data name="closed_from"><value>09-13</value></Data><mwm:icon>Mountain</mwm:icon><mwm:visibility>1</mwm:visibility></ExtendedData>
2405424054
</Placemark>
2405524055
<Placemark>
2405624056
<name>Alagna Valsesia: Pianalunga mid-station</name>

scripts/export.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ const spotTypes = ["bike-park", "natural"];
3232
// grey waypoint or a trail line.
3333
const mainKinds = new Set(["bike-park", "natural", "no-lift"]);
3434
const spotTags = new Map<string, Set<string>>();
35-
const mainSpots = new Map<string, string>();
35+
// The spot type is read from the main placemark when it declares one: a bike
36+
// park can hold a natural trace (a backcountry line off the same lift) without
37+
// stopping being a bike park. Only a main pin that declares neither falls back
38+
// to the union of the spot's tags, which then has to be unambiguous.
39+
const mainSpots = new Map<string, { name: string; tags: Set<string> }>();
3640
for (const pm of doc.getElementsByTagName("Placemark")) {
3741
const data = [...pm.getElementsByTagName("Data")];
3842
const facet = (name: string) =>
@@ -43,16 +47,25 @@ for (const pm of doc.getElementsByTagName("Placemark")) {
4347
const tags = spotTags.get(spot) ?? new Set();
4448
for (const tag of facet("tags").split(/\s+/).filter(Boolean)) tags.add(tag);
4549
spotTags.set(spot, tags);
46-
if (mainKinds.has(kind) && /\[.+\]$/.test(name)) mainSpots.set(spot, name);
50+
if (mainKinds.has(kind) && /\[.+\]$/.test(name)) {
51+
mainSpots.set(spot, {
52+
name,
53+
tags: new Set(facet("tags").split(/\s+/).filter(Boolean)),
54+
});
55+
}
4756
}
48-
for (const [spot, name] of mainSpots) {
57+
for (const [spot, main] of mainSpots) {
4958
const tags = spotTags.get(spot);
50-
if (spotTypes.filter((tag) => tags?.has(tag)).length !== 1) {
51-
throw new Error(`${name} needs exactly one of: ${spotTypes.join(", ")}`);
59+
const declared = spotTypes.filter((tag) => main.tags.has(tag));
60+
if (
61+
declared.length > 1 ||
62+
(!declared.length && spotTypes.filter((tag) => tags?.has(tag)).length !== 1)
63+
) {
64+
throw new Error(`${main.name} needs exactly one of: ${spotTypes.join(", ")}`);
5265
}
5366
for (const group of requiredGroups) {
5467
if (!group.some((tag) => tags?.has(tag))) {
55-
throw new Error(`${name} needs at least one of: ${group.join(", ")}`);
68+
throw new Error(`${main.name} needs at least one of: ${group.join(", ")}`);
5669
}
5770
}
5871
}

0 commit comments

Comments
 (0)