openskidata-format 5.3.0 → 5.5.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.
@@ -1,4 +1,5 @@
1
- import { RunDifficulty, RunFeature } from "./Run";
1
+ import { RunDifficulty, RunFeature, RunUse } from "./Run";
2
+ import { RunDifficultyConvention } from "./RunDifficultyConvention";
2
3
  /**
3
4
  * Represents a slope grading scale with steepness thresholds for different run types.
4
5
  * Used to estimate run difficulty based on slope steepness. Each scale defines
@@ -30,3 +31,14 @@ export declare function getSlopeGradingScale(feature: RunFeature): SlopeGradingS
30
31
  * @returns The estimated difficulty based on steepness, or null if no match or below minimum threshold
31
32
  */
32
33
  export declare function getEstimatedRunDifficulty(steepness: number, scale: SlopeGradingScale): RunDifficulty | null;
34
+ /**
35
+ * Gets the appropriate slope grading scale for a specific run use and region.
36
+ * Different run uses (downhill, nordic, etc.) have different steepness thresholds
37
+ * for difficulty classification. This function allows for regional variations
38
+ * in the future if different conventions use different slope scales.
39
+ *
40
+ * @param runUse - The type of run use to get the grading scale for
41
+ * @param convention - The regional difficulty convention (currently not used but available for future regional variations)
42
+ * @returns The appropriate slope grading scale with steepness thresholds
43
+ */
44
+ export declare function getSlopeGradingScaleForUse(runUse: RunUse, convention: RunDifficultyConvention): SlopeGradingScale;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSlopeGradingScale = getSlopeGradingScale;
4
4
  exports.getEstimatedRunDifficulty = getEstimatedRunDifficulty;
5
+ exports.getSlopeGradingScaleForUse = getSlopeGradingScaleForUse;
5
6
  const Run_1 = require("./Run");
6
7
  /**
7
8
  * Gets the appropriate slope grading scale for a run based on its use types.
@@ -12,26 +13,13 @@ const Run_1 = require("./Run");
12
13
  * @returns The appropriate slope grading scale with steepness thresholds
13
14
  */
