@loaders.gl/kml 4.2.0-alpha.4 → 4.2.0-alpha.6

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,52 +1,59 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { kml } from '@tmcw/togeojson';
2
5
  import { DOMParser } from '@xmldom/xmldom';
3
- const VERSION = typeof "4.2.0-alpha.4" !== 'undefined' ? "4.2.0-alpha.4" : 'latest';
6
+ // __VERSION__ is injected by babel-plugin-version-inline
7
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
+ const VERSION = typeof "4.2.0-alpha.5" !== 'undefined' ? "4.2.0-alpha.5" : 'latest';
4
9
  const KML_HEADER = `\
5
10
  <?xml version="1.0" encoding="UTF-8"?>
6
11
  <kml xmlns="http://www.opengis.net/kml/2.2">`;
12
+ /**
13
+ * Loader for KML (Keyhole Markup Language)
14
+ */
7
15
  export const KMLLoader = {
8
- name: 'KML (Keyhole Markup Language)',
9
- id: 'kml',
10
- module: 'kml',
11
- version: VERSION,
12
- extensions: ['kml'],
13
- mimeTypes: ['application/vnd.google-earth.kml+xml'],
14
- text: true,
15
- tests: [KML_HEADER],
16
- parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
17
- parseTextSync,
18
- options: {
19
- kml: {
20
- shape: 'geojson-table'
21
- },
22
- gis: {}
23
- }
16
+ name: 'KML (Keyhole Markup Language)',
17
+ id: 'kml',
18
+ module: 'kml',
19
+ version: VERSION,
20
+ extensions: ['kml'],
21
+ mimeTypes: ['application/vnd.google-earth.kml+xml'],
22
+ text: true,
23
+ tests: [KML_HEADER],
24
+ parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
25
+ parseTextSync,
26
+ options: {
27
+ kml: { shape: 'geojson-table' },
28
+ gis: {}
29
+ }
24
30
  };
25
31
  function parseTextSync(text, options) {
26
- const doc = new DOMParser().parseFromString(text, 'text/xml');
27
- const geojson = kml(doc);
28
- const kmlOptions = {
29
- ...KMLLoader.options.kml,
30
- ...(options === null || options === void 0 ? void 0 : options.kml)
31
- };
32
- switch (kmlOptions.shape) {
33
- case 'geojson-table':
34
- {
35
- const table = {
36
- shape: 'geojson-table',
37
- type: 'FeatureCollection',
38
- features: geojson.features
39
- };
40
- return table;
41
- }
42
- case 'object-row-table':
43
- const table = {
44
- shape: 'object-row-table',
45
- data: geojson.features
46
- };
47
- return table;
48
- default:
49
- throw new Error(kmlOptions.shape);
50
- }
32
+ const doc = new DOMParser().parseFromString(text, 'text/xml');
33
+ const geojson = kml(doc);
34
+ const kmlOptions = { ...KMLLoader.options.kml, ...options?.kml };
35
+ switch (kmlOptions.shape) {
36
+ case 'geojson-table': {
37
+ const table = {
38
+ shape: 'geojson-table',
39
+ type: 'FeatureCollection',
40
+ features: geojson.features
41
+ };
42
+ return table;
43
+ }
44
+ // case 'geojson':
45
+ // return geojson;
46
+ // case 'binary':
47
+ // return geojsonToBinary(geojson.features);
48
+ // case 'raw':
49
+ // return doc;
50
+ case 'object-row-table':
51
+ const table = {
52
+ shape: 'object-row-table',
53
+ data: geojson.features
54
+ };
55
+ return table;
56
+ default:
57
+ throw new Error(kmlOptions.shape);
58
+ }
51
59
  }
52
- //# sourceMappingURL=kml-loader.js.map
@@ -1,61 +1,58 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { geojsonToBinary } from '@loaders.gl/gis';
2
5
  import { tcx } from '@tmcw/togeojson';
3
6
  import { DOMParser } from '@xmldom/xmldom';
4
- const VERSION = typeof "4.2.0-alpha.4" !== 'undefined' ? "4.2.0-alpha.4" : 'latest';
7
+ // __VERSION__ is injected by babel-plugin-version-inline
8
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
9
+ const VERSION = typeof "4.2.0-alpha.5" !== 'undefined' ? "4.2.0-alpha.5" : 'latest';
5
10
  const TCX_HEADER = `\
6
11
  <?xml version="1.0" encoding="UTF-8"?>
7
12
  <TrainingCenterDatabase`;
