@loaders.gl/kml 4.0.0-alpha.4 → 4.0.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.
Files changed (45) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +2 -2
  4. package/dist/dist.min.js +1926 -0
  5. package/dist/es5/bundle.js +6 -0
  6. package/dist/es5/bundle.js.map +1 -0
  7. package/dist/es5/gpx-loader.js +81 -0
  8. package/dist/es5/gpx-loader.js.map +1 -0
  9. package/dist/es5/index.js +27 -0
  10. package/dist/es5/index.js.map +1 -0
  11. package/dist/es5/kml-loader.js +81 -0
  12. package/dist/es5/kml-loader.js.map +1 -0
  13. package/dist/es5/tcx-loader.js +81 -0
  14. package/dist/es5/tcx-loader.js.map +1 -0
  15. package/dist/esm/bundle.js +4 -0
  16. package/dist/esm/bundle.js.map +1 -0
  17. package/dist/esm/gpx-loader.js +54 -0
  18. package/dist/esm/gpx-loader.js.map +1 -0
  19. package/dist/esm/index.js +4 -0
  20. package/dist/esm/index.js.map +1 -0
  21. package/dist/esm/kml-loader.js +54 -0
  22. package/dist/esm/kml-loader.js.map +1 -0
  23. package/dist/esm/tcx-loader.js +54 -0
  24. package/dist/esm/tcx-loader.js.map +1 -0
  25. package/dist/gpx-loader.d.ts +36 -0
  26. package/dist/gpx-loader.d.ts.map +1 -0
  27. package/dist/gpx-loader.js +57 -49
  28. package/dist/index.d.ts +7 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +9 -4
  31. package/dist/kml-loader.d.ts +36 -0
  32. package/dist/kml-loader.d.ts.map +1 -0
  33. package/dist/kml-loader.js +58 -49
  34. package/dist/tcx-loader.d.ts +36 -0
  35. package/dist/tcx-loader.d.ts.map +1 -0
  36. package/dist/tcx-loader.js +59 -50
  37. package/package.json +9 -12
  38. package/src/gpx-loader.ts +34 -14
  39. package/src/kml-loader.ts +33 -13
  40. package/src/tcx-loader.ts +33 -12
  41. package/dist/bundle.js.map +0 -1
  42. package/dist/gpx-loader.js.map +0 -1
  43. package/dist/index.js.map +0 -1
  44. package/dist/kml-loader.js.map +0 -1
  45. package/dist/tcx-loader.js.map +0 -1
