openskidata-format 0.15.0 → 2.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/src/SkiArea.ts CHANGED
@@ -1,11 +1,30 @@
1
- import { Activity } from './Activity'
2
1
  import { FeatureType } from './FeatureType'
3
2
  import { LiftType } from './Lift'
4
3
  import { Location } from './Location'
5
- import { RunConvention, RunDifficulty } from './Run'
6
- import Source from './Source'
4
+ import { RunDifficulty, RunDifficultyConvention } from './Run'
5
+ import { Source } from './Source'
7
6
  import { Status } from './Status'
8
7
 
8
+ /**
9
+ * A ski area feature is derived from several sources:
10
+ * - OpenStreetMap site=piste relations
11
+ * - OpenStreetMap landuse=winter_sports areas that contains ski runs
12
+ * - Skimap.org ski areas
13
+ *
14
+ * The processor attempts to merge the data of all sources to create a single ski area feature.
15
+ *
16
+ * In some cases merging may fail and duplicate ski areas will be produced. This is likely due to ambiguous data.
17
+ * Check:
18
+ * - that a site=piste relation contains all the lifts/runs. If many lifts/runs are missing, merging will fail.
19
+ * - that if there are multiple landuse=winter_sports areas representing a single ski area. In this case a multipolygon relation should be used.
20
+ * - that if there are multiple Skimap.org ski areas representing a single ski area.
21
+ *
22
+ * General recommendation for ski area tagging in OpenStreetMap:
23
+ * - start with a landuse=winter_sports area as it's easy to set up and maintain.
24
+ * - if that's not explicit enough, add a site=piste relation as well.
25
+ *
26
+ * Note: if runs are present but there is no associated ski area source, a ski area feature is generated with no name and no source.
27
+ */
9
28
  export type SkiAreaFeature = GeoJSON.Feature<SkiAreaGeometry, SkiAreaProperties>
10
29
 
11
30
  export type SkiAreaGeometry =
@@ -13,43 +32,69 @@ export type SkiAreaGeometry =
13
32
  | GeoJSON.Polygon
14
33
  | GeoJSON.MultiPolygon
15
34
 