13
+ /**
14
+ * Loader for TCX (Training Center XML) - Garmin GPS track format
15
+ */
8
16
  export const TCXLoader = {
9
- name: 'TCX (Training Center XML)',
10
- id: 'tcx',
11
- module: 'kml',
12
- version: VERSION,
13
- extensions: ['tcx'],
14
- mimeTypes: ['application/vnd.garmin.tcx+xml'],
15
- text: true,
16
- tests: [TCX_HEADER],
17
- parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
18
- parseTextSync,
19
- options: {
20
- tcx: {
21
- shape: 'geojson-table'
22
- },
23
- gis: {}
24
- }
17
+ name: 'TCX (Training Center XML)',
18
+ id: 'tcx',
19
+ module: 'kml',
20
+ version: VERSION,
21
+ extensions: ['tcx'],
22
+ mimeTypes: ['application/vnd.garmin.tcx+xml'],
23
+ text: true,
24
+ tests: [TCX_HEADER],
25
+ parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
26
+ parseTextSync,
27
+ options: {
28
+ tcx: { shape: 'geojson-table' },
29
+ gis: {}
30
+ }
25
31
  };
26
32
  function parseTextSync(text, options) {
27
- const doc = new DOMParser().parseFromString(text, 'text/xml');
28
- const geojson = tcx(doc);
29
- const tcxOptions = {
30
- ...TCXLoader.options.tcx,
31
- ...(options === null || options === void 0 ? void 0 : options.tcx)
32
- };
33
- switch (tcxOptions.shape) {
34
- case 'object-row-table':
35
- {
36
- const table = {
37
- shape: 'object-row-table',
38
- data: geojson.features
39
- };
40
- return table;
41
- }
42
- case 'geojson-table':
43
- {
44
- const table = {
45
- shape: 'geojson-table',
46
- type: 'FeatureCollection',
47
- schema: {
48
- metadata: {},
49
- fields: []
50
- },
51
- features: geojson.features
52
- };
53
- return table;
54
- }
55
- case 'binary':
56
- return geojsonToBinary(geojson.features);
57
- default:
58
- throw new Error(tcxOptions.shape);
59
- }
33
+ const doc = new DOMParser().parseFromString(text, 'text/xml');
34
+ const geojson = tcx(doc);
35
+ const tcxOptions = { ...TCXLoader.options.tcx, ...options?.tcx };
36
+ switch (tcxOptions.shape) {
37
+ case 'object-row-table': {
38
+ const table = {
39
+ shape: 'object-row-table',
40
+ data: geojson.features
41
+ };
42
+ return table;
43
+ }
44
+ case 'geojson-table': {
45
+ const table = {
46
+ shape: 'geojson-table',
47
+ type: 'FeatureCollection',
48
+ schema: { metadata: {}, fields: [] },
49
+ features: geojson.features
50
+ };
51
+ return table;
52
+ }
53
+ case 'binary':
54
+ return geojsonToBinary(geojson.features);
55
+ default:
56
+ throw new Error(tcxOptions.shape);
57
+ }
60
58
  }
61
- //# sourceMappingURL=tcx-loader.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/kml",
3
- "version": "4.2.0-alpha.4",
3
+ "version": "4.2.0-alpha.6",
4
4
  "description": "Framework-independent loader for the KML format",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -36,15 +36,19 @@
36
36
  "README.md"
37
37
  ],
38
38
  "scripts": {
39
- "pre-build": "npm run build-bundle && npm run build-bundle -- --env=dev",
40
- "build-bundle": "ocular-bundle ./src/index.ts"
39
+ "pre-build": "npm run build-bundle && npm run build-bundle-dev",
40
+ "build-bundle": "ocular-bundle ./bundle.ts --output=dist/dist.min.js",
41
+ "build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
41
42
  },
42
43
  "dependencies": {
43
- "@loaders.gl/gis": "4.2.0-alpha.4",
44
- "@loaders.gl/loader-utils": "4.2.0-alpha.4",
45
- "@loaders.gl/schema": "4.2.0-alpha.4",
44
+ "@loaders.gl/gis": "4.2.0-alpha.6",
45
+ "@loaders.gl/loader-utils": "4.2.0-alpha.6",
46
+ "@loaders.gl/schema": "4.2.0-alpha.6",
46
47
  "@tmcw/togeojson": "^4.5.0",
47
48
  "@xmldom/xmldom": "^0.7.13"
48
49
  },