14
15
  function getSlopeGradingScale(feature) {
16
+ // Check for downhill or skitour uses first (they have the same scale)
15
17
  if (feature.properties.uses.includes(Run_1.RunUse.Downhill) ||
16
18
  feature.properties.uses.includes(Run_1.RunUse.Skitour)) {
17
- return {
18
- stops: [
19
- { maxSteepness: 0.05, difficulty: null }, // No difficulty below 5%
20
- { maxSteepness: 0.25, difficulty: Run_1.RunDifficulty.EASY },
21
- { maxSteepness: 0.4, difficulty: Run_1.RunDifficulty.INTERMEDIATE },
22
- { maxSteepness: 0.8, difficulty: Run_1.RunDifficulty.ADVANCED }, // Advanced up to 80%
23
- { maxSteepness: 1.2, difficulty: Run_1.RunDifficulty.EXPERT }, // Expert up to 120%
24
- ],
25
- };
19
+ return getSlopeGradingScaleForUse(Run_1.RunUse.Downhill, feature.properties.difficultyConvention);
26
20
  }
27
21
  else if (feature.properties.uses.includes(Run_1.RunUse.Nordic)) {
28
- return {
29
- stops: [
30
- { maxSteepness: 0.1, difficulty: Run_1.RunDifficulty.EASY },
31
- { maxSteepness: 0.15, difficulty: Run_1.RunDifficulty.INTERMEDIATE },
32
- { maxSteepness: 0.3, difficulty: Run_1.RunDifficulty.ADVANCED },
33
- ],
34
- };
22
+ return getSlopeGradingScaleForUse(Run_1.RunUse.Nordic, feature.properties.difficultyConvention);
35
23
  }
36
24
  else {
37
25
  return { stops: [] };
@@ -51,4 +39,42 @@ function getEstimatedRunDifficulty(steepness, scale) {
51
39
  return (scale.stops.find((stop) => stop.maxSteepness > absoluteSteepness)
52
40
  ?.difficulty || null);
53
41
  }
42
+ /**
43
+ * Gets the appropriate slope grading scale for a specific run use and region.
44
+ * Different run uses (downhill, nordic, etc.) have different steepness thresholds
45
+ * for difficulty classification. This function allows for regional variations
46
+ * in the future if different conventions use different slope scales.
47
+ *
48
+ * @param runUse - The type of run use to get the grading scale for
49
+ * @param convention - The regional difficulty convention (currently not used but available for future regional variations)
50
+ * @returns The appropriate slope grading scale with steepness thresholds
51
+ */
52
+ function getSlopeGradingScaleForUse(runUse, convention) {
53
+ // Currently convention is not used, but is available for future regional variations
54
+ switch (runUse) {
55
+ case Run_1.RunUse.Downhill:
56
+ case Run_1.RunUse.Skitour:
57
+ return {
58
+ stops: [
59
+ { maxSteepness: 0.05, difficulty: null }, // No difficulty below 5%
60
+ { maxSteepness: 0.25, difficulty: Run_1.RunDifficulty.EASY },
61
+ { maxSteepness: 0.4, difficulty: Run_1.RunDifficulty.INTERMEDIATE },
62
+ { maxSteepness: 0.8, difficulty: Run_1.RunDifficulty.ADVANCED }, // Advanced up to 80%
63
+ { maxSteepness: 1.0, difficulty: Run_1.RunDifficulty.EXPERT }, // Expert up to 100%
64
+ { maxSteepness: 1.2, difficulty: Run_1.RunDifficulty.FREERIDE }, // Freeride up to 120%
65
+ { maxSteepness: Infinity, difficulty: Run_1.RunDifficulty.EXTREME }, // Extreme above 120%
66
+ ],
67
+ };
68
+ case Run_1.RunUse.Nordic:
69
+ return {
70
+ stops: [
71
+ { maxSteepness: 0.1, difficulty: Run_1.RunDifficulty.EASY },
72
+ { maxSteepness: 0.15, difficulty: Run_1.RunDifficulty.INTERMEDIATE },
73
+ { maxSteepness: 0.3, difficulty: Run_1.RunDifficulty.ADVANCED },
74
+ ],
75
+ };
76
+ default:
77
+ return { stops: [] };
78
+ }
79
+ }
54
80
  //# sourceMappingURL=SlopeGradingScale.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SlopeGradingScale.js","sourceRoot":"","sources":["../src/SlopeGradingScale.ts"],"names":[],"mappings":";;AAoBA,oDAyBC;AAWD,8DASC;AAjED,+BAA0D;AAY1D;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAAC,OAAmB;IACtD,IACE,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAM,CAAC,QAAQ,CAAC;QACjD,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAM,CAAC,OAAO,CAAC,EAChD,CAAC;QACD,OAAO;YACL,KAAK,EAAE;gBACL,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,yBAAyB;gBACnE,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AAE,UAAU,EAAE,IAAI,EAAE,EAAE,yBAAyB;oBACnE,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,mBAAa,CAAC,IAAI,EAAE;oBACtD,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,mBAAa,CAAC,YAAY,EAAE;oBAC7D,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,mBAAa,CAAC,QAAQ,EAAE,EAAE,qBAAqB;oBAChF,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,mBAAa,CAAC,MAAM,EAAE,EAAE,oBAAoB;oBAC7E,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,mBAAa,CAAC,QAAQ,EAAE,EAAE,sBAAsB;oBACjF,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,mBAAa,CAAC,OAAO,EAAE,EAAE,qBAAqB;iBACrF;aACF,CAAC;QACJ,KAAK,YAAM,CAAC,MAAM;YAClB,OAAO;gBACH,KAAK,EAAE;oBACL,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,mBAAa,CAAC,IAAI,EAAE;oBACrD,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,mBAAa,CAAC,YAAY,EAAE;oBAC9D,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,mBAAa,CAAC,QAAQ,EAAE;iBAC1D;aACF,CAAC;QACJ;YACE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACzB,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openskidata-format",
3
- "version": "5.3.0",
3
+ "version": "5.5.0",
4
4
  "description": "Data format for OpenSkiMap.org",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,7 +39,6 @@
39
39
  "@turf/helpers": "^7.2.0",
40
40
  "@turf/length": "^7.2.0",
41
41
  "@turf/line-chunk": "^7.2.0",
42
- "@turf/meta": "^7.2.0",
43
42
  "tslib": "^2"
44
43
  }
45
44
  }
@@ -1,4 +1,5 @@
1
1
  import { RunDifficulty, RunFeature, RunUse } from "./Run";
2
+ import { RunDifficultyConvention } from "./RunDifficultyConvention";
2
3
 
