@loaders.gl/kml 4.0.0-alpha.5 → 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.
- package/dist/bundle.js +2 -2
- package/dist/dist.min.js +782 -385
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/gpx-loader.js +81 -0
- package/dist/es5/gpx-loader.js.map +1 -0
- package/dist/es5/index.js +27 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/kml-loader.js +81 -0
- package/dist/es5/kml-loader.js.map +1 -0
- package/dist/es5/tcx-loader.js +81 -0
- package/dist/es5/tcx-loader.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/gpx-loader.js +54 -0
- package/dist/esm/gpx-loader.js.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/kml-loader.js +54 -0
- package/dist/esm/kml-loader.js.map +1 -0
- package/dist/esm/tcx-loader.js +54 -0
- package/dist/esm/tcx-loader.js.map +1 -0
- package/dist/gpx-loader.d.ts +16 -26
- package/dist/gpx-loader.d.ts.map +1 -1
- package/dist/gpx-loader.js +57 -49
- package/dist/index.js +9 -4
- package/dist/kml-loader.d.ts +14 -7
- package/dist/kml-loader.d.ts.map +1 -1
- package/dist/kml-loader.js +58 -49
- package/dist/tcx-loader.d.ts +14 -7
- package/dist/tcx-loader.d.ts.map +1 -1
- package/dist/tcx-loader.js +59 -50
- package/package.json +7 -7
- package/src/gpx-loader.ts +34 -14
- package/src/kml-loader.ts +33 -13
- package/src/tcx-loader.ts +33 -12
- package/dist/bundle.js.map +0 -1
- 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/gpx-loader.js
CHANGED
|
@@ -1,53 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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; } });
|
package/dist/kml-loader.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
};
|
|
4
13
|
};
|
|
5
14
|
/**
|
|
6
15
|
* Loader for KML (Keyhole Markup Language)
|
|
@@ -14,16 +23,14 @@ export declare const KMLLoader: {
|
|
|
14
23
|
mimeTypes: string[];
|
|
15
24
|
text: boolean;
|
|
16
25
|
tests: string[];
|
|
17
|
-
parse: (arrayBuffer: any, options
|
|
26
|
+
parse: (arrayBuffer: any, options?: KMLLoaderOptions) => Promise<Document | FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties> | ObjectRowTable | GeoJSONRowTable | import("@loaders.gl/schema").BinaryFeatures>;
|
|
18
27
|
parseTextSync: typeof parseTextSync;
|
|
19
28
|
options: {
|
|
20
29
|
kml: {};
|
|
21
|
-
gis: {
|
|
22
|
-
format: string;
|
|
23
|
-
};
|
|
30
|
+
gis: {};
|
|
24
31
|
};
|
|
25
32
|
};
|
|
26
|
-
declare function parseTextSync(text: string, options
|
|
33
|
+
declare function parseTextSync(text: string, options?: KMLLoaderOptions): Document | FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties> | ObjectRowTable | GeoJSONRowTable | import("@loaders.gl/schema").BinaryFeatures;
|
|
27
34
|
export declare const _typecheckKMLLoader: LoaderWithParser;
|
|
28
35
|
export {};
|
|
29
36
|
//# sourceMappingURL=kml-loader.d.ts.map
|
package/dist/kml-loader.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
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"}
|
package/dist/kml-loader.js
CHANGED
|
@@ -1,53 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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;
|
package/dist/tcx-loader.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
};
|
|
4
13
|
};
|
|
5
14
|
/**
|
|
6
15
|
* Loader for TCX (Training Center XML) - Garmin GPS track format
|
|
@@ -14,16 +23,14 @@ export declare const TCXLoader: {
|
|
|
14
23
|
mimeTypes: string[];
|
|
15
24
|
text: boolean;
|
|
16
25
|
tests: string[];
|
|
17
|
-
parse: (arrayBuffer: any, options
|
|
26
|
+
parse: (arrayBuffer: any, options?: TCXLoaderOptions) => Promise<Document | FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties> | ObjectRowTable | GeoJSONRowTable | import("@loaders.gl/schema").BinaryFeatures>;
|
|
18
27
|
parseTextSync: typeof parseTextSync;
|
|
19
28
|
options: {
|
|
20
29
|
tcx: {};
|
|
21
|
-
gis: {
|
|
22
|
-
format: string;
|
|
23
|
-
};
|
|
30
|
+
gis: {};
|
|
24
31
|
};
|
|
25
32
|
};
|
|
26
|
-
declare function parseTextSync(text: string, options?:
|
|
33
|
+
declare function parseTextSync(text: string, options?: TCXLoaderOptions): Document | FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties> | ObjectRowTable | GeoJSONRowTable | import("@loaders.gl/schema").BinaryFeatures;
|
|
27
34
|
export declare const _typecheckTCXLoader: LoaderWithParser;
|
|
28
35
|
export {};
|
|
29
36
|
//# sourceMappingURL=tcx-loader.d.ts.map
|
package/dist/tcx-loader.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
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"}
|
package/dist/tcx-loader.js
CHANGED
|
@@ -1,53 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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.
|
|
3
|
+
"version": "4.0.0-alpha.6",
|
|
4
4
|
"description": "Framework-independent loader for the KML format",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"KML"
|
|
20
20
|
],
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
|
-
"main": "dist/index.js",
|
|
23
|
-
"module": "dist/index.js",
|
|
22
|
+
"main": "dist/es5/index.js",
|
|
23
|
+
"module": "dist/esm/index.js",
|
|
24
24
|
"sideEffects": false,
|
|
25
25
|
"files": [
|
|
26
26
|
"src",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
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.
|
|
36
|
-
"@loaders.gl/loader-utils": "4.0.0-alpha.
|
|
37
|
-
"@loaders.gl/schema": "4.0.0-alpha.
|
|
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
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "acc1985050dfaa0f1f0c066f8da5bce7454a046c"
|
|
41
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: {
|
|
43
|
+
gis: {}
|
|
35
44
|
}
|
|
36
45
|
};
|
|
37
46
|
|
|
38
|
-
function parseTextSync(text: string, options
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
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;
|
package/src/kml-loader.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
2
2
|
import {geojsonToBinary} from '@loaders.gl/gis';
|
|
3
3
|
import {kml} from '@tmcw/togeojson';
|
|
4
|
+
import {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 KMLLoaderOptions = LoaderOptions & {
|
|
10
|
-
kml?: {
|
|
11
|
+
kml?: {
|
|
12
|
+
shape?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
|
|
13
|
+
/** @deprecated. Use options.kml.shape */
|
|
14
|
+
type?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
|
|
15
|
+
};
|
|
16
|
+
gis?: {
|
|
17
|
+
/** @deprecated. Use options.kml.shape */
|
|
18
|
+
format?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
|
|
19
|
+
};
|
|
11
20
|
};
|
|
12
21
|
|
|
13
22
|
const KML_HEADER = `\
|
|
@@ -26,26 +35,36 @@ export const KMLLoader = {
|
|
|
26
35
|
mimeTypes: ['application/vnd.google-earth.kml+xml'],
|
|
27
36
|
text: true,
|
|
28
37
|
tests: [KML_HEADER],
|
|
29
|
-
parse: async (arrayBuffer, options) =>
|
|
38
|
+
parse: async (arrayBuffer, options?: KMLLoaderOptions) =>
|
|
30
39
|
parseTextSync(new TextDecoder().decode(arrayBuffer), options),
|
|
31
40
|
parseTextSync,
|
|
32
41
|
options: {
|
|
33
42
|
kml: {},
|
|
34
|
-
gis: {
|
|
43
|
+
gis: {}
|
|
35
44
|
}
|
|
36
45
|
};
|
|
37
46
|
|
|
38
|
-
function parseTextSync(text: string, options
|
|
47
|
+
function parseTextSync(text: string, options?: KMLLoaderOptions) {
|
|
39
48
|
const doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
40
|
-
const geojson = kml(doc);
|
|
49
|
+
const geojson: FeatureCollection = kml(doc);
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
// backwards compatibility
|
|
52
|
+
const shape = options?.gis?.format || options?.kml?.type || options?.kml?.shape;
|
|
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,7 +72,8 @@ function parseTextSync(text: string, options: any) {
|
|
|
53
72
|
case 'raw':
|
|
54
73
|
return doc;
|
|
55
74
|
default:
|
|
56
|
-
|
|
75
|
+
// Default to geojson for backwards compatibility
|
|
76
|
+
return geojson;
|
|
57
77
|
}
|
|
58
78
|
}
|
|
59
79
|
|