@@ -1,53 +1,61 @@
1
- import { geojsonToBinary } from '@loaders.gl/gis';
2
- import { gpx } from '@tmcw/togeojson';
3
- const VERSION = typeof "4.0.0-alpha.4" !== 'undefined' ? "4.0.0-alpha.4" : 'latest';
4
- const GPX_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<gpx";
5
- export const GPXLoader = {
6
- name: 'GPX (GPS exchange format)',
7
- id: 'gpx',
8
- module: 'kml',
9
- version: VERSION,
10
- extensions: ['gpx'],
11
- mimeTypes: ['application/gpx+xml'],
12
- text: true,
13
- tests: [GPX_HEADER],
14
- parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
15
- parseTextSync,
16
- options: {
17
- gpx: {},
18
- gis: {
19
- format: 'geojson'
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._typecheckGPXLoader = exports.GPXLoader = void 0;
4
+ const gis_1 = require("@loaders.gl/gis");
5
+ const togeojson_1 = require("@tmcw/togeojson");
6
+ // __VERSION__ is injected by babel-plugin-version-inline
7
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
9
+ const GPX_HEADER = `\
10
+ <?xml version="1.0" encoding="UTF-8"?>
11
+ <gpx`;
12
+ /**
13
+ * Loader for GPX (GPS exchange format)
14
+ */
15
+ exports.GPXLoader = {
16
+ name: 'GPX (GPS exchange format)',
17
+ id: 'gpx',
18
+ module: 'kml',
19
+ version: VERSION,
20
+ extensions: ['gpx'],
21
+ mimeTypes: ['application/gpx+xml'],
22
+ text: true,
23
+ tests: [GPX_HEADER],
24
+ parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
25
+ parseTextSync,
26
+ options: {
27
+ gpx: {},
28
+ gis: {}
20
29
  }
21
- }
22
30
  };
23
-
24
31
  function parseTextSync(text, options) {
25
- var _options$gpx, _options$gis;
26
-
27
- const doc = new DOMParser().parseFromString(text, 'text/xml');
28
- const geojson = gpx(doc);
29
-
30
- switch (options === null || options === void 0 ? void 0 : (_options$gpx = options.gpx) === null || _options$gpx === void 0 ? void 0 : _options$gpx.type) {
31
- case 'object-row-table':
32
- return geojson.features;
33
-
34
- default:
35
- }
36
-
37
- switch (options === null || options === void 0 ? void 0 : (_options$gis = options.gis) === null || _options$gis === void 0 ? void 0 : _options$gis.format) {
38
- case 'geojson':
39
- return geojson;
40
-
41
- case 'binary':
42
- return geojsonToBinary(geojson.features);
43
-
44
- case 'raw':
45
- return doc;
46
-
47
- default:
48
- throw new Error();
49
- }
32
+ const doc = new DOMParser().parseFromString(text, 'text/xml');
33
+ const geojson = (0, togeojson_1.gpx)(doc);
34
+ const shape = options?.gis?.format || options?.gpx?.type || options?.gpx?.shape;
35
+ switch (shape) {
36
+ case 'object-row-table': {
37
+ const table = {
38
+ shape: 'object-row-table',
39
+ data: geojson.features
40
+ };
41
+ return table;
42
+ }
43
+ case 'geojson-row-table': {
44
+ const table = {
45
+ shape: 'geojson-row-table',
46
+ data: geojson.features
47
+ };
48
+ return table;
49
+ }
50
+ case 'geojson':
51
+ return geojson;
52
+ case 'binary':
53
+ return (0, gis_1.geojsonToBinary)(geojson.features);
54
+ case 'raw':
55
+ return doc;
56
+ default:
57
+ // Default to geojson for backwards compatibility
58
+ return geojson;
59
+ }
50
60
  }
51
-
52
- export const _typecheckGPXLoader = GPXLoader;
53
- //# sourceMappingURL=gpx-loader.js.map
61
+ exports._typecheckGPXLoader = exports.GPXLoader;
@@ -0,0 +1,7 @@
1
+ export type { GPXLoaderOptions } from './gpx-loader';
2
+ export { GPXLoader } from './gpx-loader';
3
+ export type { KMLLoaderOptions } from './kml-loader';
4
+ export { KMLLoader } from './kml-loader';
5
+ export type { TCXLoaderOptions } from './tcx-loader';
6
+ export { TCXLoader } from './tcx-loader';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAEvC,YAAY,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAEvC,YAAY,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,9 @@
1
- export { GPXLoader } from './gpx-loader';
2
- export { KMLLoader } from './kml-loader';
3
- export { TCXLoader } from './tcx-loader';
4
- //# sourceMappingURL=index.js.map
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TCXLoader = exports.KMLLoader = exports.GPXLoader = void 0;
4
+ var gpx_loader_1 = require("./gpx-loader");
5
+ Object.defineProperty(exports, "GPXLoader", { enumerable: true, get: function () { return gpx_loader_1.GPXLoader; } });
6
+ var kml_loader_1 = require("./kml-loader");
7
+ Object.defineProperty(exports, "KMLLoader", { enumerable: true, get: function () { return kml_loader_1.KMLLoader; } });
8
+ var tcx_loader_1 = require("./tcx-loader");
9
+ Object.defineProperty(exports, "TCXLoader", { enumerable: true, get: function () { return tcx_loader_1.TCXLoader; } });
@@ -0,0 +1,36 @@
1
+ import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
2
+ import { GeoJSONRowTable, FeatureCollection, ObjectRowTable } from '@loaders.gl/schema';
3
+ export type KMLLoaderOptions = LoaderOptions & {
4
+ kml?: {
5
+ shape?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
6
+ /** @deprecated. Use options.kml.shape */
7
+ type?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
8
+ };
9
+ gis?: {
10
+ /** @deprecated. Use options.kml.shape */
11
+ format?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
12
+ };
13
+ };
14
+ /**
15
+ * Loader for KML (Keyhole Markup Language)
16
+ */
17
+ export declare const KMLLoader: {
18
+ name: string;
19
+ id: string;
20
+ module: string;
21
+ version: any;
22
+ extensions: string[];
23
+ mimeTypes: string[];
24
+ text: boolean;
25
+ tests: string[];
26
+ parse: (arrayBuffer: any, options?: KMLLoaderOptions) => Promise<Document | FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties> | ObjectRowTable | GeoJSONRowTable | import("@loaders.gl/schema").BinaryFeatures>;
27
+ parseTextSync: typeof parseTextSync;
28
+ options: {
29
+ kml: {};
30
+ gis: {};
31
+ };
32
+ };
33
+ declare function parseTextSync(text: string, options?: KMLLoaderOptions): Document | FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties> | ObjectRowTable | GeoJSONRowTable | import("@loaders.gl/schema").BinaryFeatures;
34
+ export declare const _typecheckKMLLoader: LoaderWithParser;
35
+ export {};
36
+ //# sourceMappingURL=kml-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kml-loader.d.ts","sourceRoot":"","sources":["../src/kml-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAG9E,OAAO,EAAC,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAMtF,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE;QACJ,KAAK,CAAC,EAAE,kBAAkB,GAAG,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;QAChF,yCAAyC;QACzC,IAAI,CAAC,EAAE,kBAAkB,GAAG,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;KAChF,CAAC;IACF,GAAG,CAAC,EAAE;QACJ,yCAAyC;QACzC,MAAM,CAAC,EAAE,kBAAkB,GAAG,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;KAClF,CAAC;CACH,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;wCASiB,gBAAgB;;;;;;CAOtD,CAAC;AAEF,iBAAS,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,kLA+B9D;AAED,eAAO,MAAM,mBAAmB,EAAE,gBAA4B,CAAC"}
@@ -1,53 +1,62 @@
1
- import { geojsonToBinary } from '@loaders.gl/gis';
2
- import { kml } from '@tmcw/togeojson';
3
- const VERSION = typeof "4.0.0-alpha.4" !== 'undefined' ? "4.0.0-alpha.4" : 'latest';
4
- const KML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kml xmlns=\"http://www.opengis.net/kml/2.2\">";
5
- export const KMLLoader = {
6
- name: 'KML (Keyhole Markup Language)',
7
- id: 'kml',
8
- module: 'kml',
9
- version: VERSION,
10
- extensions: ['kml'],
11
- mimeTypes: ['application/vnd.google-earth.kml+xml'],
12
- text: true,
13
- tests: [KML_HEADER],
14
- parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
15
- parseTextSync,
16
- options: {
17
- kml: {},
18
- gis: {
19
- format: 'geojson'
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._typecheckKMLLoader = exports.KMLLoader = void 0;
4
+ const gis_1 = require("@loaders.gl/gis");
5
+ const togeojson_1 = require("@tmcw/togeojson");
6
+ // __VERSION__ is injected by babel-plugin-version-inline
7
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
9
+ const KML_HEADER = `\
10
+ <?xml version="1.0" encoding="UTF-8"?>
11
+ <kml xmlns="http://www.opengis.net/kml/2.2">`;
12
+ /**
13
+ * Loader for KML (Keyhole Markup Language)
14
+ */
15
+ exports.KMLLoader = {
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: {},
28
+ gis: {}
20
29
  }
21
- }
22
30
  };
23
-
24
31
  function parseTextSync(text, options) {
25
- var _options$kml, _options$gis;
26
-
27
- const doc = new DOMParser().parseFromString(text, 'text/xml');
28
- const geojson = kml(doc);
29
-
30
- switch (options === null || options === void 0 ? void 0 : (_options$kml = options.kml) === null || _options$kml === void 0 ? void 0 : _options$kml.type) {
31
- case 'object-row-table':
32
- return geojson.features;
33
-
34
- default:
35
- }
36
-
37
- switch (options === null || options === void 0 ? void 0 : (_options$gis = options.gis) === null || _options$gis === void 0 ? void 0 : _options$gis.format) {
38
- case 'geojson':
39
- return geojson;
40
-
41
- case 'binary':
42
- return geojsonToBinary(geojson.features);
43
-
44
- case 'raw':
45
- return doc;
46
-
47
- default:
48
- throw new Error();
49
- }
32
+ const doc = new DOMParser().parseFromString(text, 'text/xml');
33
+ const geojson = (0, togeojson_1.kml)(doc);
34
+ // backwards compatibility
35
+ const shape = options?.gis?.format || options?.kml?.type || options?.kml?.shape;
36
+ switch (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-row-table': {
45
+ const table = {
46
+ shape: 'geojson-row-table',
47
+ data: geojson.features
48
+ };
49
+ return table;
50
+ }
51
+ case 'geojson':
52
+ return geojson;
53
+ case 'binary':
54
+ return (0, gis_1.geojsonToBinary)(geojson.features);
55
+ case 'raw':
56
+ return doc;
57
+ default:
58
+ // Default to geojson for backwards compatibility
59
+ return geojson;
60
+ }
50
61
  }
51
-
52
- export const _typecheckKMLLoader = KMLLoader;
53
- //# sourceMappingURL=kml-loader.js.map
62
+ exports._typecheckKMLLoader = exports.KMLLoader;
@@ -0,0 +1,36 @@
1
+ import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
2
+ import type { GeoJSONRowTable, FeatureCollection, ObjectRowTable } from '@loaders.gl/schema';
3
+ export type TCXLoaderOptions = LoaderOptions & {
4
+ tcx?: {
5
+ shape?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
6
+ /** @deprecated. Use options.tcx.shape */
7
+ type?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
8
+ };
9
+ gis?: {
10
+ /** @deprecated. Use options.tcx.shape */
11
+ format?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
12
+ };
13
+ };
14
+ /**
15
+ * Loader for TCX (Training Center XML) - Garmin GPS track format
16
+ */
17
+ export declare const TCXLoader: {
18
+ name: string;
19
+ id: string;
20
+ module: string;
21
+ version: any;
22
+ extensions: string[];
23
+ mimeTypes: string[];
24
+ text: boolean;
25
+ tests: string[];
26
+ parse: (arrayBuffer: any, options?: TCXLoaderOptions) => Promise<Document | FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties> | ObjectRowTable | GeoJSONRowTable | import("@loaders.gl/schema").BinaryFeatures>;
27
+ parseTextSync: typeof parseTextSync;
28
+ options: {
29
+ tcx: {};
30
+ gis: {};
31
+ };
32
+ };
33
+ declare function parseTextSync(text: string, options?: TCXLoaderOptions): Document | FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties> | ObjectRowTable | GeoJSONRowTable | import("@loaders.gl/schema").BinaryFeatures;
34
+ export declare const _typecheckTCXLoader: LoaderWithParser;
35
+ export {};
36
+ //# sourceMappingURL=tcx-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tcx-loader.d.ts","sourceRoot":"","sources":["../src/tcx-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAG9E,OAAO,KAAK,EAAC,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAM3F,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE;QACJ,KAAK,CAAC,EAAE,kBAAkB,GAAG,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;QAChF,yCAAyC;QACzC,IAAI,CAAC,EAAE,kBAAkB,GAAG,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;KAChF,CAAC;IACF,GAAG,CAAC,EAAE;QACJ,yCAAyC;QACzC,MAAM,CAAC,EAAE,kBAAkB,GAAG,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;KAClF,CAAC;CACH,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;wCASiB,gBAAgB;;;;;;CAOtD,CAAC;AAEF,iBAAS,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,kLAgC9D;AAED,eAAO,MAAM,mBAAmB,EAAE,gBAA4B,CAAC"}
@@ -1,53 +1,62 @@
1
- import { geojsonToBinary } from '@loaders.gl/gis';
2
- import { tcx } from '@tmcw/togeojson';
3
- const VERSION = typeof "4.0.0-alpha.4" !== 'undefined' ? "4.0.0-alpha.4" : 'latest';
4
- const TCX_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<TrainingCenterDatabase";
5
- export const TCXLoader = {
6
- name: 'TCX (Training Center XML)',
7
- id: 'tcx',
8
- module: 'kml',
9
- version: VERSION,
10
- extensions: ['tcx'],
11
- mimeTypes: ['application/vnd.garmin.tcx+xml'],
12
- text: true,
13
- tests: [TCX_HEADER],
14
- parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
15
- parseTextSync,
16
- options: {
17
- tcx: {},
18
- gis: {
19
- format: 'geojson'
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._typecheckTCXLoader = exports.TCXLoader = void 0;
4
+ const gis_1 = require("@loaders.gl/gis");
5
+ const togeojson_1 = require("@tmcw/togeojson");
6
+ // __VERSION__ is injected by babel-plugin-version-inline
7
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
9
+ const TCX_HEADER = `\
10
+ <?xml version="1.0" encoding="UTF-8"?>
11
+ <TrainingCenterDatabase`;
12
+ /**
13
+ * Loader for TCX (Training Center XML) - Garmin GPS track format
14
+ */
15
+ exports.TCXLoader = {
16
+ name: 'TCX (Training Center XML)',
17
+ id: 'tcx',
18
+ module: 'kml',
19
+ version: VERSION,
20
+ extensions: ['tcx'],
21
+ mimeTypes: ['application/vnd.garmin.tcx+xml'],
22
+ text: true,
23
+ tests: [TCX_HEADER],
24
+ parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
25
+ parseTextSync,
26
+ options: {
27
+ tcx: {},
28
+ gis: {}
20
29
  }
21
- }
22
30
  };
23
-
24
- function parseTextSync(text, options = {}) {
25
- var _options$tcx, _options$gis;
26
-
27
- const doc = new DOMParser().parseFromString(text, 'text/xml');
28
- const geojson = tcx(doc);
29
-
30
- switch (options === null || options === void 0 ? void 0 : (_options$tcx = options.tcx) === null || _options$tcx === void 0 ? void 0 : _options$tcx.type) {
31
- case 'object-row-table':
32
- return geojson.features;
33
-
34
- default:
35
- }
36
-
37
- switch (options === null || options === void 0 ? void 0 : (_options$gis = options.gis) === null || _options$gis === void 0 ? void 0 : _options$gis.format) {
38
- case 'geojson':
39
- return geojson;
40
-
41
- case 'binary':
42
- return geojsonToBinary(geojson.features);
43
-
44
- case 'raw':
45
- return doc;
46
-
47
- default:
48
- throw new Error();
49
- }
31
+ function parseTextSync(text, options) {
32
+ const doc = new DOMParser().parseFromString(text, 'text/xml');
33
+ const geojson = (0, togeojson_1.tcx)(doc);
34
+ // backwards compatibility
35
+ const shape = options?.gis?.format || options?.tcx?.type || options?.tcx?.shape;
36
+ switch (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-row-table': {
45
+ const table = {
46
+ shape: 'geojson-row-table',
47
+ data: geojson.features
48
+ };
49
+ return table;
50
+ }
51
+ case 'geojson':
52
+ return geojson;
53
+ case 'binary':
54
+ return (0, gis_1.geojsonToBinary)(geojson.features);
55
+ case 'raw':
56
+ return doc;
57
+ default:
58
+ // Default to geojson for backwards compatibility
59
+ return geojson;
60
+ }
50
61
  }
51
-
52
- export const _typecheckTCXLoader = TCXLoader;
53
- //# sourceMappingURL=tcx-loader.js.map
62
+ exports._typecheckTCXLoader = exports.TCXLoader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/kml",
3
- "version": "4.0.0-alpha.4",
3
+ "version": "4.0.0-alpha.6",
4
4
  "description": "Framework-independent loader for the KML format",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -18,9 +18,9 @@
18
18
  "point cloud",
19
19
  "KML"
20
20
  ],
21
- "types": "src/index.ts",
22
- "main": "dist/index.js",
23
- "module": "dist/index.js",
21
+ "types": "dist/index.d.ts",
22
+ "main": "dist/es5/index.js",
23
+ "module": "dist/esm/index.js",
24
24
  "sideEffects": false,
25
25
  "files": [
26
26
  "src",
@@ -29,16 +29,13 @@
29
29
  ],
30
30
  "scripts": {
31
31
  "pre-build": "npm run build-bundle",
32
- "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/bundle.js"
32
+ "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js"
33
33
  },
34
34
  "dependencies": {
35
- "@loaders.gl/gis": "4.0.0-alpha.4",
36
- "@loaders.gl/loader-utils": "4.0.0-alpha.4",
37
- "@loaders.gl/schema": "4.0.0-alpha.4",
35
+ "@loaders.gl/gis": "4.0.0-alpha.6",
36
+ "@loaders.gl/loader-utils": "4.0.0-alpha.6",
37
+ "@loaders.gl/schema": "4.0.0-alpha.6",
38
38
  "@tmcw/togeojson": "^4.5.0"
39
39
  },
40
- "peerDependencies": {
41
- "@loaders.gl/core": "^3.0.0"
42
- },
43
- "gitHead": "53026061b3c8871f7e96d3a5826125cc6613bddc"
40
+ "gitHead": "acc1985050dfaa0f1f0c066f8da5bce7454a046c"
44
41
  }
package/src/gpx-loader.ts CHANGED
@@ -1,13 +1,22 @@
1
- import type {LoaderOptions} from '@loaders.gl/loader-utils';
1
+ import type {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';
2
2
  import {geojsonToBinary} from '@loaders.gl/gis';
3
3
  import {gpx} from '@tmcw/togeojson';
4
+ import type {GeoJSONRowTable, FeatureCollection, ObjectRowTable} from '@loaders.gl/schema';
4
5
 
5
6
  // __VERSION__ is injected by babel-plugin-version-inline
6
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
8
  const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
8
9
 
9
10
  export type GPXLoaderOptions = LoaderOptions & {
10
- gpx?: {};
11
+ gpx?: {
12
+ shape?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
13
+ /** @deprecated. Use options.gpx.shape */
14
+ type?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
15
+ };
16
+ gis?: {
17
+ /** @deprecated. Use options.gpx.shape */
18
+ format?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
19
+ };
11
20
  };
12
21
 
13
22
  const GPX_HEADER = `\
@@ -26,26 +35,36 @@ export const GPXLoader = {
26
35
  mimeTypes: ['application/gpx+xml'],
27
36
  text: true,
28
37
  tests: [GPX_HEADER],
29
- parse: async (arrayBuffer, options) =>
38
+ parse: async (arrayBuffer, options?: GPXLoaderOptions) =>
30
39
  parseTextSync(new TextDecoder().decode(arrayBuffer), options),
31
40
  parseTextSync,
32
41
  options: {
33
42
  gpx: {},
34
- gis: {format: 'geojson'}
43
+ gis: {}
35
44
  }
36
45
  };
37
46
 
38
- function parseTextSync(text: string, options: any) {
47
+ function parseTextSync(text: string, options?: GPXLoaderOptions) {
39
48
  const doc = new DOMParser().parseFromString(text, 'text/xml');
40
- const geojson = gpx(doc);
49
+ const geojson: FeatureCollection = gpx(doc);
41
50
 
42
- switch (options?.gpx?.type) {
43
- case 'object-row-table':
44
- return geojson.features;
45
- default:
46
- }
51
+ const shape = options?.gis?.format || options?.gpx?.type || options?.gpx?.shape;
47
52
 
48
- switch (options?.gis?.format) {
53
+ switch (shape) {
54
+ case 'object-row-table': {
55
+ const table: ObjectRowTable = {
56
+ shape: 'object-row-table',
57
+ data: geojson.features
58
+ };
59
+ return table;
60
+ }
61
+ case 'geojson-row-table': {
62
+ const table: GeoJSONRowTable = {
63
+ shape: 'geojson-row-table',
64
+ data: geojson.features
65
+ };
66
+ return table;
67
+ }
49
68
  case 'geojson':
50
69
  return geojson;
51
70
  case 'binary':
@@ -53,8 +72,9 @@ function parseTextSync(text: string, options: any) {
53
72
  case 'raw':
54
73
  return doc;
55
74
  default:
56
- throw new Error();
75
+ // Default to geojson for backwards compatibility
76
+ return geojson;
57
77
  }
58
78
  }
59
79
 
60
- export const _typecheckGPXLoader = GPXLoader;
80
+ export const _typecheckGPXLoader: LoaderWithParser = GPXLoader;