@loaders.gl/kml 4.0.1 → 4.0.3
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 +24 -11
- package/dist/gpx-loader.d.ts.map +1 -1
- package/dist/gpx-loader.js +9 -5
- package/dist/gpx-loader.js.map +1 -1
- package/dist/index.cjs +11 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kml-loader.d.ts.map +1 -1
- package/dist/kml-loader.js +6 -4
- package/dist/kml-loader.js.map +1 -1
- package/dist/tcx-loader.d.ts.map +1 -1
- package/dist/tcx-loader.js +9 -5
- package/dist/tcx-loader.js.map +1 -1
- package/package.json +5 -5
- package/src/gpx-loader.ts +7 -4
- package/src/index.ts +3 -0
- package/src/kml-loader.ts +7 -4
- package/src/tcx-loader.ts +7 -5
package/dist/dist.dev.js
CHANGED
|
@@ -6328,15 +6328,20 @@ var __exports__ = (() => {
|
|
|
6328
6328
|
parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
|
|
6329
6329
|
parseTextSync,
|
|
6330
6330
|
options: {
|
|
6331
|
-
gpx: {
|
|
6331
|
+
gpx: {
|
|
6332
|
+
shape: "geojson-table"
|
|
6333
|
+
},
|
|
6332
6334
|
gis: {}
|
|
6333
6335
|
}
|
|
6334
6336
|
};
|
|
6335
6337
|
function parseTextSync(text, options) {
|
|
6336
6338
|
const doc = new import_xmldom.DOMParser().parseFromString(text, "text/xml");
|
|
6337
6339
|
const geojson = gpx(doc);
|
|
6338
|
-
const
|
|
6339
|
-
|
|
6340
|
+
const gpxOptions = {
|
|
6341
|
+
...GPXLoader.options.gpx,
|
|
6342
|
+
...options?.gpx
|
|
6343
|
+
};
|
|
6344
|
+
switch (gpxOptions.shape) {
|
|
6340
6345
|
case "object-row-table": {
|
|
6341
6346
|
const table = {
|
|
6342
6347
|
shape: "object-row-table",
|
|
@@ -6355,7 +6360,7 @@ var __exports__ = (() => {
|
|
|
6355
6360
|
case "binary":
|
|
6356
6361
|
return geojsonToBinary(geojson.features);
|
|
6357
6362
|
default:
|
|
6358
|
-
throw new Error(shape);
|
|
6363
|
+
throw new Error(gpxOptions.shape);
|
|
6359
6364
|
}
|
|
6360
6365
|
}
|
|
6361
6366
|
|
|
@@ -6385,8 +6390,11 @@ var __exports__ = (() => {
|
|
|
6385
6390
|
function parseTextSync2(text, options) {
|
|
6386
6391
|
const doc = new import_xmldom2.DOMParser().parseFromString(text, "text/xml");
|
|
6387
6392
|
const geojson = kml(doc);
|
|
6388
|
-
const
|
|
6389
|
-
|
|
6393
|
+
const kmlOptions = {
|
|
6394
|
+
...KMLLoader.options.kml,
|
|
6395
|
+
...options?.kml
|
|
6396
|
+
};
|
|
6397
|
+
switch (kmlOptions.shape) {
|
|
6390
6398
|
case "geojson-table": {
|
|
6391
6399
|
const table2 = {
|
|
6392
6400
|
shape: "geojson-table",
|
|
@@ -6402,7 +6410,7 @@ var __exports__ = (() => {
|
|
|
6402
6410
|
};
|
|
6403
6411
|
return table;
|
|
6404
6412
|
default:
|
|
6405
|
-
throw new Error(shape);
|
|
6413
|
+
throw new Error(kmlOptions.shape);
|
|
6406
6414
|
}
|
|
6407
6415
|
}
|
|
6408
6416
|
|
|
@@ -6423,15 +6431,20 @@ var __exports__ = (() => {
|
|
|
6423
6431
|
parse: async (arrayBuffer, options) => parseTextSync3(new TextDecoder().decode(arrayBuffer), options),
|
|
6424
6432
|
parseTextSync: parseTextSync3,
|
|
6425
6433
|
options: {
|
|
6426
|
-
tcx: {
|
|
6434
|
+
tcx: {
|
|
6435
|
+
shape: "geojson-table"
|
|
6436
|
+
},
|
|
6427
6437
|
gis: {}
|
|
6428
6438
|
}
|
|
6429
6439
|
};
|
|
6430
6440
|
function parseTextSync3(text, options) {
|
|
6431
6441
|
const doc = new import_xmldom3.DOMParser().parseFromString(text, "text/xml");
|
|
6432
6442
|
const geojson = tcx(doc);
|
|
6433
|
-
const
|
|
6434
|
-
|
|
6443
|
+
const tcxOptions = {
|
|
6444
|
+
...TCXLoader.options.tcx,
|
|
6445
|
+
...options?.tcx
|
|
6446
|
+
};
|
|
6447
|
+
switch (tcxOptions.shape) {
|
|
6435
6448
|
case "object-row-table": {
|
|
6436
6449
|
const table = {
|
|
6437
6450
|
shape: "object-row-table",
|
|
@@ -6450,7 +6463,7 @@ var __exports__ = (() => {
|
|
|
6450
6463
|
case "binary":
|
|
6451
6464
|
return geojsonToBinary(geojson.features);
|
|
6452
6465
|
default:
|
|
6453
|
-
throw new Error(shape);
|
|
6466
|
+
throw new Error(tcxOptions.shape);
|
|
6454
6467
|
}
|
|
6455
6468
|
}
|
|
6456
6469
|
return __toCommonJS(src_exports);
|
package/dist/gpx-loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpx-loader.d.ts","sourceRoot":"","sources":["../src/gpx-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gpx-loader.d.ts","sourceRoot":"","sources":["../src/gpx-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAE9E,OAAO,KAAK,EACV,YAAY,EAEZ,cAAc,EACd,uBAAuB,EACxB,MAAM,oBAAoB,CAAC;AAQ5B,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE;QACJ,KAAK,CAAC,EAAE,kBAAkB,GAAG,eAAe,GAAG,QAAQ,GAAG,KAAK,CAAC;KACjE,CAAC;CACH,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBAAgB,CACtC,cAAc,GAAG,YAAY,GAAG,uBAAuB,EACvD,KAAK,EACL,gBAAgB,CAiBjB,CAAC"}
|
package/dist/gpx-loader.js
CHANGED
|
@@ -17,16 +17,20 @@ export const GPXLoader = {
|
|
|
17
17
|
parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
|
|
18
18
|
parseTextSync,
|
|
19
19
|
options: {
|
|
20
|
-
gpx: {
|
|
20
|
+
gpx: {
|
|
21
|
+
shape: 'geojson-table'
|
|
22
|
+
},
|
|
21
23
|
gis: {}
|
|
22
24
|
}
|
|
23
25
|
};
|
|
24
26
|
function parseTextSync(text, options) {
|
|
25
|
-
var _options$gpx;
|
|
26
27
|
const doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
27
28
|
const geojson = gpx(doc);
|
|
28
|
-
const
|
|
29
|
-
|
|
29
|
+
const gpxOptions = {
|
|
30
|
+
...GPXLoader.options.gpx,
|
|
31
|
+
...(options === null || options === void 0 ? void 0 : options.gpx)
|
|
32
|
+
};
|
|
33
|
+
switch (gpxOptions.shape) {
|
|
30
34
|
case 'object-row-table':
|
|
31
35
|
{
|
|
32
36
|
const table = {
|
|
@@ -47,7 +51,7 @@ function parseTextSync(text, options) {
|
|
|
47
51
|
case 'binary':
|
|
48
52
|
return geojsonToBinary(geojson.features);
|
|
49
53
|
default:
|
|
50
|
-
throw new Error(shape);
|
|
54
|
+
throw new Error(gpxOptions.shape);
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
//# sourceMappingURL=gpx-loader.js.map
|
package/dist/gpx-loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpx-loader.js","names":["geojsonToBinary","gpx","DOMParser","VERSION","__VERSION__","GPX_HEADER","GPXLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","
|
|
1
|
+
{"version":3,"file":"gpx-loader.js","names":["geojsonToBinary","gpx","DOMParser","VERSION","__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, MIT license\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":"AAIA,SAAQA,eAAe,QAAO,iBAAiB;AAO/C,SAAQC,GAAG,QAAO,iBAAiB;AACnC,SAAQC,SAAS,QAAO,gBAAgB;AAIxC,MAAMC,OAAO,GAAG,OAAOC,WAAW,KAAK,WAAW,GAAGA,WAAW,GAAG,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,EAAEP,OAAO;EAChBQ,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;IACPhB,GAAG,EAAE;MAACoB,KAAK,EAAE;IAAe,CAAC;IAC7BC,GAAG,EAAE,CAAC;EACR;AACF,CAAC;AAED,SAASJ,aAAaA,CACpBL,IAAY,EACZI,OAA0B,EAC+B;EACzD,MAAMM,GAAG,GAAG,IAAIrB,SAAS,CAAC,CAAC,CAACsB,eAAe,CAACX,IAAI,EAAE,UAAU,CAAC;EAC7D,MAAMY,OAA0B,GAAGxB,GAAG,CAACsB,GAAG,CAAC;EAE3C,MAAMG,UAAU,GAAG;IAAC,GAAGpB,SAAS,CAACW,OAAO,CAAChB,GAAG;IAAE,IAAGgB,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEhB,GAAG;EAAA,CAAC;EAE9D,QAAQyB,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,OAAO3B,eAAe,CAACyB,OAAO,CAACI,QAAQ,CAAC;IAE1C;MACE,MAAM,IAAIE,KAAK,CAACL,UAAU,CAACL,KAAK,CAAC;EACrC;AACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -45,16 +45,15 @@ var GPXLoader = {
|
|
|
45
45
|
parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
|
|
46
46
|
parseTextSync,
|
|
47
47
|
options: {
|
|
48
|
-
gpx: {},
|
|
48
|
+
gpx: { shape: "geojson-table" },
|
|
49
49
|
gis: {}
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
function parseTextSync(text, options) {
|
|
53
|
-
var _a;
|
|
54
53
|
const doc = new import_xmldom.DOMParser().parseFromString(text, "text/xml");
|
|
55
54
|
const geojson = (0, import_togeojson.gpx)(doc);
|
|
56
|
-
const
|
|
57
|
-
switch (shape) {
|
|
55
|
+
const gpxOptions = { ...GPXLoader.options.gpx, ...options == null ? void 0 : options.gpx };
|
|
56
|
+
switch (gpxOptions.shape) {
|
|
58
57
|
case "object-row-table": {
|
|
59
58
|
const table = {
|
|
60
59
|
shape: "object-row-table",
|
|
@@ -73,7 +72,7 @@ function parseTextSync(text, options) {
|
|
|
73
72
|
case "binary":
|
|
74
73
|
return (0, import_gis.geojsonToBinary)(geojson.features);
|
|
75
74
|
default:
|
|
76
|
-
throw new Error(shape);
|
|
75
|
+
throw new Error(gpxOptions.shape);
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
|
|
@@ -100,11 +99,10 @@ var KMLLoader = {
|
|
|
100
99
|
}
|
|
101
100
|
};
|
|
102
101
|
function parseTextSync2(text, options) {
|
|
103
|
-
var _a, _b;
|
|
104
102
|
const doc = new import_xmldom2.DOMParser().parseFromString(text, "text/xml");
|
|
105
103
|
const geojson = (0, import_togeojson2.kml)(doc);
|
|
106
|
-
const
|
|
107
|
-
switch (shape) {
|
|
104
|
+
const kmlOptions = { ...KMLLoader.options.kml, ...options == null ? void 0 : options.kml };
|
|
105
|
+
switch (kmlOptions.shape) {
|
|
108
106
|
case "geojson-table": {
|
|
109
107
|
const table2 = {
|
|
110
108
|
shape: "geojson-table",
|
|
@@ -120,7 +118,7 @@ function parseTextSync2(text, options) {
|
|
|
120
118
|
};
|
|
121
119
|
return table;
|
|
122
120
|
default:
|
|
123
|
-
throw new Error(shape);
|
|
121
|
+
throw new Error(kmlOptions.shape);
|
|
124
122
|
}
|
|
125
123
|
}
|
|
126
124
|
|
|
@@ -143,16 +141,15 @@ var TCXLoader = {
|
|
|
143
141
|
parse: async (arrayBuffer, options) => parseTextSync3(new TextDecoder().decode(arrayBuffer), options),
|
|
144
142
|
parseTextSync: parseTextSync3,
|
|
145
143
|
options: {
|
|
146
|
-
tcx: {},
|
|
144
|
+
tcx: { shape: "geojson-table" },
|
|
147
145
|
gis: {}
|
|
148
146
|
}
|
|
149
147
|
};
|
|
150
148
|
function parseTextSync3(text, options) {
|
|
151
|
-
var _a;
|
|
152
149
|
const doc = new import_xmldom3.DOMParser().parseFromString(text, "text/xml");
|
|
153
150
|
const geojson = (0, import_togeojson3.tcx)(doc);
|
|
154
|
-
const
|
|
155
|
-
switch (shape) {
|
|
151
|
+
const tcxOptions = { ...TCXLoader.options.tcx, ...options == null ? void 0 : options.tcx };
|
|
152
|
+
switch (tcxOptions.shape) {
|
|
156
153
|
case "object-row-table": {
|
|
157
154
|
const table = {
|
|
158
155
|
shape: "object-row-table",
|
|
@@ -171,6 +168,6 @@ function parseTextSync3(text, options) {
|
|
|
171
168
|
case "binary":
|
|
172
169
|
return (0, import_gis2.geojsonToBinary)(geojson.features);
|
|
173
170
|
default:
|
|
174
|
-
throw new Error(shape);
|
|
171
|
+
throw new Error(tcxOptions.shape);
|
|
175
172
|
}
|
|
176
173
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["GPXLoader","KMLLoader","TCXLoader"],"sources":["../src/index.ts"],"sourcesContent":["// 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":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["GPXLoader","KMLLoader","TCXLoader"],"sources":["../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\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":"SAQQA,SAAS;AAAA,SAGTC,SAAS;AAAA,SAGTC,SAAS"}
|
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":"
|
|
1
|
+
{"version":3,"file":"kml-loader.d.ts","sourceRoot":"","sources":["../src/kml-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAG9E,OAAO,EAAoB,YAAY,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAQnF,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE;QACJ,KAAK,CAAC,EAAE,kBAAkB,GAAG,eAAe,GAAG,QAAQ,GAAG,KAAK,CAAC;KACjE,CAAC;CACH,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBAAgB,CAAC,cAAc,GAAG,YAAY,EAAE,KAAK,EAAE,gBAAgB,CAgB9F,CAAC"}
|
package/dist/kml-loader.js
CHANGED
|
@@ -23,11 +23,13 @@ export const KMLLoader = {
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
function parseTextSync(text, options) {
|
|
26
|
-
var _options$kml, _KMLLoader$options$km;
|
|
27
26
|
const doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
28
27
|
const geojson = kml(doc);
|
|
29
|
-
const
|
|
30
|
-
|
|
28
|
+
const kmlOptions = {
|
|
29
|
+
...KMLLoader.options.kml,
|
|
30
|
+
...(options === null || options === void 0 ? void 0 : options.kml)
|
|
31
|
+
};
|
|
32
|
+
switch (kmlOptions.shape) {
|
|
31
33
|
case 'geojson-table':
|
|
32
34
|
{
|
|
33
35
|
const table = {
|
|
@@ -44,7 +46,7 @@ function parseTextSync(text, options) {
|
|
|
44
46
|
};
|
|
45
47
|
return table;
|
|
46
48
|
default:
|
|
47
|
-
throw new Error(shape);
|
|
49
|
+
throw new Error(kmlOptions.shape);
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
//# sourceMappingURL=kml-loader.js.map
|
package/dist/kml-loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kml-loader.js","names":["kml","DOMParser","VERSION","__VERSION__","KML_HEADER","KMLLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","shape","gis","
|
|
1
|
+
{"version":3,"file":"kml-loader.js","names":["kml","DOMParser","VERSION","__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, MIT license\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":"AAOA,SAAQA,GAAG,QAAO,iBAAiB;AACnC,SAAQC,SAAS,QAAO,gBAAgB;AAIxC,MAAMC,OAAO,GAAG,OAAOC,WAAW,KAAK,WAAW,GAAGA,WAAW,GAAG,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,KA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ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcx-loader.d.ts","sourceRoot":"","sources":["../src/tcx-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tcx-loader.d.ts","sourceRoot":"","sources":["../src/tcx-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAE9E,OAAO,KAAK,EACV,YAAY,EAEZ,cAAc,EACd,uBAAuB,EACxB,MAAM,oBAAoB,CAAC;AAQ5B,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE;QACJ,KAAK,CAAC,EAAE,kBAAkB,GAAG,eAAe,GAAG,QAAQ,GAAG,KAAK,CAAC;KACjE,CAAC;CACH,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBAAgB,CACtC,cAAc,GAAG,YAAY,GAAG,uBAAuB,EACvD,KAAK,EACL,gBAAgB,CAiBjB,CAAC"}
|
package/dist/tcx-loader.js
CHANGED
|
@@ -17,16 +17,20 @@ export const TCXLoader = {
|
|
|
17
17
|
parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
|
|
18
18
|
parseTextSync,
|
|
19
19
|
options: {
|
|
20
|
-
tcx: {
|
|
20
|
+
tcx: {
|
|
21
|
+
shape: 'geojson-table'
|
|
22
|
+
},
|
|
21
23
|
gis: {}
|
|
22
24
|
}
|
|
23
25
|
};
|
|
24
26
|
function parseTextSync(text, options) {
|
|
25
|
-
var _options$tcx;
|
|
26
27
|
const doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
27
28
|
const geojson = tcx(doc);
|
|
28
|
-
const
|
|
29
|
-
|
|
29
|
+
const tcxOptions = {
|
|
30
|
+
...TCXLoader.options.tcx,
|
|
31
|
+
...(options === null || options === void 0 ? void 0 : options.tcx)
|
|
32
|
+
};
|
|
33
|
+
switch (tcxOptions.shape) {
|
|
30
34
|
case 'object-row-table':
|
|
31
35
|
{
|
|
32
36
|
const table = {
|
|
@@ -47,7 +51,7 @@ function parseTextSync(text, options) {
|
|
|
47
51
|
case 'binary':
|
|
48
52
|
return geojsonToBinary(geojson.features);
|
|
49
53
|
default:
|
|
50
|
-
throw new Error(shape);
|
|
54
|
+
throw new Error(tcxOptions.shape);
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
//# sourceMappingURL=tcx-loader.js.map
|
package/dist/tcx-loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcx-loader.js","names":["geojsonToBinary","tcx","DOMParser","VERSION","__VERSION__","TCX_HEADER","TCXLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","
|
|
1
|
+
{"version":3,"file":"tcx-loader.js","names":["geojsonToBinary","tcx","DOMParser","VERSION","__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","Error"],"sources":["../src/tcx-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\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 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":"AAIA,SAAQA,eAAe,QAAO,iBAAiB;AAO/C,SAAQC,GAAG,QAAO,iBAAiB;AACnC,SAAQC,SAAS,QAAO,gBAAgB;AAIxC,MAAMC,OAAO,GAAG,OAAOC,WAAW,KAAK,WAAW,GAAGA,WAAW,GAAG,QAAQ;AAQ3E,MAAMC,UAAU,GAAI;AACpB;AACA,wBAAwB;AAKxB,OAAO,MAAMC,SAIZ,GAAG;EACFC,IAAI,EAAE,2BAA2B;EACjCC,EAAE,EAAE,KAAK;EACTC,MAAM,EA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;MACE,MAAM,IAAIE,KAAK,CAACL,UAAU,CAACL,KAAK,CAAC;EACrC;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/kml",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "Framework-independent loader for the KML format",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"build-bundle": "ocular-bundle ./src/index.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@loaders.gl/gis": "4.0.
|
|
44
|
-
"@loaders.gl/loader-utils": "4.0.
|
|
45
|
-
"@loaders.gl/schema": "4.0.
|
|
43
|
+
"@loaders.gl/gis": "4.0.3",
|
|
44
|
+
"@loaders.gl/loader-utils": "4.0.3",
|
|
45
|
+
"@loaders.gl/schema": "4.0.3",
|
|
46
46
|
"@tmcw/togeojson": "^4.5.0",
|
|
47
47
|
"@xmldom/xmldom": "^0.7.13"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "03c871839b36c997249dabae1844df53a35d3760"
|
|
50
50
|
}
|
package/src/gpx-loader.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
1
4
|
import type {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
2
5
|
import {geojsonToBinary} from '@loaders.gl/gis';
|
|
3
6
|
import type {
|
|
@@ -43,7 +46,7 @@ export const GPXLoader: LoaderWithParser<
|
|
|
43
46
|
parseTextSync(new TextDecoder().decode(arrayBuffer), options),
|
|
44
47
|
parseTextSync,
|
|
45
48
|
options: {
|
|
46
|
-
gpx: {},
|
|
49
|
+
gpx: {shape: 'geojson-table'},
|
|
47
50
|
gis: {}
|
|
48
51
|
}
|
|
49
52
|
};
|
|
@@ -55,9 +58,9 @@ function parseTextSync(
|
|
|
55
58
|
const doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
56
59
|
const geojson: FeatureCollection = gpx(doc);
|
|
57
60
|
|
|
58
|
-
const
|
|
61
|
+
const gpxOptions = {...GPXLoader.options.gpx, ...options?.gpx};
|
|
59
62
|
|
|
60
|
-
switch (shape) {
|
|
63
|
+
switch (gpxOptions.shape) {
|
|
61
64
|
case 'object-row-table': {
|
|
62
65
|
const table: ObjectRowTable = {
|
|
63
66
|
shape: 'object-row-table',
|
|
@@ -77,6 +80,6 @@ function parseTextSync(
|
|
|
77
80
|
return geojsonToBinary(geojson.features);
|
|
78
81
|
|
|
79
82
|
default:
|
|
80
|
-
throw new Error(shape);
|
|
83
|
+
throw new Error(gpxOptions.shape);
|
|
81
84
|
}
|
|
82
85
|
}
|
package/src/index.ts
CHANGED
package/src/kml-loader.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
1
4
|
import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
2
5
|
// import {geojsonToBinary} from '@loaders.gl/gis';
|
|
3
6
|
// import {GeoJSONTable} from '@loaders.gl/schema';
|
|
@@ -44,9 +47,9 @@ function parseTextSync(text: string, options?: KMLLoaderOptions): ObjectRowTable
|
|
|
44
47
|
const doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
45
48
|
const geojson: FeatureCollection = kml(doc);
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
switch (shape) {
|
|
50
|
+
const kmlOptions = {...KMLLoader.options.kml, ...options?.kml};
|
|
51
|
+
|
|
52
|
+
switch (kmlOptions.shape) {
|
|
50
53
|
case 'geojson-table': {
|
|
51
54
|
const table: GeoJSONTable = {
|
|
52
55
|
shape: 'geojson-table',
|
|
@@ -68,6 +71,6 @@ function parseTextSync(text: string, options?: KMLLoaderOptions): ObjectRowTable
|
|
|
68
71
|
};
|
|
69
72
|
return table;
|
|
70
73
|
default:
|
|
71
|
-
throw new Error(shape);
|
|
74
|
+
throw new Error(kmlOptions.shape);
|
|
72
75
|
}
|
|
73
76
|
}
|
package/src/tcx-loader.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
1
4
|
import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
2
5
|
import {geojsonToBinary} from '@loaders.gl/gis';
|
|
3
6
|
import type {
|
|
@@ -43,7 +46,7 @@ export const TCXLoader: LoaderWithParser<
|
|
|
43
46
|
parseTextSync(new TextDecoder().decode(arrayBuffer), options),
|
|
44
47
|
parseTextSync,
|
|
45
48
|
options: {
|
|
46
|
-
tcx: {},
|
|
49
|
+
tcx: {shape: 'geojson-table'},
|
|
47
50
|
gis: {}
|
|
48
51
|
}
|
|
49
52
|
};
|
|
@@ -55,10 +58,9 @@ function parseTextSync(
|
|
|
55
58
|
const doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
56
59
|
const geojson: FeatureCollection = tcx(doc);
|
|
57
60
|
|
|
58
|
-
|
|
59
|
-
const shape = options?.tcx?.shape;
|
|
61
|
+
const tcxOptions = {...TCXLoader.options.tcx, ...options?.tcx};
|
|
60
62
|
|
|
61
|
-
switch (shape) {
|
|
63
|
+
switch (tcxOptions.shape) {
|
|
62
64
|
case 'object-row-table': {
|
|
63
65
|
const table: ObjectRowTable = {
|
|
64
66
|
shape: 'object-row-table',
|
|
@@ -78,6 +80,6 @@ function parseTextSync(
|
|
|
78
80
|
return geojsonToBinary(geojson.features);
|
|
79
81
|
|
|
80
82
|
default:
|
|
81
|
-
throw new Error(shape);
|
|
83
|
+
throw new Error(tcxOptions.shape);
|
|
82
84
|
}
|
|
83
85
|
}
|