openskidata-format 7.0.0 → 8.0.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/dist/ElevationProfile.js +35 -37
- package/dist/ElevationProfile.js.map +1 -1
- package/dist/FeatureType.d.ts +2 -1
- package/dist/FeatureType.js +1 -0
- package/dist/FeatureType.js.map +1 -1
- package/dist/Run.d.ts +4 -0
- package/dist/Run.js.map +1 -1
- package/dist/Spot.d.ts +110 -0
- package/dist/Spot.js +33 -0
- package/dist/Spot.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/ElevationProfile.test.ts +6 -0
- package/src/ElevationProfile.ts +42 -45
- package/src/FeatureType.ts +1 -0
- package/src/Run.ts +4 -0
- package/src/SlopeGradingScale.test.ts +8 -0
- package/src/Spot.ts +128 -0
- package/src/index.ts +1 -0
package/dist/ElevationProfile.js
CHANGED
|
@@ -48,6 +48,11 @@ function getPitchData(profileGeometry, resolutionInMeters = 25) {
|
|
|
48
48
|
const chunkedGeometries = (0, line_chunk_1.lineChunk)(profileGeometry, resolutionInMeters, {
|
|
49
49
|
units: 'meters',
|
|
50
50
|
}).features.map((feature) => feature.geometry);
|
|
51
|
+
// turf 7.3+ adds Z coordinates to newly created points using segment-end elevation,
|
|
52
|
+
// but we need distance-based interpolation. Strip Z from non-original vertices so
|
|
53
|
+
// interpolateElevation can add them correctly.
|
|
54
|
+
// https://github.com/Turfjs/turf/issues/3007
|
|
55
|
+
stripNonOriginalElevations(chunkedGeometries, coordinates);
|
|
51
56
|
// Mutates the geometries in place to add elevation data
|
|
52
57
|
interpolateElevation(chunkedGeometries);
|
|
53
58
|
// Initialize max pitch values
|
|
@@ -88,50 +93,32 @@ function getPitchData(profileGeometry, resolutionInMeters = 25) {
|
|
|
88
93
|
};
|
|
89
94
|
}
|
|
90
95
|
function getProfileGeometry(geometry, elevationProfile) {
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
for (let subline of geometries) {
|
|
94
|
-
const firstPoint = subline.coordinates[0];
|
|
95
|
-
if (firstPoint.length === 2) {
|
|
96
|
-
firstPoint.push(elevationProfile.heights[index]);
|
|
97
|
-
}
|
|
98
|
-
index++;
|
|
99
|
-
if (index === elevationProfile.heights.length) {
|
|
100
|
-
throw 'Mismatch of points & elevation profile.';
|
|
101
|
-
}
|
|
102
|
-
const lastPoint = subline.coordinates[subline.coordinates.length - 1];
|
|
103
|
-
if (lastPoint.length === 2) {
|
|
104
|
-
lastPoint.push(elevationProfile.heights[index]);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (index !== elevationProfile.heights.length - 1) {
|
|
96
|
+
const profileLine = extractPointsForElevationProfile(geometry, elevationProfile.resolution);
|
|
97
|
+
if (profileLine.coordinates.length !== elevationProfile.heights.length) {
|
|
108
98
|
throw `Mismatch of points & elevation profile`;
|
|
109
99
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
throw 'All points should have an elevation at this point.';
|
|
115
|
-
}
|
|
116
|
-
}
|
|
100
|
+
for (let i = 0; i < profileLine.coordinates.length; i++) {
|
|
101
|
+
const point = profileLine.coordinates[i];
|
|
102
|
+
const height = elevationProfile.heights[i];
|
|
103
|
+
point.push(height);
|
|
117
104
|
}
|
|
118
|
-
return
|
|
119
|
-
type: 'LineString',
|
|
120
|
-
coordinates: geometries.flatMap((geometry) => geometry.coordinates),
|
|
121
|
-
};
|
|
105
|
+
return profileLine;
|
|
122
106
|
}
|
|
123
107
|
/**
|
|
124
108
|
* Determines the points to use for an elevation profile.
|
|
125
109
|
*/
|
|
126
110
|
function extractPointsForElevationProfile(geometry, resolution) {
|
|
127
|
-
|
|
111
|
+
// Important: Z coordinates in the output of lineChunk may be incorrect, ignore them (https://github.com/Turfjs/turf/issues/3007)
|
|
112
|
+
const lineChunks = (0, line_chunk_1.lineChunk)(geometry, resolution, {
|
|
113
|
+
units: 'meters',
|
|
114
|
+
}).features.map((feature) => feature.geometry);
|
|
128
115
|
const points = [];
|
|
129
|
-
for (let subline of
|
|
116
|
+
for (let subline of lineChunks) {
|
|
130
117
|
const point = subline.coordinates[0];
|
|
131
118
|
points.push([point[0], point[1]]);
|
|
132
119
|
}
|
|
133
|
-
if (
|
|
134
|
-
const geometry =
|
|
120
|
+
if (lineChunks.length > 0) {
|
|
121
|
+
const geometry = lineChunks[lineChunks.length - 1];
|
|
135
122
|
const coords = geometry.coordinates;
|
|
136
123
|
if (coords.length > 1) {
|
|
137
124
|
const point = coords[coords.length - 1];
|
|
@@ -143,11 +130,6 @@ function extractPointsForElevationProfile(geometry, resolution) {
|
|
|
143
130
|
coordinates: points,
|
|
144
131
|
};
|
|
145
132
|
}
|
|
146
|
-
function lineChunksForElevationProfile(geometry, resolution) {
|
|
147
|
-
return (0, line_chunk_1.lineChunk)(geometry, resolution, {
|
|
148
|
-
units: 'meters',
|
|
149
|
-
}).features.map((feature) => feature.geometry);
|
|
150
|
-
}
|
|
151
133
|
function getAscentAndDescent(profileGeometry) {
|
|
152
134
|
const coordinates = profileGeometry.coordinates;
|
|
153
135
|
if (coordinates.length === 0) {
|
|
@@ -186,6 +168,22 @@ function getAscentAndDescent(profileGeometry) {
|
|
|
186
168
|
verticalInMeters: result.maxElevation - result.minElevation,
|
|
187
169
|
};
|
|
188
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Strip Z coordinates from points that were created by lineChunk (not original vertices).
|
|
173
|
+
* Original vertices are identified by matching lon/lat coordinates.
|
|
174
|
+
* Mutates the geometries in place.
|
|
175
|
+
*/
|
|
176
|
+
function stripNonOriginalElevations(geometries, originalCoordinates) {
|
|
177
|
+
const originalSet = new Set(originalCoordinates.map((c) => `${c[0]},${c[1]}`));
|
|
178
|
+
for (const geometry of geometries) {
|
|
179
|
+
for (const point of geometry.coordinates) {
|
|
180
|
+
const key = `${point[0]},${point[1]}`;
|
|
181
|
+
if (!originalSet.has(key) && point.length >= 3) {
|
|
182
|
+
point.length = 2;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
189
187
|
/**
|
|
190
188
|
* Interpolate elevation for points along a list of linestrings that don't already have elevation.
|
|
191
189
|
* Uses geographic distances for proper interpolation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElevationProfile.js","sourceRoot":"","sources":["../src/ElevationProfile.ts"],"names":[],"mappings":";;AAyCA,4CAQC;AAED,
|
|
1
|
+
{"version":3,"file":"ElevationProfile.js","sourceRoot":"","sources":["../src/ElevationProfile.ts"],"names":[],"mappings":";;AAyCA,4CAQC;AAED,oCAmGC;AAED,gDAmBC;AAKD,4EA2BC;AAED,kDAiDC;;AA9PD,sEAAqC;AACrC,kEAAiC;AACjC,iDAA4C;AAuC5C,SAAgB,gBAAgB,CAC9B,eAAmC;IAEnC,OAAO;QACL,GAAG,mBAAmB,CAAC,eAAe,CAAC;QACvC,GAAG,YAAY,CAAC,eAAe,CAAC;QAChC,eAAe;KAChB,CAAA;AACH,CAAC;AAED,SAAgB,YAAY,CAC1B,eAAmC,EACnC,qBAA6B,EAAE;IAE/B,MAAM,WAAW,GAAG,eAAe,CAAC,WAAW,CAAA;IAC/C,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,MAAM,+CAA+C,CAAA;IACvD,CAAC;IAED,+DAA+D;IAC/D,IAAI,WAAW,GAAG,CAAC,CAAA;IACnB,IAAI,mBAAmB,GAAG,CAAC,CAAA;IAC3B,IAAI,oBAAoB,GAAG,CAAC,CAAA;IAE5B,2DAA2D;IAC3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAChD,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;QAC7B,MAAM,KAAK,GAAG,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,CAAA;YACzD,CAAC;YAED,wEAAwE;YACxE,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;QAC7C,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/FeatureType.d.ts
CHANGED
package/dist/FeatureType.js
CHANGED
package/dist/FeatureType.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureType.js","sourceRoot":"","sources":["../src/FeatureType.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"FeatureType.js","sourceRoot":"","sources":["../src/FeatureType.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,0BAAW,CAAA;IACX,4BAAa,CAAA;IACb,kCAAmB,CAAA;IACnB,4BAAa,CAAA;AACf,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB"}
|
package/dist/Run.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ export type RunFeature = GeoJSON.Feature<RunGeometry, RunProperties>;
|
|
|
42
42
|
* @property {boolean | null} lit - Whether the run has lighting for night skiing, derived from the OpenStreetMap "piste:lit" or "lit" tag.
|
|
43
43
|
* @property {boolean | null} gladed - Whether the run is through gladed/tree terrain, derived from the OpenStreetMap "piste:gladed" or "gladed" tag.
|
|
44
44
|
* @property {boolean | null} patrolled - Whether the run is patrolled by ski patrol, derived from the OpenStreetMap "piste:patrolled" or "patrolled" tag.
|
|
45
|
+
* @property {boolean | null} snowmaking - Whether the run has its operation secured through snowmaking, derived from the OpenStreetMap "piste:snowmaking" tag.
|
|
46
|
+
* @property {boolean | null} snowfarming - Whether the run has its early season operation secured through snowfarming (storing snow from previous season), derived from the OpenStreetMap "piste:snowfarming" tag.
|
|
45
47
|
* @property {RunGrooming | null} grooming - Grooming status/type of the run, derived from the OpenStreetMap "piste:grooming" tag. If not specified explicitly, for difficulties "expert", "freeride", and "extreme", grooming is assumed to be "backcountry".
|
|
46
48
|
* @property {SkiAreaSummaryFeature[]} skiAreas - Ski areas this run belongs to. Derived from the OpenStreetMap site=piste relation or landuse=winter_sports area and proximity to ski area features. Runs with "backcountry" grooming are not associated with ski areas unless they have a "piste:patrolled=yes" or "patrolled=yes" OpenStreetMap tag, or are part of a "site=piste" ski area relation.
|
|
47
49
|
* @property {ElevationProfile | null} elevationProfile - Elevation profile of the run, only available for runs with LineString geometry.
|
|
@@ -65,6 +67,8 @@ export type RunProperties = {
|
|
|
65
67
|
lit: boolean | null;
|
|
66
68
|
gladed: boolean | null;
|
|
67
69
|
patrolled: boolean | null;
|
|
70
|
+
snowmaking: boolean | null;
|
|
71
|
+
snowfarming: boolean | null;
|
|
68
72
|
grooming: RunGrooming | null;
|
|
69
73
|
skiAreas: SkiAreaSummaryFeature[];
|
|
70
74
|
elevationProfile: ElevationProfile | null;
|
package/dist/Run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Run.js","sourceRoot":"","sources":["../src/Run.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Run.js","sourceRoot":"","sources":["../src/Run.ts"],"names":[],"mappings":";;;AA8IA,kDAUC;AAED,kCAKC;AAED,kDAiBC;AAED,0CAyDC;AA5OD,yDAK2B;AAG3B,uEAAmE;AAKnE,4EAAwE;AA4ExE,IAAY,MAYX;AAZD,WAAY,MAAM;IAChB,+BAAqB,CAAA;IACrB,2BAAiB,CAAA;IACjB,6BAAmB,CAAA;IACnB,uBAAa,CAAA;IACb,uBAAa,CAAA;IACb,2BAAiB,CAAA;IACjB,gCAAsB,CAAA;IACtB,gCAAsB,CAAA;IACtB,mCAAyB,CAAA;IACzB,mCAAyB,CAAA;IACzB,6BAAmB,CAAA;AACrB,CAAC,EAZW,MAAM,sBAAN,MAAM,QAYjB;AAED,IAAY,WAOX;AAPD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,8BAAe,CAAA;IACf,oDAAqC,CAAA;IACrC,kCAAmB,CAAA;IACnB,k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,CAAC;gBACnB,KAAK,aAAa,CAAC,MAAM,CAAC;gBAC1B,KAAK,aAAa,CAAC,IAAI;oBACrB,OAAO,YAAY,CAAC,KAAK,CAAA;gBAC3B,KAAK,aAAa,CAAC,YAAY;oBAC7B,OAAO,YAAY,CAAC,GAAG,CAAA;gBACzB,KAAK,aAAa,CAAC,QAAQ,CAAC;gBAC5B,KAAK,aAAa,CAAC,MAAM;oBACvB,OAAO,YAAY,CAAC,KAAK,CAAA;gBAC3B,KAAK,aAAa,CAAC,QAAQ,CAAC;gBAC5B,KAAK,aAAa,CAAC,OAAO;oBACxB,OAAO,YAAY,CAAC,MAAM,CAAA;gBAC5B;oBACE,OAAO,YAAY,CAAC,IAAI,CAAA;YAC5B,CAAC;QACH,KAAK,iDAAuB,CAAC,aAAa;YACxC,QAAQ,UAAU,EAAE,CAAC;gBACnB,KAAK,aAAa,CAAC,MAAM,CAAC;gBAC1B,KAAK,aAAa,CAAC,IAAI;oBACrB,OAAO,YAAY,CAAC,KAAK,CAAA;gBAC3B,KAAK,aAAa,CAAC,YAAY;oBAC7B,OAAO,YAAY,CAAC,IAAI,CAAA;gBAC1B,KAAK,aAAa,CAAC,QAAQ,CAAC;gBAC5B,KAAK,aAAa,CAAC,MAAM;oBACvB,OAAO,YAAY,CAAC,KAAK,CAAA;gBAC3B,KAAK,aAAa,CAAC,QAAQ,CAAC;gBAC5B,KAAK,aAAa,CAAC,OAAO;oBACxB,OAAO,YAAY,CAAC,MAAM,CAAA;gBAC5B;oBACE,OAAO,YAAY,CAAC,IAAI,CAAA;YAC5B,CAAC;QACH;YACE,OAAO,IAAA,iDAAuB,EAAC,UAAU,CAAC,CAAA;IAC9C,CAAC;AACH,CAAC"}
|
package/dist/Spot.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as GeoJSON from 'geojson';
|
|
2
|
+
import { FeatureType } from './FeatureType';
|
|
3
|
+
import { Place } from './Place';
|
|
4
|
+
import { SkiAreaSummaryFeature } from './SkiArea';
|
|
5
|
+
import { Source } from './Source';
|
|
6
|
+
/**
|
|
7
|
+
* A GeoJSON feature representing a spot (point of interest) in or around a ski area.
|
|
8
|
+
*
|
|
9
|
+
* Spots are used to represent lift stations, road crossings, or certain terrain features.
|
|
10
|
+
*/
|
|
11
|
+
export type SpotFeature = GeoJSON.Feature<SpotGeometry, SpotProperties>;
|
|
12
|
+
/**
|
|
13
|
+
* Geometry type for spots - always a point.
|
|
14
|
+
*/
|
|
15
|
+
export type SpotGeometry = GeoJSON.Point;
|
|
16
|
+
/**
|
|
17
|
+
* Union of all spot property types.
|
|
18
|
+
*/
|
|
19
|
+
export type SpotProperties = CrossingSpotProperties | LiftStationSpotProperties | AvalancheTransceiverTrainingSpotProperties | AvalancheTransceiverCheckpointSpotProperties | HalfpipeSpotProperties;
|
|
20
|
+
/**
|
|
21
|
+
* Base properties shared by all spot types.
|
|
22
|
+
*/
|
|
23
|
+
export type SpotBaseProperties = {
|
|
24
|
+
type: FeatureType.Spot;
|
|
25
|
+
id: string;
|
|
26
|
+
skiAreas: SkiAreaSummaryFeature[];
|
|
27
|
+
sources: Source[];
|
|
28
|
+
places: Place[];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Types of spots that can be found in or around ski areas.
|
|
32
|
+
*/
|
|
33
|
+
export declare enum SpotType {
|
|
34
|
+
Crossing = "crossing",
|
|
35
|
+
LiftStation = "lift_station",
|
|
36
|
+
AvalancheTransceiverTraining = "avalanche_transceiver_training",
|
|
37
|
+
AvalancheTransceiverCheckpoint = "avalanche_transceiver_checkpoint",
|
|
38
|
+
Halfpipe = "halfpipe"
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A crossing is a point where a ski run intersects with a road or path,
|
|
42
|
+
* potentially requiring skiers to remove their skis.
|
|
43
|
+
*
|
|
44
|
+
* From OpenStreetMap node with tag `piste:dismount=yes|no|sometimes`.
|
|
45
|
+
*/
|
|
46
|
+
export type CrossingSpotProperties = SpotBaseProperties & {
|
|
47
|
+
spotType: SpotType.Crossing;
|
|
48
|
+
dismount: DismountRequirement;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Whether dismounting from skis is required at a crossing.
|
|
52
|
+
*/
|
|
53
|
+
export declare enum DismountRequirement {
|
|
54
|
+
Yes = "yes",
|
|
55
|
+
No = "no",
|
|
56
|
+
Sometimes = "sometimes"
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A lift station is a boarding or alighting point for a ski lift.
|
|
60
|
+
*
|
|
61
|
+
* From OpenStreetMap node or area with tag `aerialway=station`.
|
|
62
|
+
* Areas are represented as a point (centroid).
|
|
63
|
+
*
|
|
64
|
+
* @property {string | null} name - Name of the station, from OpenStreetMap tag `name`.
|
|
65
|
+
* @property {LiftStationPosition | null} position - From OpenStreetMap tag `aerialway:station=bottom|mid|top`.
|
|
66
|
+
* @property {boolean | null} entry - Whether passengers can board here. From OpenStreetMap tag `aerialway:access=entry|both|no`.
|
|
67
|
+
* @property {boolean | null} exit - Whether passengers can alight here. From OpenStreetMap tag `aerialway:access=exit|both|no`.
|
|
68
|
+
*/
|
|
69
|
+
export type LiftStationSpotProperties = SpotBaseProperties & {
|
|
70
|
+
spotType: SpotType.LiftStation;
|
|
71
|
+
name: string | null;
|
|
72
|
+
position: LiftStationPosition | null;
|
|
73
|
+
entry: boolean | null;
|
|
74
|
+
exit: boolean | null;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Position of a lift station along the lift line.
|
|
78
|
+
*/
|
|
79
|
+
export declare enum LiftStationPosition {
|
|
80
|
+
Top = "top",
|
|
81
|
+
Mid = "mid",
|
|
82
|
+
Bottom = "bottom"
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A designated area where skiers can practice using avalanche transceivers.
|
|
86
|
+
*
|
|
87
|
+
* From OpenStreetMap node or area with tags `amenity=avalanche_transceiver` and `avalanche_transceiver=training`.
|
|
88
|
+
* Areas are represented as a point (centroid).
|
|
89
|
+
*/
|
|
90
|
+
export type AvalancheTransceiverTrainingSpotProperties = SpotBaseProperties & {
|
|
91
|
+
spotType: SpotType.AvalancheTransceiverTraining;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A checkpoint where skiers can verify their avalanche transceiver is functioning.
|
|
95
|
+
*
|
|
96
|
+
* From OpenStreetMap node or area with tags `amenity=avalanche_transceiver` and `avalanche_transceiver=checkpoint`.
|
|
97
|
+
* Areas are represented as a point (centroid).
|
|
98
|
+
*/
|
|
99
|
+
export type AvalancheTransceiverCheckpointSpotProperties = SpotBaseProperties & {
|
|
100
|
+
spotType: SpotType.AvalancheTransceiverCheckpoint;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* A halfpipe structure for freestyle skiing or snowboarding.
|
|
104
|
+
*
|
|
105
|
+
* From OpenStreetMap node/way/area with tag `man_made=piste:halfpipe`.
|
|
106
|
+
* Areas are represented as a point (centroid).
|
|
107
|
+
*/
|
|
108
|
+
export type HalfpipeSpotProperties = SpotBaseProperties & {
|
|
109
|
+
spotType: SpotType.Halfpipe;
|
|
110
|
+
};
|
package/dist/Spot.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiftStationPosition = exports.DismountRequirement = exports.SpotType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Types of spots that can be found in or around ski areas.
|
|
6
|
+
*/
|
|
7
|
+
var SpotType;
|
|
8
|
+
(function (SpotType) {
|
|
9
|
+
SpotType["Crossing"] = "crossing";
|
|
10
|
+
SpotType["LiftStation"] = "lift_station";
|
|
11
|
+
SpotType["AvalancheTransceiverTraining"] = "avalanche_transceiver_training";
|
|
12
|
+
SpotType["AvalancheTransceiverCheckpoint"] = "avalanche_transceiver_checkpoint";
|
|
13
|
+
SpotType["Halfpipe"] = "halfpipe";
|
|
14
|
+
})(SpotType || (exports.SpotType = SpotType = {}));
|
|
15
|
+
/**
|
|
16
|
+
* Whether dismounting from skis is required at a crossing.
|
|
17
|
+
*/
|
|
18
|
+
var DismountRequirement;
|
|
19
|
+
(function (DismountRequirement) {
|
|
20
|
+
DismountRequirement["Yes"] = "yes";
|
|
21
|
+
DismountRequirement["No"] = "no";
|
|
22
|
+
DismountRequirement["Sometimes"] = "sometimes";
|
|
23
|
+
})(DismountRequirement || (exports.DismountRequirement = DismountRequirement = {}));
|
|
24
|
+
/**
|
|
25
|
+
* Position of a lift station along the lift line.
|
|
26
|
+
*/
|
|
27
|
+
var LiftStationPosition;
|
|
28
|
+
(function (LiftStationPosition) {
|
|
29
|
+
LiftStationPosition["Top"] = "top";
|
|
30
|
+
LiftStationPosition["Mid"] = "mid";
|
|
31
|
+
LiftStationPosition["Bottom"] = "bottom";
|
|
32
|
+
})(LiftStationPosition || (exports.LiftStationPosition = LiftStationPosition = {}));
|
|
33
|
+
//# sourceMappingURL=Spot.js.map
|
package/dist/Spot.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spot.js","sourceRoot":"","sources":["../src/Spot.ts"],"names":[],"mappings":";;;AAuCA;;GAEG;AACH,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,iCAAqB,CAAA;IACrB,wCAA4B,CAAA;IAC5B,2EAA+D,CAAA;IAC/D,+EAAmE,CAAA;IACnE,iCAAqB,CAAA;AACvB,CAAC,EANW,QAAQ,wBAAR,QAAQ,QAMnB;AAaD;;GAEG;AACH,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC7B,kCAAW,CAAA;IACX,gCAAS,CAAA;IACT,8CAAuB,CAAA;AACzB,CAAC,EAJW,mBAAmB,mCAAnB,mBAAmB,QAI9B;AAqBD;;GAEG;AACH,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC7B,kCAAW,CAAA;IACX,kCAAW,CAAA;IACX,wCAAiB,CAAA;AACnB,CAAC,EAJW,mBAAmB,mCAAnB,mBAAmB,QAI9B"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -12,5 +12,6 @@ tslib_1.__exportStar(require("./SlopeGradingScale"), exports);
|
|
|
12
12
|
tslib_1.__exportStar(require("./SkiArea"), exports);
|
|
13
13
|
tslib_1.__exportStar(require("./SnowCoverHistory"), exports);
|
|
14
14
|
tslib_1.__exportStar(require("./Source"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./Spot"), exports);
|
|
15
16
|
tslib_1.__exportStar(require("./Status"), exports);
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAAkC;AAClC,wDAA6B;AAC7B,iDAAsB;AACtB,8DAAmC;AACnC,kDAAuB;AACvB,gDAAqB;AACrB,oEAAyC;AACzC,8DAAmC;AACnC,oDAAyB;AACzB,6DAAkC;AAClC,mDAAwB;AACxB,mDAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAAkC;AAClC,wDAA6B;AAC7B,iDAAsB;AACtB,8DAAmC;AACnC,kDAAuB;AACvB,gDAAqB;AACrB,oEAAyC;AACzC,8DAAmC;AACnC,oDAAyB;AACzB,6DAAkC;AAClC,mDAAwB;AACxB,iDAAsB;AACtB,mDAAwB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openskidata-format",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Data format for OpenSkiMap.org",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/russellporter/openskidata-format#readme",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/geojson": "^7946.0.
|
|
30
|
-
"@types/jest": "^
|
|
31
|
-
"jest": "^
|
|
32
|
-
"ts-jest": "^29.
|
|
33
|
-
"typescript": "^5"
|
|
29
|
+
"@types/geojson": "^7946.0.16",
|
|
30
|
+
"@types/jest": "^30.0.0",
|
|
31
|
+
"jest": "^30.2.0",
|
|
32
|
+
"ts-jest": "^29.4.6",
|
|
33
|
+
"typescript": "^5.9.3"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@turf/boolean-point-in-polygon": "^7.2
|
|
37
|
-
"@turf/center": "^7.2
|
|
38
|
-
"@turf/distance": "^7.2
|
|
39
|
-
"@turf/helpers": "^7.2
|
|
40
|
-
"@turf/length": "^7.2
|
|
41
|
-
"@turf/line-chunk": "^7.2
|
|
42
|
-
"tslib": "^2"
|
|
36
|
+
"@turf/boolean-point-in-polygon": "^7.3.2",
|
|
37
|
+
"@turf/center": "^7.3.2",
|
|
38
|
+
"@turf/distance": "^7.3.2",
|
|
39
|
+
"@turf/helpers": "^7.3.2",
|
|
40
|
+
"@turf/length": "^7.3.2",
|
|
41
|
+
"@turf/line-chunk": "^7.3.2",
|
|
42
|
+
"tslib": "^2.8.1"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -174,6 +174,8 @@ describe('ElevationProfile', () => {
|
|
|
174
174
|
lit: null,
|
|
175
175
|
gladed: null,
|
|
176
176
|
patrolled: null,
|
|
177
|
+
snowmaking: null,
|
|
178
|
+
snowfarming: null,
|
|
177
179
|
grooming: null,
|
|
178
180
|
websites: [],
|
|
179
181
|
wikidataID: null,
|
|
@@ -211,6 +213,8 @@ describe('ElevationProfile', () => {
|
|
|
211
213
|
lit: null,
|
|
212
214
|
gladed: null,
|
|
213
215
|
patrolled: null,
|
|
216
|
+
snowmaking: null,
|
|
217
|
+
snowfarming: null,
|
|
214
218
|
grooming: null,
|
|
215
219
|
websites: [],
|
|
216
220
|
wikidataID: null,
|
|
@@ -274,6 +278,8 @@ describe('ElevationProfile', () => {
|
|
|
274
278
|
lit: null,
|
|
275
279
|
gladed: null,
|
|
276
280
|
patrolled: null,
|
|
281
|
+
snowmaking: null,
|
|
282
|
+
snowfarming: null,
|
|
277
283
|
grooming: 'classic+skating',
|
|
278
284
|
skiAreas: [],
|
|
279
285
|
elevationProfile: {
|
package/src/ElevationProfile.ts
CHANGED
|
@@ -91,6 +91,12 @@ export function getPitchData(
|
|
|
91
91
|
units: 'meters',
|
|
92
92
|
}).features.map((feature) => feature.geometry)
|
|
93
93
|
|
|
94
|
+
// turf 7.3+ adds Z coordinates to newly created points using segment-end elevation,
|
|
95
|
+
// but we need distance-based interpolation. Strip Z from non-original vertices so
|
|
96
|
+
// interpolateElevation can add them correctly.
|
|
97
|
+
// https://github.com/Turfjs/turf/issues/3007
|
|
98
|
+
stripNonOriginalElevations(chunkedGeometries, coordinates)
|
|
99
|
+
|
|
94
100
|
// Mutates the geometries in place to add elevation data
|
|
95
101
|
interpolateElevation(chunkedGeometries)
|
|
96
102
|
|
|
@@ -148,46 +154,21 @@ export function getProfileGeometry(
|
|
|
148
154
|
geometry: GeoJSON.LineString,
|
|
149
155
|
elevationProfile: ElevationProfile,
|
|
150
156
|
): GeoJSON.LineString {
|
|
151
|
-
const
|
|
157
|
+
const profileLine = extractPointsForElevationProfile(
|
|
152
158
|
geometry,
|
|
153
159
|
elevationProfile.resolution,
|
|
154
160
|
)
|
|
155
|
-
|
|
156
|
-
for (let subline of geometries) {
|
|
157
|
-
const firstPoint = subline.coordinates[0]
|
|
158
|
-
if (firstPoint.length === 2) {
|
|
159
|
-
firstPoint.push(elevationProfile.heights[index])
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
index++
|
|
163
|
-
|
|
164
|
-
if (index === elevationProfile.heights.length) {
|
|
165
|
-
throw 'Mismatch of points & elevation profile.'
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const lastPoint = subline.coordinates[subline.coordinates.length - 1]
|
|
169
|
-
if (lastPoint.length === 2) {
|
|
170
|
-
lastPoint.push(elevationProfile.heights[index])
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (index !== elevationProfile.heights.length - 1) {
|
|
161
|
+
if (profileLine.coordinates.length !== elevationProfile.heights.length) {
|
|
175
162
|
throw `Mismatch of points & elevation profile`
|
|
176
163
|
}
|
|
177
164
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
throw 'All points should have an elevation at this point.'
|
|
183
|
-
}
|
|
184
|
-
}
|
|
165
|
+
for (let i = 0; i < profileLine.coordinates.length; i++) {
|
|
166
|
+
const point = profileLine.coordinates[i]
|
|
167
|
+
const height = elevationProfile.heights[i]
|
|
168
|
+
point.push(height)
|
|
185
169
|
}
|
|
186
170
|
|
|
187
|
-
return
|
|
188
|
-
type: 'LineString',
|
|
189
|
-
coordinates: geometries.flatMap((geometry) => geometry.coordinates),
|
|
190
|
-
}
|
|
171
|
+
return profileLine
|
|
191
172
|
}
|
|
192
173
|
|
|
193
174
|
/**
|
|
@@ -197,14 +178,18 @@ export function extractPointsForElevationProfile(
|
|
|
197
178
|
geometry: LineString,
|
|
198
179
|
resolution: number,
|
|
199
180
|
): GeoJSON.LineString {
|
|
200
|
-
|
|
181
|
+
// Important: Z coordinates in the output of lineChunk may be incorrect, ignore them (https://github.com/Turfjs/turf/issues/3007)
|
|
182
|
+
const lineChunks = lineChunk(geometry, resolution, {
|
|
183
|
+
units: 'meters',
|
|
184
|
+
}).features.map((feature) => feature.geometry)
|
|
185
|
+
|
|
201
186
|
const points: GeoJSON.Position[] = []
|
|
202
|
-
for (let subline of
|
|
187
|
+
for (let subline of lineChunks) {
|
|
203
188
|
const point = subline.coordinates[0]
|
|
204
189
|
points.push([point[0], point[1]])
|
|
205
190
|
}
|
|
206
|
-
if (
|
|
207
|
-
const geometry =
|
|
191
|
+
if (lineChunks.length > 0) {
|
|
192
|
+
const geometry = lineChunks[lineChunks.length - 1]
|
|
208
193
|
const coords = geometry.coordinates
|
|
209
194
|
if (coords.length > 1) {
|
|
210
195
|
const point = coords[coords.length - 1]
|
|
@@ -218,15 +203,6 @@ export function extractPointsForElevationProfile(
|
|
|
218
203
|
}
|
|
219
204
|
}
|
|
220
205
|
|
|
221
|
-
function lineChunksForElevationProfile(
|
|
222
|
-
geometry: LineString,
|
|
223
|
-
resolution: number,
|
|
224
|
-
): GeoJSON.LineString[] {
|
|
225
|
-
return lineChunk(geometry, resolution, {
|
|
226
|
-
units: 'meters',
|
|
227
|
-
}).features.map((feature) => feature.geometry)
|
|
228
|
-
}
|
|
229
|
-
|
|
230
206
|
export function getAscentAndDescent(
|
|
231
207
|
profileGeometry: GeoJSON.LineString,
|
|
232
208
|
): AscentDescentData {
|
|
@@ -278,6 +254,27 @@ export function getAscentAndDescent(
|
|
|
278
254
|
}
|
|
279
255
|
}
|
|
280
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Strip Z coordinates from points that were created by lineChunk (not original vertices).
|
|
259
|
+
* Original vertices are identified by matching lon/lat coordinates.
|
|
260
|
+
* Mutates the geometries in place.
|
|
261
|
+
*/
|
|
262
|
+
function stripNonOriginalElevations(
|
|
263
|
+
geometries: GeoJSON.LineString[],
|
|
264
|
+
originalCoordinates: GeoJSON.Position[],
|
|
265
|
+
) {
|
|
266
|
+
const originalSet = new Set(originalCoordinates.map((c) => `${c[0]},${c[1]}`))
|
|
267
|
+
|
|
268
|
+
for (const geometry of geometries) {
|
|
269
|
+
for (const point of geometry.coordinates) {
|
|
270
|
+
const key = `${point[0]},${point[1]}`
|
|
271
|
+
if (!originalSet.has(key) && point.length >= 3) {
|
|
272
|
+
point.length = 2
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
281
278
|
/**
|
|
282
279
|
* Interpolate elevation for points along a list of linestrings that don't already have elevation.
|
|
283
280
|
* Uses geographic distances for proper interpolation.
|
package/src/FeatureType.ts
CHANGED
package/src/Run.ts
CHANGED
|
@@ -51,6 +51,8 @@ export type RunFeature = GeoJSON.Feature<RunGeometry, RunProperties>
|
|
|
51
51
|
* @property {boolean | null} lit - Whether the run has lighting for night skiing, derived from the OpenStreetMap "piste:lit" or "lit" tag.
|
|
52
52
|
* @property {boolean | null} gladed - Whether the run is through gladed/tree terrain, derived from the OpenStreetMap "piste:gladed" or "gladed" tag.
|
|
53
53
|
* @property {boolean | null} patrolled - Whether the run is patrolled by ski patrol, derived from the OpenStreetMap "piste:patrolled" or "patrolled" tag.
|
|
54
|
+
* @property {boolean | null} snowmaking - Whether the run has its operation secured through snowmaking, derived from the OpenStreetMap "piste:snowmaking" tag.
|
|
55
|
+
* @property {boolean | null} snowfarming - Whether the run has its early season operation secured through snowfarming (storing snow from previous season), derived from the OpenStreetMap "piste:snowfarming" tag.
|
|
54
56
|
* @property {RunGrooming | null} grooming - Grooming status/type of the run, derived from the OpenStreetMap "piste:grooming" tag. If not specified explicitly, for difficulties "expert", "freeride", and "extreme", grooming is assumed to be "backcountry".
|
|
55
57
|
* @property {SkiAreaSummaryFeature[]} skiAreas - Ski areas this run belongs to. Derived from the OpenStreetMap site=piste relation or landuse=winter_sports area and proximity to ski area features. Runs with "backcountry" grooming are not associated with ski areas unless they have a "piste:patrolled=yes" or "patrolled=yes" OpenStreetMap tag, or are part of a "site=piste" ski area relation.
|
|
56
58
|
* @property {ElevationProfile | null} elevationProfile - Elevation profile of the run, only available for runs with LineString geometry.
|
|
@@ -74,6 +76,8 @@ export type RunProperties = {
|
|
|
74
76
|
lit: boolean | null
|
|
75
77
|
gladed: boolean | null
|
|
76
78
|
patrolled: boolean | null
|
|
79
|
+
snowmaking: boolean | null
|
|
80
|
+
snowfarming: boolean | null
|
|
77
81
|
grooming: RunGrooming | null
|
|
78
82
|
skiAreas: SkiAreaSummaryFeature[]
|
|
79
83
|
elevationProfile: ElevationProfile | null
|
|
@@ -20,6 +20,8 @@ describe("getEstimatedRunDifficulty", () => {
|
|
|
20
20
|
lit: null,
|
|
21
21
|
gladed: null,
|
|
22
22
|
patrolled: null,
|
|
23
|
+
snowmaking: null,
|
|
24
|
+
snowfarming: null,
|
|
23
25
|
grooming: null,
|
|
24
26
|
skiAreas: [],
|
|
25
27
|
elevationProfile: null,
|
|
@@ -51,6 +53,8 @@ describe("getEstimatedRunDifficulty", () => {
|
|
|
51
53
|
lit: null,
|
|
52
54
|
gladed: null,
|
|
53
55
|
patrolled: null,
|
|
56
|
+
snowmaking: null,
|
|
57
|
+
snowfarming: null,
|
|
54
58
|
grooming: null,
|
|
55
59
|
skiAreas: [],
|
|
56
60
|
elevationProfile: null,
|
|
@@ -86,6 +90,8 @@ describe("getEstimatedRunDifficulty", () => {
|
|
|
86
90
|
lit: null,
|
|
87
91
|
gladed: null,
|
|
88
92
|
patrolled: null,
|
|
93
|
+
snowmaking: null,
|
|
94
|
+
snowfarming: null,
|
|
89
95
|
grooming: null,
|
|
90
96
|
skiAreas: [],
|
|
91
97
|
elevationProfile: null,
|
|
@@ -119,6 +125,8 @@ describe("getEstimatedRunDifficulty", () => {
|
|
|
119
125
|
lit: null,
|
|
120
126
|
gladed: null,
|
|
121
127
|
patrolled: null,
|
|
128
|
+
snowmaking: null,
|
|
129
|
+
snowfarming: null,
|
|
122
130
|
grooming: null,
|
|
123
131
|
skiAreas: [],
|
|
124
132
|
elevationProfile: null,
|
package/src/Spot.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import * as GeoJSON from 'geojson'
|
|
2
|
+
import { FeatureType } from './FeatureType'
|
|
3
|
+
import { Place } from './Place'
|
|
4
|
+
import { SkiAreaSummaryFeature } from './SkiArea'
|
|
5
|
+
import { Source } from './Source'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A GeoJSON feature representing a spot (point of interest) in or around a ski area.
|
|
9
|
+
*
|
|
10
|
+
* Spots are used to represent lift stations, road crossings, or certain terrain features.
|
|
11
|
+
*/
|
|
12
|
+
export type SpotFeature = GeoJSON.Feature<SpotGeometry, SpotProperties>
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Geometry type for spots - always a point.
|
|
16
|
+
*/
|
|
17
|
+
export type SpotGeometry = GeoJSON.Point
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Union of all spot property types.
|
|
21
|
+
*/
|
|
22
|
+
export type SpotProperties =
|
|
23
|
+
| CrossingSpotProperties
|
|
24
|
+
| LiftStationSpotProperties
|
|
25
|
+
| AvalancheTransceiverTrainingSpotProperties
|
|
26
|
+
| AvalancheTransceiverCheckpointSpotProperties
|
|
27
|
+
| HalfpipeSpotProperties
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Base properties shared by all spot types.
|
|
31
|
+
*/
|
|
32
|
+
export type SpotBaseProperties = {
|
|
33
|
+
type: FeatureType.Spot
|
|
34
|
+
id: string
|
|
35
|
+
skiAreas: SkiAreaSummaryFeature[]
|
|
36
|
+
sources: Source[]
|
|
37
|
+
places: Place[]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Types of spots that can be found in or around ski areas.
|
|
42
|
+
*/
|
|
43
|
+
export enum SpotType {
|
|
44
|
+
Crossing = 'crossing',
|
|
45
|
+
LiftStation = 'lift_station',
|
|
46
|
+
AvalancheTransceiverTraining = 'avalanche_transceiver_training',
|
|
47
|
+
AvalancheTransceiverCheckpoint = 'avalanche_transceiver_checkpoint',
|
|
48
|
+
Halfpipe = 'halfpipe',
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A crossing is a point where a ski run intersects with a road or path,
|
|
53
|
+
* potentially requiring skiers to remove their skis.
|
|
54
|
+
*
|
|
55
|
+
* From OpenStreetMap node with tag `piste:dismount=yes|no|sometimes`.
|
|
56
|
+
*/
|
|
57
|
+
export type CrossingSpotProperties = SpotBaseProperties & {
|
|
58
|
+
spotType: SpotType.Crossing
|
|
59
|
+
dismount: DismountRequirement
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Whether dismounting from skis is required at a crossing.
|
|
64
|
+
*/
|
|
65
|
+
export enum DismountRequirement {
|
|
66
|
+
Yes = 'yes',
|
|
67
|
+
No = 'no',
|
|
68
|
+
Sometimes = 'sometimes',
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* A lift station is a boarding or alighting point for a ski lift.
|
|
73
|
+
*
|
|
74
|
+
* From OpenStreetMap node or area with tag `aerialway=station`.
|
|
75
|
+
* Areas are represented as a point (centroid).
|
|
76
|
+
*
|
|
77
|
+
* @property {string | null} name - Name of the station, from OpenStreetMap tag `name`.
|
|
78
|
+
* @property {LiftStationPosition | null} position - From OpenStreetMap tag `aerialway:station=bottom|mid|top`.
|
|
79
|
+
* @property {boolean | null} entry - Whether passengers can board here. From OpenStreetMap tag `aerialway:access=entry|both|no`.
|
|
80
|
+
* @property {boolean | null} exit - Whether passengers can alight here. From OpenStreetMap tag `aerialway:access=exit|both|no`.
|
|
81
|
+
*/
|
|
82
|
+
export type LiftStationSpotProperties = SpotBaseProperties & {
|
|
83
|
+
spotType: SpotType.LiftStation
|
|
84
|
+
name: string | null
|
|
85
|
+
position: LiftStationPosition | null
|
|
86
|
+
entry: boolean | null
|
|
87
|
+
exit: boolean | null
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Position of a lift station along the lift line.
|
|
92
|
+
*/
|
|
93
|
+
export enum LiftStationPosition {
|
|
94
|
+
Top = 'top',
|
|
95
|
+
Mid = 'mid',
|
|
96
|
+
Bottom = 'bottom',
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* A designated area where skiers can practice using avalanche transceivers.
|
|
101
|
+
*
|
|
102
|
+
* From OpenStreetMap node or area with tags `amenity=avalanche_transceiver` and `avalanche_transceiver=training`.
|
|
103
|
+
* Areas are represented as a point (centroid).
|
|
104
|
+
*/
|
|
105
|
+
export type AvalancheTransceiverTrainingSpotProperties = SpotBaseProperties & {
|
|
106
|
+
spotType: SpotType.AvalancheTransceiverTraining
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A checkpoint where skiers can verify their avalanche transceiver is functioning.
|
|
111
|
+
*
|
|
112
|
+
* From OpenStreetMap node or area with tags `amenity=avalanche_transceiver` and `avalanche_transceiver=checkpoint`.
|
|
113
|
+
* Areas are represented as a point (centroid).
|
|
114
|
+
*/
|
|
115
|
+
export type AvalancheTransceiverCheckpointSpotProperties =
|
|
116
|
+
SpotBaseProperties & {
|
|
117
|
+
spotType: SpotType.AvalancheTransceiverCheckpoint
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* A halfpipe structure for freestyle skiing or snowboarding.
|
|
122
|
+
*
|
|
123
|
+
* From OpenStreetMap node/way/area with tag `man_made=piste:halfpipe`.
|
|
124
|
+
* Areas are represented as a point (centroid).
|
|
125
|
+
*/
|
|
126
|
+
export type HalfpipeSpotProperties = SpotBaseProperties & {
|
|
127
|
+
spotType: SpotType.Halfpipe
|
|
128
|
+
}
|