16
- export interface SkiAreaProperties {
17
- type: FeatureType.SkiArea
18
- id: string
19
- name: string | null
35
+ export type SkiAreaSummaryFeature = GeoJSON.Feature<
36
+ SkiAreaGeometry,
37
+ SkiAreaSummaryProperties
38
+ >
39
+
40
+ /**
41
+ * @property {string} id - Unique identifier for the ski area. The ID is just a hash of the feature, so will change if the feature changes in any way. If a stable identifier is needed, use the wikidata_id property, or a source id.
42
+ * @property {string | null} name - Name of the ski area.
43
+ * @property {Source[]} sources - Data sources.
44
+ * @property {SkiAreaActivity[]} activities - Activities available at this ski area, derived from presence of ski runs and Skimap.org data.
45
+ * @property {SkiAreaStatistics} statistics - Statistics generated from associated runs / lifts.
46
+ * @property {Status | null} status - Operational status. Derived from OpenStreetMap lifecycle tags and Skimap.org data.
47
+ * @property {RunColorConvention} runConvention - Color convention used for runs at this ski area.
48
+ * @property {string[]} websites - Official website(s) of the ski area. Derived from the OpenStreetMap website tag and Skimap.org data.
49
+ * @property {string | null} wikidata_id - Wikidata identifier. Derived from the OpenStreetMap wikidata tag.
50
+ * @property {Location | null} location - Reverse geocoded country / region information.
51
+ */
52
+ export type SkiAreaProperties = SkiAreaSummaryProperties & {
20
53
  sources: Source[]
21
- activities: Activity[]
22
- generated: boolean
23
54
  statistics?: SkiAreaStatistics
24
- status: Status | null
25
- runConvention: RunConvention
55
+ runConvention: RunDifficultyConvention
26
56
  websites: string[]
27
57
  wikidata_id: string | null
58
+ }
59
+
60
+ export type SkiAreaSummaryProperties = {
61
+ type: FeatureType.SkiArea
62
+ id: string
63
+ name: string | null
64
+ activities: SkiAreaActivity[]
65
+ status: Status | null
28
66
  location: Location | null
29
67
  }
30
68
 
31
- export interface SkiAreaStatistics {
69
+ export enum SkiAreaActivity {
70
+ Downhill = 'downhill',
71
+ Nordic = 'nordic',
72
+ }
73
+
74
+ export type SkiAreaStatistics = {
32
75
  runs: RunStatistics
33
76
  lifts: LiftStatistics
34
77
  minElevation?: number
35
78
  maxElevation?: number
36
79
  }
37
80
 
38
- export interface RunStatistics {
81
+ export type RunStatistics = {
39
82
  minElevation?: number
40
83
  maxElevation?: number
41
84
  byActivity: RunStatisticsByActivityAndDifficulty
42
85
  }
43
86
 
44
87
  export type RunStatisticsByActivityAndDifficulty = {
45
- [key in Activity | 'other']?: { byDifficulty: RunStatisticsByDifficulty }
88
+ [key in SkiAreaActivity | 'other']?: {
89
+ byDifficulty: RunStatisticsByDifficulty
90
+ }
46
91
  }
47
92
 
48
93
  export type RunStatisticsByDifficulty = {
49
94
  [key in RunDifficulty | 'other']?: { count: number; lengthInKm: number }
50
95
  }
51
96
 
52
- export interface LiftStatistics {
97
+ export type LiftStatistics = {
53
98
  minElevation?: number
54
99
  maxElevation?: number
55
100
  byType: LiftStatisticsByType
@@ -60,11 +105,3 @@ export type LiftStatisticsByTypeKey = LiftType | 'other'
60
105
  export type LiftStatisticsByType = {
61
106
  [key in LiftStatisticsByTypeKey]?: { count: number; lengthInKm: number }
62
107
  }
63
-
64
- export interface MapObjectStatistics {
65
- count: number
66
- lengthInKm: number
67
- minElevation?: number
68
- maxElevation?: number
69
- combinedElevationChange?: number
70
- }
package/src/Source.ts CHANGED
@@ -3,7 +3,7 @@ export enum SourceType {
3
3
  OPENSTREETMAP = 'openstreetmap',
4
4
  }
5
5
 
6
- export default interface Source {
6
+ export type Source = {
7
7
  type: SourceType
8
8
  id: string
9
9
  }
package/src/Status.ts CHANGED
@@ -1,3 +1,15 @@
1
+ /**
2
+ * Status of a feature.
3
+ *
4
+ * Note that this is not real-time status but indicates whether a feature is in operation when conditions permit or is abandoned, etc.
5
+ *
6
+ * Primarily derived from OpenStreetMap tags.
7
+ * Additionally, Skimap.org data provides status information for ski area features only.
8
+ *
9
+ * Tagging schemes supported are:
10
+ * - lifecycle prefixes (preferred) https://wiki.openstreetmap.org/wiki/Lifecycle_prefix
11
+ * - separate lifecycle tags ("proposed=yes", etc)
12
+ */
1
13
  export enum Status {
2
14
  Operating = 'operating',
3
15
  Disused = 'disused',
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './Activity'
2
1
  export * from './ElevationProfile'
3
2
  export * from './FeatureType'
4
3
  export * from './Lift'
@@ -0,0 +1,3 @@
1
+ export const exhaustiveMatchingGuard = (value: never): never => {
2
+ throw new Error(`Unhandled case: ${value}`)
3
+ }
@@ -1,5 +0,0 @@
1
- export declare enum Activity {
2
- Downhill = "downhill",
3
- Nordic = "nordic",
4
- Backcountry = "backcountry"
5
- }
package/dist/Activity.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Activity = void 0;
4
- var Activity;
5
- (function (Activity) {
6
- Activity["Downhill"] = "downhill";
7
- Activity["Nordic"] = "nordic";
8
- Activity["Backcountry"] = "backcountry";
9
- })(Activity || (exports.Activity = Activity = {}));
10
- //# sourceMappingURL=Activity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Activity.js","sourceRoot":"","sources":["../src/Activity.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,iCAAqB,CAAA;IACrB,6BAAiB,CAAA;IACjB,uCAA2B,CAAA;AAC7B,CAAC,EAJW,QAAQ,wBAAR,QAAQ,QAInB"}
package/src/Activity.ts DELETED
@@ -1,5 +0,0 @@
1
- export enum Activity {
2
- Downhill = 'downhill',
3
- Nordic = 'nordic',
4
- Backcountry = 'backcountry',
5
- }