49
- "gitHead": "6c52dee5c3f005648a394cc4aee7fc37005c8e83"
50
+ "peerDependencies": {
51
+ "@loaders.gl/core": "^4.0.0"
52
+ },
53
+ "gitHead": "37bd8ca71763529f18727ee4bf29dd176aa914ca"
50
54
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"gpx-loader.js","names":["geojsonToBinary","gpx","DOMParser","VERSION","GPX_HEADER","GPXLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","shape","gis","doc","parseFromString","geojson","gpxOptions","table","data","features","type","Error"],"sources":["../src/gpx-loader.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport type {\n GeoJSONTable,\n FeatureCollection,\n ObjectRowTable,\n BinaryFeatureCollection\n} from '@loaders.gl/schema';\nimport {gpx} from '@tmcw/togeojson';\nimport {DOMParser} from '@xmldom/xmldom';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type GPXLoaderOptions = LoaderOptions & {\n gpx?: {\n shape?: 'object-row-table' | 'geojson-table' | 'binary' | 'raw';\n };\n};\n\nconst GPX_HEADER = `\\\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<gpx`;\n\n/**\n * Loader for GPX (GPS exchange format)\n */\nexport const GPXLoader: LoaderWithParser<\n ObjectRowTable | GeoJSONTable | BinaryFeatureCollection,\n never,\n GPXLoaderOptions\n> = {\n name: 'GPX (GPS exchange format)',\n id: 'gpx',\n module: 'kml',\n version: VERSION,\n extensions: ['gpx'],\n mimeTypes: ['application/gpx+xml'],\n text: true,\n tests: [GPX_HEADER],\n parse: async (arrayBuffer, options?: GPXLoaderOptions) =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync,\n options: {\n gpx: {shape: 'geojson-table'},\n gis: {}\n }\n};\n\nfunction parseTextSync(\n text: string,\n options?: GPXLoaderOptions\n): ObjectRowTable | GeoJSONTable | BinaryFeatureCollection {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson: FeatureCollection = gpx(doc);\n\n const gpxOptions = {...GPXLoader.options.gpx, ...options?.gpx};\n\n switch (gpxOptions.shape) {\n case 'object-row-table': {\n const table: ObjectRowTable = {\n shape: 'object-row-table',\n data: geojson.features\n };\n return table;\n }\n case 'geojson-table': {\n const table: GeoJSONTable = {\n shape: 'geojson-table',\n type: 'FeatureCollection',\n features: geojson.features\n };\n return table;\n }\n case 'binary':\n return geojsonToBinary(geojson.features);\n\n default:\n throw new Error(gpxOptions.shape);\n }\n}\n"],"mappings":"AAKA,SAAQA,eAAe,QAAO,iBAAiB;AAO/C,SAAQC,GAAG,QAAO,iBAAiB;AACnC,SAAQC,SAAS,QAAO,gBAAgB;AAIxC,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAQ3E,MAAMC,UAAU,GAAI;AACpB;AACA,KAAK;AAKL,OAAO,MAAMC,SAIZ,GAAG;EACFC,IAAI,EAAE,2BAA2B;EACjCC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEN,OAAO;EAChBO,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,qBAAqB,CAAC;EAClCC,IAAI,EAAE,IAAI;EACVC,KAAK,EAAE,CAACT,UAAU,CAAC;EACnBU,KAAK,EAAE,MAAAA,CAAOC,WAAW,EAAEC,OAA0B,KACnDC,aAAa,CAAC,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CAACJ,WAAW,CAAC,EAAEC,OAAO,CAAC;EAC/DC,aAAa;EACbD,OAAO,EAAE;IACPf,GAAG,EAAE;MAACmB,KAAK,EAAE;IAAe,CAAC;IAC7BC,GAAG,EAAE,CAAC;EACR;AACF,CAAC;AAED,SAASJ,aAAaA,CACpBL,IAAY,EACZI,OAA0B,EAC+B;EACzD,MAAMM,GAAG,GAAG,IAAIpB,SAAS,CAAC,CAAC,CAACqB,eAAe,CAACX,IAAI,EAAE,UAAU,CAAC;EAC7D,MAAMY,OAA0B,GAAGvB,GAAG,CAACqB,GAAG,CAAC;EAE3C,MAAMG,UAAU,GAAG;IAAC,GAAGpB,SAAS,CAACW,OAAO,CAACf,GAAG;IAAE,IAAGe,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEf,GAAG;EAAA,CAAC;EAE9D,QAAQwB,UAAU,CAACL,KAAK;IACtB,KAAK,kBAAkB;MAAE;QACvB,MAAMM,KAAqB,GAAG;UAC5BN,KAAK,EAAE,kBAAkB;UACzBO,IAAI,EAAEH,OAAO,CAACI;QAChB,CAAC;QACD,OAAOF,KAAK;MACd;IACA,KAAK,eAAe;MAAE;QACpB,MAAMA,KAAmB,GAAG;UAC1BN,KAAK,EAAE,eAAe;UACtBS,IAAI,EAAE,mBAAmB;UACzBD,QAAQ,EAAEJ,OAAO,CAACI;QACpB,CAAC;QACD,OAAOF,KAAK;MACd;IACA,KAAK,QAAQ;MACX,OAAO1B,eAAe,CAACwB,OAAO,CAACI,QAAQ,CAAC;IAE1C;MACE,MAAM,IAAIE,KAAK,CAACL,UAAU,CAACL,KAAK,CAAC;EACrC;AACF"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["GPXLoader","KMLLoader","TCXLoader"],"sources":["../src/index.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// POLYFILL: DOMParser\n// - Node: Yes\n// - Browser: No\n\nexport type {GPXLoaderOptions} from './gpx-loader';\nexport {GPXLoader} from './gpx-loader';\n\nexport type {KMLLoaderOptions} from './kml-loader';\nexport {KMLLoader} from './kml-loader';\n\nexport type {TCXLoaderOptions} from './tcx-loader';\nexport {TCXLoader} from './tcx-loader';\n"],"mappings":"SASQA,SAAS;AAAA,SAGTC,SAAS;AAAA,SAGTC,SAAS"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"kml-loader.js","names":["kml","DOMParser","VERSION","KML_HEADER","KMLLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","shape","gis","doc","parseFromString","geojson","kmlOptions","table","type","features","data","Error"],"sources":["../src/kml-loader.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\n// import {geojsonToBinary} from '@loaders.gl/gis';\n// import {GeoJSONTable} from '@loaders.gl/schema';\nimport {FeatureCollection, GeoJSONTable, ObjectRowTable} from '@loaders.gl/schema';\nimport {kml} from '@tmcw/togeojson';\nimport {DOMParser} from '@xmldom/xmldom';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type KMLLoaderOptions = LoaderOptions & {\n kml?: {\n shape?: 'object-row-table' | 'geojson-table' | 'binary' | 'raw';\n };\n};\n\nconst KML_HEADER = `\\\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kml xmlns=\"http://www.opengis.net/kml/2.2\">`;\n\n/**\n * Loader for KML (Keyhole Markup Language)\n */\nexport const KMLLoader: LoaderWithParser<ObjectRowTable | GeoJSONTable, never, KMLLoaderOptions> = {\n name: 'KML (Keyhole Markup Language)',\n id: 'kml',\n module: 'kml',\n version: VERSION,\n extensions: ['kml'],\n mimeTypes: ['application/vnd.google-earth.kml+xml'],\n text: true,\n tests: [KML_HEADER],\n parse: async (arrayBuffer, options?: KMLLoaderOptions) =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync,\n options: {\n kml: {shape: 'geojson-table'},\n gis: {}\n }\n};\n\nfunction parseTextSync(text: string, options?: KMLLoaderOptions): ObjectRowTable | GeoJSONTable {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson: FeatureCollection = kml(doc);\n\n const kmlOptions = {...KMLLoader.options.kml, ...options?.kml};\n\n switch (kmlOptions.shape) {\n case 'geojson-table': {\n const table: GeoJSONTable = {\n shape: 'geojson-table',\n type: 'FeatureCollection',\n features: geojson.features\n };\n return table;\n }\n // case 'geojson':\n // return geojson;\n // case 'binary':\n // return geojsonToBinary(geojson.features);\n // case 'raw':\n // return doc;\n case 'object-row-table':\n const table: ObjectRowTable = {\n shape: 'object-row-table',\n data: geojson.features\n };\n return table;\n default:\n throw new Error(kmlOptions.shape);\n }\n}\n"],"mappings":"AAQA,SAAQA,GAAG,QAAO,iBAAiB;AACnC,SAAQC,SAAS,QAAO,gBAAgB;AAIxC,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAQ3E,MAAMC,UAAU,GAAI;AACpB;AACA,6CAA6C;AAK7C,OAAO,MAAMC,SAAmF,GAAG;EACjGC,IAAI,EAAE,+BAA+B;EACrCC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEN,OAAO;EAChBO,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,sCAAsC,CAAC;EACnDC,IAAI,EAAE,IAAI;EACVC,KAAK,EAAE,CAACT,UAAU,CAAC;EACnBU,KAAK,EAAE,MAAAA,CAAOC,WAAW,EAAEC,OAA0B,KACnDC,aAAa,CAAC,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CAACJ,WAAW,CAAC,EAAEC,OAAO,CAAC;EAC/DC,aAAa;EACbD,OAAO,EAAE;IACPf,GAAG,EAAE;MAACmB,KAAK,EAAE;IAAe,CAAC;IAC7BC,GAAG,EAAE,CAAC;EACR;AACF,CAAC;AAED,SAASJ,aAAaA,CAACL,IAAY,EAAEI,OAA0B,EAAiC;EAC9F,MAAMM,GAAG,GAAG,IAAIpB,SAAS,CAAC,CAAC,CAACqB,eAAe,CAACX,IAAI,EAAE,UAAU,CAAC;EAC7D,MAAMY,OAA0B,GAAGvB,GAAG,CAACqB,GAAG,CAAC;EAE3C,MAAMG,UAAU,GAAG;IAAC,GAAGpB,SAAS,CAACW,OAAO,CAACf,GAAG;IAAE,IAAGe,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEf,GAAG;EAAA,CAAC;EAE9D,QAAQwB,UAAU,CAACL,KAAK;IACtB,KAAK,eAAe;MAAE;QACpB,MAAMM,KAAmB,GAAG;UAC1BN,KAAK,EAAE,eAAe;UACtBO,IAAI,EAAE,mBAAmB;UACzBC,QAAQ,EAAEJ,OAAO,CAACI;QACpB,CAAC;QACD,OAAOF,KAAK;MACd;IAOA,KAAK,kBAAkB;MACrB,MAAMA,KAAqB,GAAG;QAC5BN,KAAK,EAAE,kBAAkB;QACzBS,IAAI,EAAEL,OAAO,CAACI;MAChB,CAAC;MACD,OAAOF,KAAK;IACd;MACE,MAAM,IAAII,KAAK,CAACL,UAAU,CAACL,KAAK,CAAC;EACrC;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tcx-loader.js","names":["geojsonToBinary","tcx","DOMParser","VERSION","TCX_HEADER","TCXLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","shape","gis","doc","parseFromString","geojson","tcxOptions","table","data","features","type","schema","metadata","fields","Error"],"sources":["../src/tcx-loader.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport type {\n GeoJSONTable,\n FeatureCollection,\n ObjectRowTable,\n BinaryFeatureCollection\n} from '@loaders.gl/schema';\nimport {tcx} from '@tmcw/togeojson';\nimport {DOMParser} from '@xmldom/xmldom';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type TCXLoaderOptions = LoaderOptions & {\n tcx?: {\n shape?: 'object-row-table' | 'geojson-table' | 'binary' | 'raw';\n };\n};\n\nconst TCX_HEADER = `\\\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<TrainingCenterDatabase`;\n\n/**\n * Loader for TCX (Training Center XML) - Garmin GPS track format\n */\nexport const TCXLoader: LoaderWithParser<\n ObjectRowTable | GeoJSONTable | BinaryFeatureCollection,\n never,\n TCXLoaderOptions\n> = {\n name: 'TCX (Training Center XML)',\n id: 'tcx',\n module: 'kml',\n version: VERSION,\n extensions: ['tcx'],\n mimeTypes: ['application/vnd.garmin.tcx+xml'],\n text: true,\n tests: [TCX_HEADER],\n parse: async (arrayBuffer, options?: TCXLoaderOptions) =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync,\n options: {\n tcx: {shape: 'geojson-table'},\n gis: {}\n }\n};\n\nfunction parseTextSync(\n text: string,\n options?: TCXLoaderOptions\n): ObjectRowTable | GeoJSONTable | BinaryFeatureCollection {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson: FeatureCollection = tcx(doc);\n\n const tcxOptions = {...TCXLoader.options.tcx, ...options?.tcx};\n\n switch (tcxOptions.shape) {\n case 'object-row-table': {\n const table: ObjectRowTable = {\n shape: 'object-row-table',\n data: geojson.features\n };\n return table;\n }\n case 'geojson-table': {\n const table: GeoJSONTable = {\n shape: 'geojson-table',\n type: 'FeatureCollection',\n schema: {metadata: {}, fields: []},\n features: geojson.features\n };\n return table;\n }\n case 'binary':\n return geojsonToBinary(geojson.features);\n\n default:\n throw new Error(tcxOptions.shape);\n }\n}\n"],"mappings":"AAKA,SAAQA,eAAe,QAAO,iBAAiB;AAO/C,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