openskidata-format 2.0.0 → 2.1.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/Source.d.ts CHANGED
@@ -6,3 +6,5 @@ export type Source = {
6
6
  type: SourceType;
7
7
  id: string;
8
8
  };
9
+ export declare function getSourceURL(source: Source): string;
10
+ export declare function getSourceName(type: SourceType): string;
package/dist/Source.js CHANGED
@@ -1,9 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SourceType = void 0;
4
+ exports.getSourceURL = getSourceURL;
5
+ exports.getSourceName = getSourceName;
6
+ const exhaustiveMatchingGuard_1 = require("./util/exhaustiveMatchingGuard");
4
7
  var SourceType;
5
8
  (function (SourceType) {
6
9
  SourceType["SKIMAP_ORG"] = "skimap.org";
7
10
  SourceType["OPENSTREETMAP"] = "openstreetmap";
8
11
  })(SourceType || (exports.SourceType = SourceType = {}));
12
+ function getSourceURL(source) {
13
+ switch (source.type) {
14
+ case SourceType.OPENSTREETMAP:
15
+ return 'https://www.openstreetmap.org/' + source.id;
16
+ case SourceType.SKIMAP_ORG:
17
+ return 'https://www.skimap.org/SkiAreas/view/' + source.id;
18
+ default:
19
+ return (0, exhaustiveMatchingGuard_1.exhaustiveMatchingGuard)(source.type);
20
+ }
21
+ }
22
+ function getSourceName(type) {
23
+ switch (type) {
24
+ case SourceType.OPENSTREETMAP:
25
+ return 'OpenStreetMap';
26
+ case SourceType.SKIMAP_ORG:
27
+ return 'Skimap.org';
28
+ default:
29
+ return (0, exhaustiveMatchingGuard_1.exhaustiveMatchingGuard)(type);
30
+ }
31
+ }
9
32
  //# sourceMappingURL=Source.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Source.js","sourceRoot":"","sources":["../src/Source.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,uCAAyB,CAAA;IACzB,6CAA+B,CAAA;AACjC,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB"}
1
+ {"version":3,"file":"Source.js","sourceRoot":"","sources":["../src/Source.ts"],"names":[],"mappings":";;;AAYA,oCASC;AAED,sCASC;AAhCD,4EAAwE;AAExE,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,uCAAyB,CAAA;IACzB,6CAA+B,CAAA;AACjC,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAOD,SAAgB,YAAY,CAAC,MAAc;IACzC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,UAAU,CAAC,aAAa;YAC3B,OAAO,gCAAgC,GAAG,MAAM,CAAC,EAAE,CAAA;QACrD,KAAK,UAAU,CAAC,UAAU;YACxB,OAAO,uCAAuC,GAAG,MAAM,CAAC,EAAE,CAAA;QAC5D;YACE,OAAO,IAAA,iDAAuB,EAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC/C,CAAC;AACH,CAAC;AAED,SAAgB,aAAa,CAAC,IAAgB;IAC5C,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,UAAU,CAAC,aAAa;YAC3B,OAAO,eAAe,CAAA;QACxB,KAAK,UAAU,CAAC,UAAU;YACxB,OAAO,YAAY,CAAA;QACrB;YACE,OAAO,IAAA,iDAAuB,EAAC,IAAI,CAAC,CAAA;IACxC,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openskidata-format",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Data format for OpenSkiMap.org",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/Source.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { exhaustiveMatchingGuard } from './util/exhaustiveMatchingGuard'
2
+
1
3
  export enum SourceType {
2
4
  SKIMAP_ORG = 'skimap.org',
3
5
  OPENSTREETMAP = 'openstreetmap',
@@ -7,3 +9,25 @@ export type Source = {
7
9
  type: SourceType
8
10
  id: string
9
11
  }
12
+
13
+ export function getSourceURL(source: Source): string {
14
+ switch (source.type) {
15
+ case SourceType.OPENSTREETMAP:
16
+ return 'https://www.openstreetmap.org/' + source.id
17
+ case SourceType.SKIMAP_ORG:
18
+ return 'https://www.skimap.org/SkiAreas/view/' + source.id
19
+ default:
20
+ return exhaustiveMatchingGuard(source.type)
21
+ }
22
+ }
23
+
24
+ export function getSourceName(type: SourceType): string {
25
+ switch (type) {
26
+ case SourceType.OPENSTREETMAP:
27
+ return 'OpenStreetMap'
28
+ case SourceType.SKIMAP_ORG:
29
+ return 'Skimap.org'
30
+ default:
31
+ return exhaustiveMatchingGuard(type)
32
+ }
33
+ }