3
4
  /**
4
5
  * Represents a slope grading scale with steepness thresholds for different run types.
@@ -19,27 +20,14 @@ export type SlopeGradingScale = {
19
20
  * @returns The appropriate slope grading scale with steepness thresholds
20
21
  */
21
22
  export function getSlopeGradingScale(feature: RunFeature): SlopeGradingScale {
23
+ // Check for downhill or skitour uses first (they have the same scale)
22
24
  if (
23
25
  feature.properties.uses.includes(RunUse.Downhill) ||
24
26
  feature.properties.uses.includes(RunUse.Skitour)
25
27
  ) {
26
- return {
27
- stops: [
28
- { maxSteepness: 0.05, difficulty: null }, // No difficulty below 5%
29
- { maxSteepness: 0.25, difficulty: RunDifficulty.EASY },
30
- { maxSteepness: 0.4, difficulty: RunDifficulty.INTERMEDIATE },
31
- { maxSteepness: 0.8, difficulty: RunDifficulty.ADVANCED }, // Advanced up to 80%
32
- { maxSteepness: 1.2, difficulty: RunDifficulty.EXPERT }, // Expert up to 120%
33
- ],
34
- };
28
+ return getSlopeGradingScaleForUse(RunUse.Downhill, feature.properties.difficultyConvention);
35
29
  } else if (feature.properties.uses.includes(RunUse.Nordic)) {
36
- return {
37
- stops: [
38
- { maxSteepness: 0.1, difficulty: RunDifficulty.EASY },
39
- { maxSteepness: 0.15, difficulty: RunDifficulty.INTERMEDIATE },
40
- { maxSteepness: 0.3, difficulty: RunDifficulty.ADVANCED },
41
- ],
42
- };
30
+ return getSlopeGradingScaleForUse(RunUse.Nordic, feature.properties.difficultyConvention);
43
31
  } else {
44
32
  return { stops: [] };
45
33
  }
@@ -63,4 +51,46 @@ export function getEstimatedRunDifficulty(
63
51
  scale.stops.find((stop) => stop.maxSteepness > absoluteSteepness)
64
52
  ?.difficulty || null
65
53
  );
54
+ }
55
+
56
+ /**
57
+ * Gets the appropriate slope grading scale for a specific run use and region.
58
+ * Different run uses (downhill, nordic, etc.) have different steepness thresholds
59
+ * for difficulty classification. This function allows for regional variations
60
+ * in the future if different conventions use different slope scales.
61
+ *
62
+ * @param runUse - The type of run use to get the grading scale for
63
+ * @param convention - The regional difficulty convention (currently not used but available for future regional variations)
64
+ * @returns The appropriate slope grading scale with steepness thresholds
65
+ */
66
+ export function getSlopeGradingScaleForUse(
67
+ runUse: RunUse,
68
+ convention: RunDifficultyConvention
69
+ ): SlopeGradingScale {
70
+ // Currently convention is not used, but is available for future regional variations
71
+ switch (runUse) {
72
+ case RunUse.Downhill:
73
+ case RunUse.Skitour:
74
+ return {
75
+ stops: [
76
+ { maxSteepness: 0.05, difficulty: null }, // No difficulty below 5%
77
+ { maxSteepness: 0.25, difficulty: RunDifficulty.EASY },
78
+ { maxSteepness: 0.4, difficulty: RunDifficulty.INTERMEDIATE },
79
+ { maxSteepness: 0.8, difficulty: RunDifficulty.ADVANCED }, // Advanced up to 80%
80
+ { maxSteepness: 1.0, difficulty: RunDifficulty.EXPERT }, // Expert up to 100%
81
+ { maxSteepness: 1.2, difficulty: RunDifficulty.FREERIDE }, // Freeride up to 120%
82
+ { maxSteepness: Infinity, difficulty: RunDifficulty.EXTREME }, // Extreme above 120%
83
+ ],
84
+ };
85
+ case RunUse.Nordic:
86
+ return {
87
+ stops: [
88
+ { maxSteepness: 0.1, difficulty: RunDifficulty.EASY },
89
+ { maxSteepness: 0.15, difficulty: RunDifficulty.INTERMEDIATE },
90
+ { maxSteepness: 0.3, difficulty: RunDifficulty.ADVANCED },
91
+ ],
92
+ };
93
+ default:
94
+ return { stops: [] };
95
+ }
66
96
  }