@loaders.gl/kml 4.2.0-alpha.4 → 4.2.0-alpha.5
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/dist.dev.js +97 -151
- package/dist/dist.min.js +14 -0
- package/dist/gpx-loader.js +46 -46
- package/dist/index.cjs +11 -10
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/kml-loader.js +49 -42
- package/dist/tcx-loader.js +47 -50
- package/package.json +11 -7
- package/dist/gpx-loader.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/kml-loader.js.map +0 -1
- package/dist/tcx-loader.js.map +0 -1
package/dist/kml-loader.js
CHANGED
|
@@ -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';
|
|
6
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
7
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
3
8
|
const VERSION = typeof "4.2.0-alpha.4" !== 'undefined' ? "4.2.0-alpha.4" : '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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
package/dist/tcx-loader.js
CHANGED
|
@@ -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';
|
|
7
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
8
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
4
9
|
const VERSION = typeof "4.2.0-alpha.4" !== 'undefined' ? "4.2.0-alpha.4" : '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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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.
|
|
3
|
+
"version": "4.2.0-alpha.5",
|
|
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
|
|
40
|
-
"build-bundle": "ocular-bundle ./
|
|
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.
|
|
44
|
-
"@loaders.gl/loader-utils": "4.2.0-alpha.
|
|
45
|
-
"@loaders.gl/schema": "4.2.0-alpha.
|
|
44
|
+
"@loaders.gl/gis": "4.2.0-alpha.5",
|
|
45
|
+
"@loaders.gl/loader-utils": "4.2.0-alpha.5",
|
|
46
|
+
"@loaders.gl/schema": "4.2.0-alpha.5",
|
|
46
47
|
"@tmcw/togeojson": "^4.5.0",
|
|
47
48
|
"@xmldom/xmldom": "^0.7.13"
|
|
48
49
|
},
|
|
49
|
-
"
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@loaders.gl/core": "^4.0.0"
|
|
52
|
+
},
|
|
53
|
+
"gitHead": "32d95a81971f104e4dfeb88ab57065f05321a76a"
|
|
50
54
|
}
|
package/dist/gpx-loader.js.map
DELETED
|
@@ -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"}
|
package/dist/kml-loader.js.map
DELETED
|
@@ -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"}
|
package/dist/tcx-loader.js.map
DELETED
|
@@ -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,SAAQC,GAAG,QAAO,iBAAiB;AACnC,SAAQC,SAAS,QAAO,gBAAgB;AAIxC,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAQ3E,MAAMC,UAAU,GAAI;AACpB;AACA,wBAAwB;AAKxB,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,gCAAgC,CAAC;EAC7CC,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;UACzBC,MAAM,EAAE;YAACC,QAAQ,EAAE,CAAC,CAAC;YAAEC,MAAM,EAAE;UAAE,CAAC;UAClCJ,QAAQ,EAAEJ,OAAO,CAACI;QACpB,CAAC;QACD,OAAOF,KAAK;MACd;IACA,KAAK,QAAQ;MACX,OAAO1B,eAAe,CAACwB,OAAO,CAACI,QAAQ,CAAC;IAE1C;MACE,MAAM,IAAIK,KAAK,CAACR,UAAU,CAACL,KAAK,CAAC;EACrC;AACF"}
|