@loaders.gl/kml 3.1.8 → 3.2.0-alpha.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.min.js CHANGED
@@ -1365,12 +1365,22 @@
1365
1365
  function parseTextSync(text, options) {
1366
1366
  const doc = new DOMParser().parseFromString(text, "text/xml");
1367
1367
  const geojson = (0, import_togeojson.gpx)(doc);
1368
- switch (options?.gpx?.type) {
1369
- case "object-row-table":
1370
- return geojson.features;
1371
- default:
1372
- }
1373
- switch (options?.gis?.format) {
1368
+ const shape = options?.gis?.format || options?.gpx?.type || options?.gpx?.shape;
1369
+ switch (shape) {
1370
+ case "object-row-table": {
1371
+ const table = {
1372
+ shape: "object-row-table",
1373
+ data: geojson.features
1374
+ };
1375
+ return table;
1376
+ }
1377
+ case "geojson-row-table": {
1378
+ const table = {
1379
+ shape: "geojson-row-table",
1380
+ data: geojson.features
1381
+ };
1382
+ return table;
1383
+ }
1374
1384
  case "geojson":
1375
1385
  return geojson;
1376
1386
  case "binary":
@@ -1378,7 +1388,7 @@
1378
1388
  case "raw":
1379
1389
  return doc;
1380
1390
  default:
1381
- throw new Error();
1391
+ return geojson;
1382
1392
  }
1383
1393
  }
1384
1394
  var import_togeojson, VERSION, GPX_HEADER, GPXLoader;
@@ -1402,7 +1412,7 @@
1402
1412
  parseTextSync,
1403
1413
  options: {
1404
1414
  gpx: {},
1405
- gis: { format: "geojson" }
1415
+ gis: {}
1406
1416
  }
1407
1417
  };
1408
1418
  }
@@ -1412,12 +1422,22 @@
1412
1422
  function parseTextSync2(text, options) {
1413
1423
  const doc = new DOMParser().parseFromString(text, "text/xml");
1414
1424
  const geojson = (0, import_togeojson2.kml)(doc);
1415
- switch (options?.kml?.type) {
1416
- case "object-row-table":
1417
- return geojson.features;
1418
- default:
1419
- }
1420
- switch (options?.gis?.format) {
1425
+ const shape = options?.gis?.format || options?.kml?.type || options?.kml?.shape;
1426
+ switch (shape) {
1427
+ case "object-row-table": {
1428
+ const table = {
1429
+ shape: "object-row-table",
1430
+ data: geojson.features
1431
+ };
1432
+ return table;
1433
+ }
1434
+ case "geojson-row-table": {
1435
+ const table = {
1436
+ shape: "geojson-row-table",
1437
+ data: geojson.features
1438
+ };
1439
+ return table;
1440
+ }
1421
1441
  case "geojson":
1422
1442
  return geojson;
1423
1443
  case "binary":
@@ -1425,7 +1445,7 @@
1425
1445
  case "raw":
1426
1446
  return doc;
1427
1447
  default:
1428
- throw new Error();
1448
+ return geojson;
1429
1449
  }
1430
1450
  }
1431
1451
  var import_togeojson2, VERSION2, KML_HEADER, KMLLoader;
@@ -1449,22 +1469,32 @@
1449
1469
  parseTextSync: parseTextSync2,
1450
1470
  options: {
1451
1471
  kml: {},
1452
- gis: { format: "geojson" }
1472
+ gis: {}
1453
1473
  }
1454
1474
  };
1455
1475
  }
1456
1476
  });
1457
1477
 
1458
1478
  // src/tcx-loader.ts
1459
- function parseTextSync3(text, options = {}) {
1479
+ function parseTextSync3(text, options) {
1460
1480
  const doc = new DOMParser().parseFromString(text, "text/xml");
1461
1481
  const geojson = (0, import_togeojson3.tcx)(doc);
1462
- switch (options?.tcx?.type) {
1463
- case "object-row-table":
1464
- return geojson.features;
1465
- default:
1466
- }
1467
- switch (options?.gis?.format) {
1482
+ const shape = options?.gis?.format || options?.tcx?.type || options?.tcx?.shape;
1483
+ switch (shape) {
1484
+ case "object-row-table": {
1485
+ const table = {
1486
+ shape: "object-row-table",
1487
+ data: geojson.features
1488
+ };
1489
+ return table;
1490
+ }
1491
+ case "geojson-row-table": {
1492
+ const table = {
1493
+ shape: "geojson-row-table",
1494
+ data: geojson.features
1495
+ };
1496
+ return table;
1497
+ }
1468
1498
  case "geojson":
1469
1499
  return geojson;
1470
1500
  case "binary":
@@ -1472,7 +1502,7 @@
1472
1502
  case "raw":
1473
1503
  return doc;
1474
1504
  default:
1475
- throw new Error();
1505
+ return geojson;
1476
1506
  }
1477
1507
  }
1478
1508
  var import_togeojson3, VERSION3, TCX_HEADER, TCXLoader;
@@ -1496,7 +1526,7 @@
1496
1526
  parseTextSync: parseTextSync3,
1497
1527
  options: {
1498
1528
  tcx: {},
1499
- gis: { format: "geojson" }
1529
+ gis: {}
1500
1530
  }
1501
1531
  };
1502
1532
  }
@@ -15,7 +15,7 @@ var _gis = require("@loaders.gl/gis");
15
15
 
16
16
  var _togeojson = require("@tmcw/togeojson");
17
17
 
18
- var VERSION = typeof "3.1.8" !== 'undefined' ? "3.1.8" : 'latest';
18
+ var VERSION = typeof "3.2.0-alpha.3" !== 'undefined' ? "3.2.0-alpha.3" : 'latest';
19
19
  var GPX_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<gpx";
20
20
  var GPXLoader = {
21
21
  name: 'GPX (GPS exchange format)',
@@ -51,27 +51,37 @@ var GPXLoader = {
51
51
  parseTextSync: parseTextSync,
52
52
  options: {
53
53
  gpx: {},
54
- gis: {
55
- format: 'geojson'
56
- }
54
+ gis: {}
57
55
  }
58
56
  };
59
57
  exports.GPXLoader = GPXLoader;
60
58
 
61
59
  function parseTextSync(text, options) {
62
- var _options$gpx, _options$gis;
60
+ var _options$gis, _options$gpx, _options$gpx2;
63
61
 
64
62
  var doc = new DOMParser().parseFromString(text, 'text/xml');
65
63
  var geojson = (0, _togeojson.gpx)(doc);
64
+ var shape = (options === null || options === void 0 ? void 0 : (_options$gis = options.gis) === null || _options$gis === void 0 ? void 0 : _options$gis.format) || (options === null || options === void 0 ? void 0 : (_options$gpx = options.gpx) === null || _options$gpx === void 0 ? void 0 : _options$gpx.type) || (options === null || options === void 0 ? void 0 : (_options$gpx2 = options.gpx) === null || _options$gpx2 === void 0 ? void 0 : _options$gpx2.shape);
66
65
 
67
- switch (options === null || options === void 0 ? void 0 : (_options$gpx = options.gpx) === null || _options$gpx === void 0 ? void 0 : _options$gpx.type) {
66
+ switch (shape) {
68
67
  case 'object-row-table':
69
- return geojson.features;
68
+ {
69
+ var table = {
70
+ shape: 'object-row-table',
71
+ data: geojson.features
72
+ };
73
+ return table;
74
+ }
75
+
76
+ case 'geojson-row-table':
77
+ {
78
+ var _table = {
79
+ shape: 'geojson-row-table',
80
+ data: geojson.features
81
+ };
82
+ return _table;
83
+ }
70
84
 
71
- default:
72
- }
73
-
74
- switch (options === null || options === void 0 ? void 0 : (_options$gis = options.gis) === null || _options$gis === void 0 ? void 0 : _options$gis.format) {
75
85
  case 'geojson':
76
86
  return geojson;
77
87
 
@@ -82,7 +92,7 @@ function parseTextSync(text, options) {
82
92
  return doc;
83
93
 
84
94
  default:
85
- throw new Error();
95
+ return geojson;
86
96
  }
87
97
  }
88
98
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/gpx-loader.ts"],"names":["VERSION","GPX_HEADER","GPXLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","gpx","gis","format","doc","DOMParser","parseFromString","geojson","type","features","Error","_typecheckGPXLoader"],"mappings":";;;;;;;;;;;;;AACA;;AACA;;AAIA,IAAMA,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE;AAMA,IAAMC,UAAU,qDAAhB;AAOO,IAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,2BADiB;AAEvBC,EAAAA,EAAE,EAAE,KAFmB;AAGvBC,EAAAA,MAAM,EAAE,KAHe;AAIvBC,EAAAA,OAAO,EAAEN,OAJc;AAKvBO,EAAAA,UAAU,EAAE,CAAC,KAAD,CALW;AAMvBC,EAAAA,SAAS,EAAE,CAAC,qBAAD,CANY;AAOvBC,EAAAA,IAAI,EAAE,IAPiB;AAQvBC,EAAAA,KAAK,EAAE,CAACT,UAAD,CARgB;AASvBU,EAAAA,KAAK;AAAA,2EAAE,iBAAOC,WAAP,EAAoBC,OAApB;AAAA;AAAA;AAAA;AAAA;AAAA,+CACLC,aAAa,CAAC,IAAIC,WAAJ,GAAkBC,MAAlB,CAAyBJ,WAAzB,CAAD,EAAwCC,OAAxC,CADR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAF;;AAAA;AAAA;AAAA;;AAAA;AAAA,KATkB;AAWvBC,EAAAA,aAAa,EAAbA,aAXuB;AAYvBD,EAAAA,OAAO,EAAE;AACPI,IAAAA,GAAG,EAAE,EADE;AAEPC,IAAAA,GAAG,EAAE;AAACC,MAAAA,MAAM,EAAE;AAAT;AAFE;AAZc,CAAlB;;;AAkBP,SAASL,aAAT,CAAuBL,IAAvB,EAAqCI,OAArC,EAAmD;AAAA;;AACjD,MAAMO,GAAG,GAAG,IAAIC,SAAJ,GAAgBC,eAAhB,CAAgCb,IAAhC,EAAsC,UAAtC,CAAZ;AACA,MAAMc,OAAO,GAAG,oBAAIH,GAAJ,CAAhB;;AAEA,UAAQP,OAAR,aAAQA,OAAR,uCAAQA,OAAO,CAAEI,GAAjB,iDAAQ,aAAcO,IAAtB;AACE,SAAK,kBAAL;AACE,aAAOD,OAAO,CAACE,QAAf;;AACF;AAHF;;AAMA,UAAQZ,OAAR,aAAQA,OAAR,uCAAQA,OAAO,CAAEK,GAAjB,iDAAQ,aAAcC,MAAtB;AACE,SAAK,SAAL;AACE,aAAOI,OAAP;;AACF,SAAK,QAAL;AACE,aAAO,0BAAgBA,OAAO,CAACE,QAAxB,CAAP;;AACF,SAAK,KAAL;AACE,aAAOL,GAAP;;AACF;AACE,YAAM,IAAIM,KAAJ,EAAN;AARJ;AAUD;;AAEM,IAAMC,mBAAmB,GAAGzB,SAA5B","sourcesContent":["import type {LoaderOptions} from '@loaders.gl/loader-utils';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport {gpx} from '@tmcw/togeojson';\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};\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 = {\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) =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync,\n options: {\n gpx: {},\n gis: {format: 'geojson'}\n }\n};\n\nfunction parseTextSync(text: string, options: any) {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson = gpx(doc);\n\n switch (options?.gpx?.type) {\n case 'object-row-table':\n return geojson.features;\n default:\n }\n\n switch (options?.gis?.format) {\n case 'geojson':\n return geojson;\n case 'binary':\n return geojsonToBinary(geojson.features);\n case 'raw':\n return doc;\n default:\n throw new Error();\n }\n}\n\nexport const _typecheckGPXLoader = GPXLoader;\n"],"file":"gpx-loader.js"}
1
+ {"version":3,"sources":["../../src/gpx-loader.ts"],"names":["VERSION","GPX_HEADER","GPXLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","gpx","gis","doc","DOMParser","parseFromString","geojson","shape","format","type","table","data","features","_typecheckGPXLoader"],"mappings":";;;;;;;;;;;;;AACA;;AACA;;AAKA,IAAMA,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAcA,IAAMC,UAAU,qDAAhB;AAOO,IAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,2BADiB;AAEvBC,EAAAA,EAAE,EAAE,KAFmB;AAGvBC,EAAAA,MAAM,EAAE,KAHe;AAIvBC,EAAAA,OAAO,EAAEN,OAJc;AAKvBO,EAAAA,UAAU,EAAE,CAAC,KAAD,CALW;AAMvBC,EAAAA,SAAS,EAAE,CAAC,qBAAD,CANY;AAOvBC,EAAAA,IAAI,EAAE,IAPiB;AAQvBC,EAAAA,KAAK,EAAE,CAACT,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AAFe,SAA/B;AAIA,eAAOF,MAAP;AACD;;AACD,SAAK,SAAL;AACE,aAAOJ,OAAP;;AACF,SAAK,QAAL;AACE,aAAO,0BAAgBA,OAAO,CAACM,QAAxB,CAAP;;AACF,SAAK,KAAL;AACE,aAAOT,GAAP;;AACF;AAEE,aAAOG,OAAP;AAvBJ;AAyBD;;AAEM,IAAMO,mBAAqC,GAAG3B,SAA9C","sourcesContent":["import type {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport {gpx} from '@tmcw/togeojson';\nimport type {GeoJSONRowTable, FeatureCollection, ObjectRowTable} from '@loaders.gl/schema';\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-row-table' | 'geojson' | 'binary' | 'raw';\n /** @deprecated. Use options.gpx.shape */\n type?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';\n };\n gis?: {\n /** @deprecated. Use options.gpx.shape */\n format?: 'object-row-table' | 'geojson-row-table' | 'geojson' | '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 = {\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: {},\n gis: {}\n }\n};\n\nfunction parseTextSync(text: string, options?: GPXLoaderOptions) {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson: FeatureCollection = gpx(doc);\n\n const shape = options?.gis?.format || options?.gpx?.type || options?.gpx?.shape;\n\n switch (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-row-table': {\n const table: GeoJSONRowTable = {\n shape: 'geojson-row-table',\n data: 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 default:\n // Default to geojson for backwards compatibility\n return geojson;\n }\n}\n\nexport const _typecheckGPXLoader: LoaderWithParser = GPXLoader;\n"],"file":"gpx-loader.js"}
@@ -15,7 +15,7 @@ var _gis = require("@loaders.gl/gis");
15
15
 
16
16
  var _togeojson = require("@tmcw/togeojson");
17
17
 
18
- var VERSION = typeof "3.1.8" !== 'undefined' ? "3.1.8" : 'latest';
18
+ var VERSION = typeof "3.2.0-alpha.3" !== 'undefined' ? "3.2.0-alpha.3" : 'latest';
19
19
  var KML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kml xmlns=\"http://www.opengis.net/kml/2.2\">";
20
20
  var KMLLoader = {
21
21
  name: 'KML (Keyhole Markup Language)',
@@ -51,27 +51,37 @@ var KMLLoader = {
51
51
  parseTextSync: parseTextSync,
52
52
  options: {
53
53
  kml: {},
54
- gis: {
55
- format: 'geojson'
56
- }
54
+ gis: {}
57
55
  }
58
56
  };
59
57
  exports.KMLLoader = KMLLoader;
60
58
 
61
59
  function parseTextSync(text, options) {
62
- var _options$kml, _options$gis;
60
+ var _options$gis, _options$kml, _options$kml2;
63
61
 
64
62
  var doc = new DOMParser().parseFromString(text, 'text/xml');
65
63
  var geojson = (0, _togeojson.kml)(doc);
64
+ var shape = (options === null || options === void 0 ? void 0 : (_options$gis = options.gis) === null || _options$gis === void 0 ? void 0 : _options$gis.format) || (options === null || options === void 0 ? void 0 : (_options$kml = options.kml) === null || _options$kml === void 0 ? void 0 : _options$kml.type) || (options === null || options === void 0 ? void 0 : (_options$kml2 = options.kml) === null || _options$kml2 === void 0 ? void 0 : _options$kml2.shape);
66
65
 
67
- switch (options === null || options === void 0 ? void 0 : (_options$kml = options.kml) === null || _options$kml === void 0 ? void 0 : _options$kml.type) {
66
+ switch (shape) {
68
67
  case 'object-row-table':
69
- return geojson.features;
68
+ {
69
+ var table = {
70
+ shape: 'object-row-table',
71
+ data: geojson.features
72
+ };
73
+ return table;
74
+ }
75
+
76
+ case 'geojson-row-table':
77
+ {
78
+ var _table = {
79
+ shape: 'geojson-row-table',
80
+ data: geojson.features
81
+ };
82
+ return _table;
83
+ }
70
84
 
71
- default:
72
- }
73
-
74
- switch (options === null || options === void 0 ? void 0 : (_options$gis = options.gis) === null || _options$gis === void 0 ? void 0 : _options$gis.format) {
75
85
  case 'geojson':
76
86
  return geojson;
77
87
 
@@ -82,7 +92,7 @@ function parseTextSync(text, options) {
82
92
  return doc;
83
93
 
84
94
  default:
85
- throw new Error();
95
+ return geojson;
86
96
  }
87
97
  }
88
98
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/kml-loader.ts"],"names":["VERSION","KML_HEADER","KMLLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","kml","gis","format","doc","DOMParser","parseFromString","geojson","type","features","Error","_typecheckKMLLoader"],"mappings":";;;;;;;;;;;;;AACA;;AACA;;AAIA,IAAMA,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE;AAMA,IAAMC,UAAU,+FAAhB;AAOO,IAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,+BADiB;AAEvBC,EAAAA,EAAE,EAAE,KAFmB;AAGvBC,EAAAA,MAAM,EAAE,KAHe;AAIvBC,EAAAA,OAAO,EAAEN,OAJc;AAKvBO,EAAAA,UAAU,EAAE,CAAC,KAAD,CALW;AAMvBC,EAAAA,SAAS,EAAE,CAAC,sCAAD,CANY;AAOvBC,EAAAA,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onToBinary} from '@loaders.gl/gis';\nimport {kml} from '@tmcw/togeojson';\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};\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 = {\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) =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync,\n options: {\n kml: {},\n gis: {format: 'geojson'}\n }\n};\n\nfunction parseTextSync(text: string, options: any) {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson = kml(doc);\n\n switch (options?.kml?.type) {\n case 'object-row-table':\n return geojson.features;\n default:\n }\n\n switch (options?.gis?.format) {\n case 'geojson':\n return geojson;\n case 'binary':\n return geojsonToBinary(geojson.features);\n case 'raw':\n return doc;\n default:\n throw new Error();\n }\n}\n\nexport const _typecheckKMLLoader: LoaderWithParser = KMLLoader;\n"],"file":"kml-loader.js"}
1
+ {"version":3,"sources":["../../src/kml-loader.ts"],"names":["VERSION","KML_HEADER","KMLLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","kml","gis","doc","DOMParser","parseFromString","geojson","shape","format","type","table","data","features","_typecheckKMLLoader"],"mappings":";;;;;;;;;;;;;AACA;;AACA;;AAKA,IAAMA,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAcA,IAAMC,UAAU,+FAAhB;AAOO,IAAMC,SAAS,G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KAAR;AACE,SAAK,kBAAL;AAAyB;AACvB,YAAMG,KAAqB,GAAG;AAC5BH,UAAAA,KAAK,EAAE,kBADqB;AAE5BI,UAAAA,IAAI,EAAEL,OAAO,CAACM;AAFc,SAA9B;AAIA,eAAOF,KAAP;AACD;;AACD,SAAK,mBAAL;AAA0B;AACxB,YAAMA,MAAsB,GAAG;AAC7BH,UAAAA,KAAK,EAAE,mBADsB;AAE7BI,UAAAA,IAAI,EAAEL,OAAO,CAACM;AAFe,SAA/B;AAIA,eAAOF,MAAP;AACD;;AACD,SAAK,SAAL;AACE,aAAOJ,OAAP;;AACF,SAAK,QAAL;AACE,aAAO,0BAAgBA,OAAO,CAACM,QAAxB,CAAP;;AACF,SAAK,KAAL;AACE,aAAOT,GAAP;;AACF;AAEE,aAAOG,OAAP;AAvBJ;AAyBD;;AAEM,IAAMO,mBAAqC,GAAG3B,SAA9C","sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport {kml} from '@tmcw/togeojson';\nimport {GeoJSONRowTable, FeatureCollection, ObjectRowTable} from '@loaders.gl/schema';\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-row-table' | 'geojson' | 'binary' | 'raw';\n /** @deprecated. Use options.kml.shape */\n type?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';\n };\n gis?: {\n /** @deprecated. Use options.kml.shape */\n format?: 'object-row-table' | 'geojson-row-table' | 'geojson' | '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 = {\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: {},\n gis: {}\n }\n};\n\nfunction parseTextSync(text: string, options?: KMLLoaderOptions) {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson: FeatureCollection = kml(doc);\n\n // backwards compatibility\n const shape = options?.gis?.format || options?.kml?.type || options?.kml?.shape;\n switch (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-row-table': {\n const table: GeoJSONRowTable = {\n shape: 'geojson-row-table',\n data: 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 default:\n // Default to geojson for backwards compatibility\n return geojson;\n }\n}\n\nexport const _typecheckKMLLoader: LoaderWithParser = KMLLoader;\n"],"file":"kml-loader.js"}
@@ -15,7 +15,7 @@ var _gis = require("@loaders.gl/gis");
15
15
 
16
16
  var _togeojson = require("@tmcw/togeojson");
17
17
 
18
- var VERSION = typeof "3.1.8" !== 'undefined' ? "3.1.8" : 'latest';
18
+ var VERSION = typeof "3.2.0-alpha.3" !== 'undefined' ? "3.2.0-alpha.3" : 'latest';
19
19
  var TCX_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<TrainingCenterDatabase";
20
20
  var TCXLoader = {
21
21
  name: 'TCX (Training Center XML)',
@@ -51,28 +51,37 @@ var TCXLoader = {
51
51
  parseTextSync: parseTextSync,
52
52
  options: {
53
53
  tcx: {},
54
- gis: {
55
- format: 'geojson'
56
- }
54
+ gis: {}
57
55
  }
58
56
  };
59
57
  exports.TCXLoader = TCXLoader;
60
58
 
61
- function parseTextSync(text) {
62
- var _options$tcx, _options$gis;
59
+ function parseTextSync(text, options) {
60
+ var _options$gis, _options$tcx, _options$tcx2;
63
61
 
64
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
65
62
  var doc = new DOMParser().parseFromString(text, 'text/xml');
66
63
  var geojson = (0, _togeojson.tcx)(doc);
64
+ var shape = (options === null || options === void 0 ? void 0 : (_options$gis = options.gis) === null || _options$gis === void 0 ? void 0 : _options$gis.format) || (options === null || options === void 0 ? void 0 : (_options$tcx = options.tcx) === null || _options$tcx === void 0 ? void 0 : _options$tcx.type) || (options === null || options === void 0 ? void 0 : (_options$tcx2 = options.tcx) === null || _options$tcx2 === void 0 ? void 0 : _options$tcx2.shape);
67
65
 
68
- switch (options === null || options === void 0 ? void 0 : (_options$tcx = options.tcx) === null || _options$tcx === void 0 ? void 0 : _options$tcx.type) {
66
+ switch (shape) {
69
67
  case 'object-row-table':
70
- return geojson.features;
68
+ {
69
+ var table = {
70
+ shape: 'object-row-table',
71
+ data: geojson.features
72
+ };
73
+ return table;
74
+ }
75
+
76
+ case 'geojson-row-table':
77
+ {
78
+ var _table = {
79
+ shape: 'geojson-row-table',
80
+ data: geojson.features
81
+ };
82
+ return _table;
83
+ }
71
84
 
72
- default:
73
- }
74
-
75
- switch (options === null || options === void 0 ? void 0 : (_options$gis = options.gis) === null || _options$gis === void 0 ? void 0 : _options$gis.format) {
76
85
  case 'geojson':
77
86
  return geojson;
78
87
 
@@ -83,7 +92,7 @@ function parseTextSync(text) {
83
92
  return doc;
84
93
 
85
94
  default:
86
- throw new Error();
95
+ return geojson;
87
96
  }
88
97
  }
89
98
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tcx-loader.ts"],"names":["VERSION","TCX_HEADER","TCXLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","tcx","gis","format","doc","DOMParser","parseFromString","geojson","type","features","Error","_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kBAAL;AACE,aAAOD,OAAO,CAACE,QAAf;;AACF;AAHF;;AAMA,UAAQZ,OAAR,aAAQA,OAAR,uCAAQA,OAAO,CAAEK,GAAjB,iDAAQ,aAAcC,MAAtB;AACE,SAAK,SAAL;AACE,aAAOI,OAAP;;AACF,SAAK,QAAL;AACE,aAAO,0BAAgBA,OAAO,CAACE,QAAxB,CAAP;;AACF,SAAK,KAAL;AACE,aAAOL,GAAP;;AACF;AACE,YAAM,IAAIM,KAAJ,EAAN;AARJ;AAUD;;AAEM,IAAMC,mBAAqC,GAAGzB,SAA9C","sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport {tcx} from '@tmcw/togeojson';\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};\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 = {\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) =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync,\n options: {\n tcx: {},\n gis: {format: 'geojson'}\n }\n};\n\nfunction parseTextSync(text: string, options: any = {}) {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson = tcx(doc);\n\n switch (options?.tcx?.type) {\n case 'object-row-table':\n return geojson.features;\n default:\n }\n\n switch (options?.gis?.format) {\n case 'geojson':\n return geojson;\n case 'binary':\n return geojsonToBinary(geojson.features);\n case 'raw':\n return doc;\n default:\n throw new Error();\n }\n}\n\nexport const _typecheckTCXLoader: LoaderWithParser = TCXLoader;\n"],"file":"tcx-loader.js"}
1
+ {"version":3,"sources":["../../src/tcx-loader.ts"],"names":["VERSION","TCX_HEADER","TCXLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","tcx","gis","doc","DOMParser","parseFromString","geojson","shape","format","type","table","data","features","_typecheckTCXLoader"],"mappings":";;;;;;;;;;;;;AACA;;AACA;;AAKA,IAAMA,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAcA,IAAMC,UAAU,wEAAhB;AAOO,IAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,2BADiB;AAEvBC,EAAAA,EAAE,EAAE,KAFmB;AAGvBC,EAAAA,MAAM,EAAE,KAHe;AAIvBC,EAAAA,OAAO,EAAEN,OAJc;AAKvBO,EAAAA,UAAU,EAAE,CAAC,KAAD,CALW;AAMvBC,EAAAA,SAAS,EAAE,CAAC,gCAAD,CANY;AAOvBC,EAAAA,IAAI,EAAE,IAPiB;AAQvBC,EAAAA,KAAK,EAAE,CAACT,UAAD,CARgB;AASvBU,EAAAA,KAAK;AAAA,2EAAE,iBAAOC,WAAP,EAAoBC,OAApB;AAAA;AAAA;AAAA;AAAA;AAAA,+CACLC,aAAa,CAAC,IAAIC,WAAJ,GAAkBC,MAAlB,CAAyBJ,WAAzB,CAAD,EAAwCC,OAAxC,CADR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAF;;AAAA;AAAA;AAAA;;AAAA;AAAA,KATkB;AAWvBC,EAAAA,aAAa,EAAbA,aAXuB;AAYvBD,EAAAA,OAAO,EAAE;AACPI,IAAAA,GAAG,EAAE,EADE;AAEPC,IAAAA,GAAG,EAAE;AAFE;AAZc,CAAlB;;;AAkBP,SAASJ,aAAT,CAAuBL,IAAvB,EAAqCI,OAArC,EAAiE;AAAA;;AAC/D,MAAMM,GAAG,GAAG,IAAIC,SAAJ,GAAgBC,eAAhB,CAAgCZ,IAAhC,EAAsC,UAAtC,CAAZ;AACA,MAAMa,OAA0B,GAAG,oBAAIH,GAAJ,CAAnC;AAGA,MAAMI,KAAK,GAAG,CAAAV,OAAO,SAAP,IAAAA,OAAO,WAAP,4BAAAA,OAAO,CAAEK,GAAT,8DAAcM,MAAd,MAAwBX,OAAxB,aAAwBA,OAAxB,uCAAwBA,OAAO,CAAEI,GAAjC,iDAAwB,aAAcQ,IAAtC,MAA8CZ,OAA9C,aAA8CA,OAA9C,wCAA8CA,OAAO,CAAEI,GAAvD,kDAA8C,cAAcM,KAA5D,CAAd;;AAEA,UAAQA,KAAR;AACE,SAAK,kBAAL;AAAyB;AACvB,YAAMG,KAAqB,GAAG;AAC5BH,UAAAA,KAAK,EAAE,kBADqB;AAE5BI,UAAAA,IAAI,EAAEL,OAAO,CAACM;AAFc,SAA9B;AAIA,eAAOF,KAAP;AACD;;AACD,SAAK,mBAAL;AAA0B;AACxB,YAAMA,MAAsB,GAAG;AAC7BH,UAAAA,KAAK,EAAE,mBADsB;AAE7BI,UAAAA,IAAI,EAAEL,OAAO,CAACM;AAFe,SAA/B;AAIA,eAAOF,MAAP;AACD;;AACD,SAAK,SAAL;AACE,aAAOJ,OAAP;;AACF,SAAK,QAAL;AACE,aAAO,0BAAgBA,OAAO,CAACM,QAAxB,CAAP;;AACF,SAAK,KAAL;AACE,aAAOT,GAAP;;AACF;AAEE,aAAOG,OAAP;AAvBJ;AAyBD;;AAEM,IAAMO,mBAAqC,GAAG3B,SAA9C","sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport {tcx} from '@tmcw/togeojson';\nimport type {GeoJSONRowTable, FeatureCollection, ObjectRowTable} from '@loaders.gl/schema';\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-row-table' | 'geojson' | 'binary' | 'raw';\n /** @deprecated. Use options.tcx.shape */\n type?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';\n };\n gis?: {\n /** @deprecated. Use options.tcx.shape */\n format?: 'object-row-table' | 'geojson-row-table' | 'geojson' | '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 = {\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: {},\n gis: {}\n }\n};\n\nfunction parseTextSync(text: string, options?: TCXLoaderOptions) {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson: FeatureCollection = tcx(doc);\n\n // backwards compatibility\n const shape = options?.gis?.format || options?.tcx?.type || options?.tcx?.shape;\n\n switch (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-row-table': {\n const table: GeoJSONRowTable = {\n shape: 'geojson-row-table',\n data: 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 default:\n // Default to geojson for backwards compatibility\n return geojson;\n }\n}\n\nexport const _typecheckTCXLoader: LoaderWithParser = TCXLoader;\n"],"file":"tcx-loader.js"}
@@ -1,6 +1,6 @@
1
1
  import { geojsonToBinary } from '@loaders.gl/gis';
2
2
  import { gpx } from '@tmcw/togeojson';
3
- const VERSION = typeof "3.1.8" !== 'undefined' ? "3.1.8" : 'latest';
3
+ const VERSION = typeof "3.2.0-alpha.3" !== 'undefined' ? "3.2.0-alpha.3" : 'latest';
4
4
  const GPX_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<gpx";
5
5
  export const GPXLoader = {
6
6
  name: 'GPX (GPS exchange format)',
@@ -15,26 +15,36 @@ export const GPXLoader = {
15
15
  parseTextSync,
16
16
  options: {
17
17
  gpx: {},
18
- gis: {
19
- format: 'geojson'
20
- }
18
+ gis: {}
21
19
  }
22
20
  };
23
21
 
24
22
  function parseTextSync(text, options) {
25
- var _options$gpx, _options$gis;
23
+ var _options$gis, _options$gpx, _options$gpx2;
26
24
 
27
25
  const doc = new DOMParser().parseFromString(text, 'text/xml');
28
26
  const geojson = gpx(doc);
27
+ const shape = (options === null || options === void 0 ? void 0 : (_options$gis = options.gis) === null || _options$gis === void 0 ? void 0 : _options$gis.format) || (options === null || options === void 0 ? void 0 : (_options$gpx = options.gpx) === null || _options$gpx === void 0 ? void 0 : _options$gpx.type) || (options === null || options === void 0 ? void 0 : (_options$gpx2 = options.gpx) === null || _options$gpx2 === void 0 ? void 0 : _options$gpx2.shape);
29
28
 
30
- switch (options === null || options === void 0 ? void 0 : (_options$gpx = options.gpx) === null || _options$gpx === void 0 ? void 0 : _options$gpx.type) {
29
+ switch (shape) {
31
30
  case 'object-row-table':
32
- return geojson.features;
31
+ {
32
+ const table = {
33
+ shape: 'object-row-table',
34
+ data: geojson.features
35
+ };
36
+ return table;
37
+ }
38
+
39
+ case 'geojson-row-table':
40
+ {
41
+ const table = {
42
+ shape: 'geojson-row-table',
43
+ data: geojson.features
44
+ };
45
+ return table;
46
+ }
33
47
 
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
48
  case 'geojson':
39
49
  return geojson;
40
50
 
@@ -45,7 +55,7 @@ function parseTextSync(text, options) {
45
55
  return doc;
46
56
 
47
57
  default:
48
- throw new Error();
58
+ return geojson;
49
59
  }
50
60
  }
51
61
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/gpx-loader.ts"],"names":["geojsonToBinary","gpx","VERSION","GPX_HEADER","GPXLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","gis","format","doc","DOMParser","parseFromString","geojson","type","features","Error","_typecheckGPXLoader"],"mappings":"AACA,SAAQA,eAAR,QAA8B,iBAA9B;AACA,SAAQC,GAAR,QAAkB,iBAAlB;AAIA,MAAMC,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE;AAMA,MAAMC,UAAU,qDAAhB;AAOA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,2BADiB;AAEvBC,EAAAA,EAAE,EAAE,KAFmB;AAGvBC,EAAAA,MAAM,EAAE,KAHe;AAIvBC,EAAAA,OAAO,EAAEN,OAJc;AAKvBO,EAAAA,UAAU,EAAE,CAAC,KAAD,CALW;AAMvBC,EAAAA,SAAS,EAAE,CAAC,qBAAD,CANY;AAOvBC,EAAAA,IAAI,EAAE,IAPiB;AAQvBC,EAAAA,KAAK,EAAE,CAACT,UAAD,CARgB;AASvBU,EAAAA,KAAK,EAAE,OAAOC,WAAP,EAAoBC,OAApB,KACLC,aAAa,CAAC,IAAIC,WAAJ,GAAkBC,MAAlB,CAAyBJ,WAAzB,CAAD,EAAwCC,OAAxC,CAVQ;AAWvBC,EAAAA,aAXuB;AAYvBD,EAAAA,OAAO,EAAE;AACPd,IAAAA,GAAG,EAAE,EADE;AAEPkB,IAAAA,GAAG,EAAE;AAACC,MAAAA,MAAM,EAAE;AAAT;AAFE;AAZc,CAAlB;;AAkBP,SAASJ,aAAT,CAAuBL,IAAvB,EAAqCI,OAArC,EAAmD;AAAA;;AACjD,QAAMM,GAAG,GAAG,IAAIC,SAAJ,GAAgBC,eAAhB,CAAgCZ,IAAhC,EAAsC,UAAtC,CAAZ;AACA,QAAMa,OAAO,GAAGvB,GAAG,CAACoB,GAAD,CAAnB;;AAEA,UAAQN,OAAR,aAAQA,OAAR,uCAAQA,OAAO,CAAEd,GAAjB,iDAAQ,aAAcwB,IAAtB;AACE,SAAK,kBAAL;AACE,aAAOD,OAAO,CAACE,QAAf;;AACF;AAHF;;AAMA,UAAQX,OAAR,aAAQA,OAAR,uCAAQA,OAAO,CAAEI,GAAjB,iDAAQ,aAAcC,MAAtB;AACE,SAAK,SAAL;AACE,aAAOI,OAAP;;AACF,SAAK,QAAL;AACE,aAAOxB,eAAe,CAACwB,OAAO,CAACE,QAAT,CAAtB;;AACF,SAAK,KAAL;AACE,aAAOL,GAAP;;AACF;AACE,YAAM,IAAIM,KAAJ,EAAN;AARJ;AAUD;;AAED,OAAO,MAAMC,mBAAmB,GAAGxB,SAA5B","sourcesContent":["import type {LoaderOptions} from '@loaders.gl/loader-utils';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport {gpx} from '@tmcw/togeojson';\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};\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 = {\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) =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync,\n options: {\n gpx: {},\n gis: {format: 'geojson'}\n }\n};\n\nfunction parseTextSync(text: string, options: any) {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson = gpx(doc);\n\n switch (options?.gpx?.type) {\n case 'object-row-table':\n return geojson.features;\n default:\n }\n\n switch (options?.gis?.format) {\n case 'geojson':\n return geojson;\n case 'binary':\n return geojsonToBinary(geojson.features);\n case 'raw':\n return doc;\n default:\n throw new Error();\n }\n}\n\nexport const _typecheckGPXLoader = GPXLoader;\n"],"file":"gpx-loader.js"}
1
+ {"version":3,"sources":["../../src/gpx-loader.ts"],"names":["geojsonToBinary","gpx","VERSION","GPX_HEADER","GPXLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","gis","doc","DOMParser","parseFromString","geojson","shape","format","type","table","data","features","_typecheckGPXLoader"],"mappings":"AACA,SAAQA,eAAR,QAA8B,iBAA9B;AACA,SAAQC,GAAR,QAAkB,iBAAlB;AAKA,MAAMC,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAcA,MAAMC,UAAU,qDAAhB;AAOA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,2BADiB;AAEvBC,EAAAA,EAAE,EAAE,KAFmB;AAGvBC,EAAAA,MAAM,EAAE,KAHe;AAIvBC,EAAAA,OAAO,EAAEN,OAJc;AAKvBO,EAAAA,UAAU,EAAE,CAAC,KAAD,CALW;AAMvBC,EAAAA,SAAS,EAAE,CAAC,qBAAD,CANY;AAOvBC,EAAAA,IAAI,EAAE,IAPiB;AAQvBC,EAAAA,KAAK,EAAE,CAACT,UAAD,CARgB;AASvBU,EAAAA,KAAK,EAAE,OAAOC,WAAP,EAAoBC,OAApB,KACLC,aAAa,CAAC,IAAIC,WAAJ,GAAkBC,MAAlB,CAAyBJ,WAAzB,CAAD,EAAwCC,OAAxC,CAVQ;AAWvBC,EAAAA,aAXuB;AAYvBD,EAAAA,OAAO,EAAE;AACPd,IAAAA,GAAG,EAAE,EADE;AAEPkB,IAAAA,GAAG,EAAE;AAFE;AAZc,CAAlB;;AAkBP,SAASH,aAAT,CAAuBL,IAAvB,EAAqCI,OAArC,EAAiE;AAAA;;AAC/D,QAAMK,GAAG,GAAG,IAAIC,SAAJ,GAAgBC,eAAhB,CAAgCX,IAAhC,EAAsC,UAAtC,CAAZ;AACA,QAAMY,OAA0B,GAAGtB,GAAG,CAACmB,GAAD,CAAtC;AAEA,QAAMI,KAAK,GAAG,CAAAT,OAAO,SAAP,IAAAA,OAAO,WAAP,4BAAAA,OAAO,CAAEI,GAAT,8DAAcM,MAAd,MAAwBV,OAAxB,aAAwBA,OAAxB,uCAAwBA,OAAO,CAAEd,GAAjC,iDAAwB,aAAcyB,IAAtC,MAA8CX,OAA9C,aAA8CA,OAA9C,wCAA8CA,OAAO,CAAEd,GAAvD,kDAA8C,cAAcuB,KAA5D,CAAd;;AAEA,UAAQA,KAAR;AACE,SAAK,kBAAL;AAAyB;AACvB,cAAMG,KAAqB,GAAG;AAC5BH,UAAAA,KAAK,EAAE,kBADqB;AAE5BI,UAAAA,IAAI,EAAEL,OAAO,CAACM;AAFc,SAA9B;AAIA,eAAOF,KAAP;AACD;;AACD,SAAK,mBAAL;AAA0B;AACxB,cAAMA,KAAsB,GAAG;AAC7BH,UAAAA,KAAK,EAAE,mBADsB;AAE7BI,UAAAA,IAAI,EAAEL,OAAO,CAACM;AAFe,SAA/B;AAIA,eAAOF,KAAP;AACD;;AACD,SAAK,SAAL;AACE,aAAOJ,OAAP;;AACF,SAAK,QAAL;AACE,aAAOvB,eAAe,CAACuB,OAAO,CAACM,QAAT,CAAtB;;AACF,SAAK,KAAL;AACE,aAAOT,GAAP;;AACF;AAEE,aAAOG,OAAP;AAvBJ;AAyBD;;AAED,OAAO,MAAMO,mBAAqC,GAAG1B,SAA9C","sourcesContent":["import type {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport {gpx} from '@tmcw/togeojson';\nimport type {GeoJSONRowTable, FeatureCollection, ObjectRowTable} from '@loaders.gl/schema';\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-row-table' | 'geojson' | 'binary' | 'raw';\n /** @deprecated. Use options.gpx.shape */\n type?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';\n };\n gis?: {\n /** @deprecated. Use options.gpx.shape */\n format?: 'object-row-table' | 'geojson-row-table' | 'geojson' | '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 = {\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: {},\n gis: {}\n }\n};\n\nfunction parseTextSync(text: string, options?: GPXLoaderOptions) {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson: FeatureCollection = gpx(doc);\n\n const shape = options?.gis?.format || options?.gpx?.type || options?.gpx?.shape;\n\n switch (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-row-table': {\n const table: GeoJSONRowTable = {\n shape: 'geojson-row-table',\n data: 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 default:\n // Default to geojson for backwards compatibility\n return geojson;\n }\n}\n\nexport const _typecheckGPXLoader: LoaderWithParser = GPXLoader;\n"],"file":"gpx-loader.js"}
@@ -1,6 +1,6 @@
1
1
  import { geojsonToBinary } from '@loaders.gl/gis';
2
2
  import { kml } from '@tmcw/togeojson';
3
- const VERSION = typeof "3.1.8" !== 'undefined' ? "3.1.8" : 'latest';
3
+ const VERSION = typeof "3.2.0-alpha.3" !== 'undefined' ? "3.2.0-alpha.3" : 'latest';
4
4
  const KML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<kml xmlns=\"http://www.opengis.net/kml/2.2\">";
5
5
  export const KMLLoader = {
6
6
  name: 'KML (Keyhole Markup Language)',
@@ -15,26 +15,36 @@ export const KMLLoader = {
15
15
  parseTextSync,
16
16
  options: {
17
17
  kml: {},
18
- gis: {
19
- format: 'geojson'
20
- }
18
+ gis: {}
21
19
  }
22
20
  };
23
21
 
24
22
  function parseTextSync(text, options) {
25
- var _options$kml, _options$gis;
23
+ var _options$gis, _options$kml, _options$kml2;
26
24
 
27
25
  const doc = new DOMParser().parseFromString(text, 'text/xml');
28
26
  const geojson = kml(doc);
27
+ const shape = (options === null || options === void 0 ? void 0 : (_options$gis = options.gis) === null || _options$gis === void 0 ? void 0 : _options$gis.format) || (options === null || options === void 0 ? void 0 : (_options$kml = options.kml) === null || _options$kml === void 0 ? void 0 : _options$kml.type) || (options === null || options === void 0 ? void 0 : (_options$kml2 = options.kml) === null || _options$kml2 === void 0 ? void 0 : _options$kml2.shape);
29
28
 
30
- switch (options === null || options === void 0 ? void 0 : (_options$kml = options.kml) === null || _options$kml === void 0 ? void 0 : _options$kml.type) {
29
+ switch (shape) {
31
30
  case 'object-row-table':
32
- return geojson.features;
31
+ {
32
+ const table = {
33
+ shape: 'object-row-table',
34
+ data: geojson.features
35
+ };
36
+ return table;
37
+ }
38
+
39
+ case 'geojson-row-table':
40
+ {
41
+ const table = {
42
+ shape: 'geojson-row-table',
43
+ data: geojson.features
44
+ };
45
+ return table;
46
+ }
33
47
 
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
48
  case 'geojson':
39
49
  return geojson;
40
50
 
@@ -45,7 +55,7 @@ function parseTextSync(text, options) {
45
55
  return doc;
46
56
 
47
57
  default:
48
- throw new Error();
58
+ return geojson;
49
59
  }
50
60
  }
51
61
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/kml-loader.ts"],"names":["geojsonToBinary","kml","VERSION","KML_HEADER","KMLLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","gis","format","doc","DOMParser","parseFromString","geojson","type","features","Error","_typecheckKMLLoader"],"mappings":"AACA,SAAQA,eAAR,QAA8B,iBAA9B;AACA,SAAQC,GAAR,QAAkB,iBAAlB;AAIA,MAAMC,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE;AAMA,MAAMC,UAAU,+FAAhB;AAOA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,+BADiB;AAEvBC,EAAAA,EAAE,EAAE,KAFmB;AAGvBC,EAAAA,MAAM,EAAE,KAHe;AAIvBC,EAAAA,OAAO,EAAEN,OAJc;AAKvBO,EAAAA,UAAU,EAAE,CAAC,KAAD,CALW;AAMvBC,EAAAA,SAAS,EAAE,CAAC,sCAAD,CANY;AAOvBC,EAAAA,IAAI,EAAE,IAPiB;AAQvBC,EAAAA,KAAK,EAAE,CAACT,UAAD,CARgB;AASvBU,EAAAA,KAAK,EAAE,OAAOC,WAAP,EAAoBC,OAApB,KACLC,aAAa,CAAC,IAAIC,WAAJ,GAAkBC,MAAlB,CAAyBJ,WAAzB,CAAD,EAAwCC,OAAxC,CAVQ;AAWvBC,EAAAA,aAXuB;AAYvBD,EAAAA,OAAO,EAAE;AACPd,IAAAA,GAAG,EAAE,EADE;AAEPkB,IAAAA,GAAG,EAAE;AAACC,MAAAA,MAAM,EAAE;AAAT;AAFE;AAZc,CAAlB;;AAkBP,SAASJ,aAAT,CAAuBL,IAAvB,EAAqCI,OAArC,EAAmD;AAAA;;AACjD,QAAMM,GAAG,GAAG,IAAIC,SAAJ,GAAgBC,eAAhB,CAAgCZ,IAAhC,EAAsC,UAAtC,CAAZ;AACA,QAAMa,OAAO,GAAGvB,GAAG,CAACoB,GAAD,CAAnB;;AAEA,UAAQN,OAAR,aAAQA,OAAR,uCAAQA,OAAO,CAAEd,GAAjB,iDAAQ,aAAcwB,IAAtB;AACE,SAAK,kBAAL;AACE,aAAOD,OAAO,CAACE,QAAf;;AACF;AAHF;;AAMA,UAAQX,OAAR,aAAQA,OAAR,uCAAQA,OAAO,CAAEI,GAAjB,iDAAQ,aAAcC,MAAtB;AACE,SAAK,SAAL;AACE,aAAOI,OAAP;;AACF,SAAK,QAAL;AACE,aAAOxB,eAAe,CAACwB,OAAO,CAACE,QAAT,CAAtB;;AACF,SAAK,KAAL;AACE,aAAOL,GAAP;;AACF;AACE,YAAM,IAAIM,KAAJ,EAAN;AARJ;AAUD;;AAED,OAAO,MAAMC,mBAAqC,GAAGxB,SAA9C","sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport {kml} from '@tmcw/togeojson';\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};\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 = {\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) =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync,\n options: {\n kml: {},\n gis: {format: 'geojson'}\n }\n};\n\nfunction parseTextSync(text: string, options: any) {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson = kml(doc);\n\n switch (options?.kml?.type) {\n case 'object-row-table':\n return geojson.features;\n default:\n }\n\n switch (options?.gis?.format) {\n case 'geojson':\n return geojson;\n case 'binary':\n return geojsonToBinary(geojson.features);\n case 'raw':\n return doc;\n default:\n throw new Error();\n }\n}\n\nexport const _typecheckKMLLoader: LoaderWithParser = KMLLoader;\n"],"file":"kml-loader.js"}
1
+ {"version":3,"sources":["../../src/kml-loader.ts"],"names":["geojsonToBinary","kml","VERSION","KML_HEADER","KMLLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","gis","doc","DOMParser","parseFromString","geojson","shape","format","type","table","data","features","_typecheckKMLLoader"],"mappings":"AACA,SAAQA,eAAR,QAA8B,iBAA9B;AACA,SAAQC,GAAR,QAAkB,iBAAlB;AAKA,MAAMC,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAcA,MAAMC,UAAU,+FAAhB;AAOA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,+BADiB;AAEvBC,EAAAA,EAAE,EAAE,KAFmB;AAGvBC,EAAAA,MAAM,EAAE,KAHe;AAIvBC,EAAAA,OAAO,EAAEN,OAJc;AAKvBO,EAAAA,UAAU,EAAE,CAAC,KAAD,CALW;AAMvBC,EAAAA,SAAS,EAAE,CAAC,sCAAD,CANY;AAOvBC,EAAAA,IAAI,EAAE,IAPiB;AAQvBC,EAAAA,KAAK,EAAE,CAACT,UAAD,CARgB;AASvBU,EAAAA,KAAK,EAAE,OAAOC,WAAP,EAAoBC,OAApB,KACLC,aAAa,CAAC,IAAIC,WAAJ,GAAkBC,MAAlB,CAAyBJ,WAAzB,CAAD,EAAwCC,OAAxC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, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport {kml} from '@tmcw/togeojson';\nimport {GeoJSONRowTable, FeatureCollection, ObjectRowTable} from '@loaders.gl/schema';\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-row-table' | 'geojson' | 'binary' | 'raw';\n /** @deprecated. Use options.kml.shape */\n type?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';\n };\n gis?: {\n /** @deprecated. Use options.kml.shape */\n format?: 'object-row-table' | 'geojson-row-table' | 'geojson' | '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 = {\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: {},\n gis: {}\n }\n};\n\nfunction parseTextSync(text: string, options?: KMLLoaderOptions) {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson: FeatureCollection = kml(doc);\n\n // backwards compatibility\n const shape = options?.gis?.format || options?.kml?.type || options?.kml?.shape;\n switch (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-row-table': {\n const table: GeoJSONRowTable = {\n shape: 'geojson-row-table',\n data: 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 default:\n // Default to geojson for backwards compatibility\n return geojson;\n }\n}\n\nexport const _typecheckKMLLoader: LoaderWithParser = KMLLoader;\n"],"file":"kml-loader.js"}
@@ -1,6 +1,6 @@
1
1
  import { geojsonToBinary } from '@loaders.gl/gis';
2
2
  import { tcx } from '@tmcw/togeojson';
3
- const VERSION = typeof "3.1.8" !== 'undefined' ? "3.1.8" : 'latest';
3
+ const VERSION = typeof "3.2.0-alpha.3" !== 'undefined' ? "3.2.0-alpha.3" : 'latest';
4
4
  const TCX_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<TrainingCenterDatabase";
5
5
  export const TCXLoader = {
6
6
  name: 'TCX (Training Center XML)',
@@ -15,26 +15,36 @@ export const TCXLoader = {
15
15
  parseTextSync,
16
16
  options: {
17
17
  tcx: {},
18
- gis: {
19
- format: 'geojson'
20
- }
18
+ gis: {}
21
19
  }
22
20
  };
23
21
 
24
- function parseTextSync(text, options = {}) {
25
- var _options$tcx, _options$gis;
22
+ function parseTextSync(text, options) {
23
+ var _options$gis, _options$tcx, _options$tcx2;
26
24
 
27
25
  const doc = new DOMParser().parseFromString(text, 'text/xml');
28
26
  const geojson = tcx(doc);
27
+ const shape = (options === null || options === void 0 ? void 0 : (_options$gis = options.gis) === null || _options$gis === void 0 ? void 0 : _options$gis.format) || (options === null || options === void 0 ? void 0 : (_options$tcx = options.tcx) === null || _options$tcx === void 0 ? void 0 : _options$tcx.type) || (options === null || options === void 0 ? void 0 : (_options$tcx2 = options.tcx) === null || _options$tcx2 === void 0 ? void 0 : _options$tcx2.shape);
29
28
 
30
- switch (options === null || options === void 0 ? void 0 : (_options$tcx = options.tcx) === null || _options$tcx === void 0 ? void 0 : _options$tcx.type) {
29
+ switch (shape) {
31
30
  case 'object-row-table':
32
- return geojson.features;
31
+ {
32
+ const table = {
33
+ shape: 'object-row-table',
34
+ data: geojson.features
35
+ };
36
+ return table;
37
+ }
38
+
39
+ case 'geojson-row-table':
40
+ {
41
+ const table = {
42
+ shape: 'geojson-row-table',
43
+ data: geojson.features
44
+ };
45
+ return table;
46
+ }
33
47
 
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
48
  case 'geojson':
39
49
  return geojson;
40
50
 
@@ -45,7 +55,7 @@ function parseTextSync(text, options = {}) {
45
55
  return doc;
46
56
 
47
57
  default:
48
- throw new Error();
58
+ return geojson;
49
59
  }
50
60
  }
51
61
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tcx-loader.ts"],"names":["geojsonToBinary","tcx","VERSION","TCX_HEADER","TCXLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","gis","format","doc","DOMParser","parseFromString","geojson","type","features","Error","_typecheckTCXLoader"],"mappings":"AACA,SAAQA,eAAR,QAA8B,iBAA9B;AACA,SAAQC,GAAR,QAAkB,iBAAlB;AAIA,MAAMC,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE;AAMA,MAAMC,UAAU,wEAAhB;AAOA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,2BADiB;AAEvBC,EAAAA,EAAE,EAAE,KAFmB;AAGvBC,EAAAA,MAAM,EAAE,KAHe;AAIvBC,EAAAA,OAAO,EAAEN,OAJc;AAKvBO,EAAAA,UAAU,EAAE,CAAC,KAAD,CALW;AAMvBC,EAAAA,SAAS,EAAE,CAAC,gCAAD,CANY;AAOvBC,EAAAA,IAAI,EAAE,IAPiB;AAQvBC,EAAAA,KAAK,EAAE,CAACT,UAAD,CARgB;AASvBU,EAAAA,KAAK,EAAE,OAAOC,WAAP,EAAoBC,OAApB,KACLC,aAAa,CAAC,IAAIC,WAAJ,GAAkBC,MAAlB,CAAyBJ,WAAzB,CAAD,EAAwCC,OAAxC,CAVQ;AAWvBC,EAAAA,aAXuB;AAYvBD,EAAAA,OAAO,EAAE;AACPd,IAAAA,GAAG,EAAE,EADE;AAEPkB,IAAAA,GAAG,EAAE;AAACC,MAAAA,MAAM,EAAE;AAAT;AAFE;AAZc,CAAlB;;AAkBP,SAASJ,aAAT,CAAuBL,IAAvB,EAAqCI,OAAY,GAAG,EAApD,EAAwD;AAAA;;AACtD,QAAMM,GAAG,GAAG,IAAIC,SAAJ,GAAgBC,eAAhB,CAAgCZ,IAAhC,EAAsC,UAAtC,CAAZ;AACA,QAAMa,OAAO,GAAGvB,GAAG,CAACoB,GAAD,CAAnB;;AAEA,UAAQN,OAAR,aAAQA,OAAR,uCAAQA,OAAO,CAAEd,GAAjB,iDAAQ,aAAcwB,IAAtB;AACE,SAAK,kBAAL;AACE,aAAOD,OAAO,CAACE,QAAf;;AACF;AAHF;;AAMA,UAAQX,OAAR,aAAQA,OAAR,uCAAQA,OAAO,CAAEI,GAAjB,iDAAQ,aAAcC,MAAtB;AACE,SAAK,SAAL;AACE,aAAOI,OAAP;;AACF,SAAK,QAAL;AACE,aAAOxB,eAAe,CAACwB,OAAO,CAACE,QAAT,CAAtB;;AACF,SAAK,KAAL;AACE,aAAOL,GAAP;;AACF;AACE,YAAM,IAAIM,KAAJ,EAAN;AARJ;AAUD;;AAED,OAAO,MAAMC,mBAAqC,GAAGxB,SAA9C","sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport {tcx} from '@tmcw/togeojson';\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};\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 = {\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) =>\n parseTextSync(new TextDecoder().decode(arrayBuffer), options),\n parseTextSync,\n options: {\n tcx: {},\n gis: {format: 'geojson'}\n }\n};\n\nfunction parseTextSync(text: string, options: any = {}) {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson = tcx(doc);\n\n switch (options?.tcx?.type) {\n case 'object-row-table':\n return geojson.features;\n default:\n }\n\n switch (options?.gis?.format) {\n case 'geojson':\n return geojson;\n case 'binary':\n return geojsonToBinary(geojson.features);\n case 'raw':\n return doc;\n default:\n throw new Error();\n }\n}\n\nexport const _typecheckTCXLoader: LoaderWithParser = TCXLoader;\n"],"file":"tcx-loader.js"}
1
+ {"version":3,"sources":["../../src/tcx-loader.ts"],"names":["geojsonToBinary","tcx","VERSION","TCX_HEADER","TCXLoader","name","id","module","version","extensions","mimeTypes","text","tests","parse","arrayBuffer","options","parseTextSync","TextDecoder","decode","gis","doc","DOMParser","parseFromString","geojson","shape","format","type","table","data","features","_typecheckTCXLoader"],"mappings":"AACA,SAAQA,eAAR,QAA8B,iBAA9B;AACA,SAAQC,GAAR,QAAkB,iBAAlB;AAKA,MAAMC,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAcA,MAAMC,UAAU,wEAAhB;AAOA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,2BADiB;AAEvBC,EAAAA,EAAE,EAAE,KAFmB;AAGvBC,EAAAA,MAAM,EAAE,KAHe;AAIvBC,EAAAA,OAAO,EAAEN,OAJc;AAKvBO,EAAAA,UAAU,EAAE,CAAC,KAAD,CALW;AAMvBC,EAAAA,SAAS,EAAE,CAAC,gCAAD,CANY;AAOvBC,EAAAA,I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AK,QAAL;AACE,aAAOvB,eAAe,CAACuB,OAAO,CAACM,QAAT,CAAtB;;AACF,SAAK,KAAL;AACE,aAAOT,GAAP;;AACF;AAEE,aAAOG,OAAP;AAvBJ;AAyBD;;AAED,OAAO,MAAMO,mBAAqC,GAAG1B,SAA9C","sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport {tcx} from '@tmcw/togeojson';\nimport type {GeoJSONRowTable, FeatureCollection, ObjectRowTable} from '@loaders.gl/schema';\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-row-table' | 'geojson' | 'binary' | 'raw';\n /** @deprecated. Use options.tcx.shape */\n type?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';\n };\n gis?: {\n /** @deprecated. Use options.tcx.shape */\n format?: 'object-row-table' | 'geojson-row-table' | 'geojson' | '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 = {\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: {},\n gis: {}\n }\n};\n\nfunction parseTextSync(text: string, options?: TCXLoaderOptions) {\n const doc = new DOMParser().parseFromString(text, 'text/xml');\n const geojson: FeatureCollection = tcx(doc);\n\n // backwards compatibility\n const shape = options?.gis?.format || options?.tcx?.type || options?.tcx?.shape;\n\n switch (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-row-table': {\n const table: GeoJSONRowTable = {\n shape: 'geojson-row-table',\n data: 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 default:\n // Default to geojson for backwards compatibility\n return geojson;\n }\n}\n\nexport const _typecheckTCXLoader: LoaderWithParser = TCXLoader;\n"],"file":"tcx-loader.js"}
@@ -1,6 +1,15 @@
1
- import type { LoaderOptions } from '@loaders.gl/loader-utils';
1
+ import type { LoaderOptions, LoaderWithParser } from '@loaders.gl/loader-utils';
2
+ import type { GeoJSONRowTable, FeatureCollection, ObjectRowTable } from '@loaders.gl/schema';
2
3
  export declare type GPXLoaderOptions = LoaderOptions & {
3
- gpx?: {};
4
+ gpx?: {
5
+ shape?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
6
+ /** @deprecated. Use options.gpx.shape */
7
+ type?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
8
+ };
9
+ gis?: {
10
+ /** @deprecated. Use options.gpx.shape */
11
+ format?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
12
+ };
4
13
  };
5
14
  /**
6
15
  * Loader for GPX (GPS exchange format)
@@ -14,33 +23,14 @@ export declare const GPXLoader: {
14
23
  mimeTypes: string[];
15
24
  text: boolean;
16
25
  tests: string[];
17
- parse: (arrayBuffer: any, options: any) => Promise<any>;
18
- parseTextSync: typeof parseTextSync;
19
- options: {
20
- gpx: {};
21
- gis: {
22
- format: string;
23
- };
24
- };
25
- };
26
- declare function parseTextSync(text: string, options: any): any;
27
- export declare const _typecheckGPXLoader: {
28
- name: string;
29
- id: string;
30
- module: string;
31
- version: any;
32
- extensions: string[];
33
- mimeTypes: string[];
34
- text: boolean;
35
- tests: string[];
36
- parse: (arrayBuffer: any, options: any) => Promise<any>;
26
+ parse: (arrayBuffer: any, options?: GPXLoaderOptions | undefined) => Promise<Document | FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties> | ObjectRowTable | GeoJSONRowTable | import("@loaders.gl/schema").BinaryFeatures>;
37
27
  parseTextSync: typeof parseTextSync;
38
28
  options: {
39
29
  gpx: {};
40
- gis: {
41
- format: string;
42
- };
30
+ gis: {};
43
31
  };
44
32
  };
33
+ declare function parseTextSync(text: string, options?: GPXLoaderOptions): Document | FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties> | ObjectRowTable | GeoJSONRowTable | import("@loaders.gl/schema").BinaryFeatures;
34
+ export declare const _typecheckGPXLoader: LoaderWithParser;
45
35
  export {};
46
36
  //# sourceMappingURL=gpx-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gpx-loader.d.ts","sourceRoot":"","sources":["../src/gpx-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAQ5D,oBAAY,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,EAAE,CAAC;CACV,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;CAgBrB,CAAC;AAEF,iBAAS,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAoBhD;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;CAAY,CAAC"}
1
+ {"version":3,"file":"gpx-loader.d.ts","sourceRoot":"","sources":["../src/gpx-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAG9E,OAAO,KAAK,EAAC,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAM3F,oBAAY,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;;;;;;;;;;;;;;;CAgBrB,CAAC;AAEF,iBAAS,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,kLA+B9D;AAED,eAAO,MAAM,mBAAmB,EAAE,gBAA4B,CAAC"}
@@ -25,18 +25,28 @@ exports.GPXLoader = {
25
25
  parseTextSync,
26
26
  options: {
27
27
  gpx: {},
28
- gis: { format: 'geojson' }
28
+ gis: {}
29
29
  }
30
30
  };
31
31
  function parseTextSync(text, options) {
32
32
  const doc = new DOMParser().parseFromString(text, 'text/xml');
33
33
  const geojson = (0, togeojson_1.gpx)(doc);
34
- switch (options?.gpx?.type) {
35
- case 'object-row-table':
36
- return geojson.features;
37
- default:
38
- }
39
- switch (options?.gis?.format) {
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
+ }
40
50
  case 'geojson':
41
51
  return geojson;
42
52
  case 'binary':
@@ -44,7 +54,8 @@ function parseTextSync(text, options) {
44
54
  case 'raw':
45
55
  return doc;
46
56
  default:
47
- throw new Error();
57
+ // Default to geojson for backwards compatibility
58
+ return geojson;
48
59
  }
49
60
  }
50
61
  exports._typecheckGPXLoader = exports.GPXLoader;
@@ -1,6 +1,15 @@
1
1
  import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
2
+ import { GeoJSONRowTable, FeatureCollection, ObjectRowTable } from '@loaders.gl/schema';
2
3
  export declare type KMLLoaderOptions = LoaderOptions & {
3
- kml?: {};
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: any) => Promise<any>;
26
+ parse: (arrayBuffer: any, options?: KMLLoaderOptions | undefined) => 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: any): any;
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
@@ -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;AAQ9E,oBAAY,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,EAAE,CAAC;CACV,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;CAgBrB,CAAC;AAEF,iBAAS,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAoBhD;AAED,eAAO,MAAM,mBAAmB,EAAE,gBAA4B,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,oBAAY,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;;;;;;;;;;;;;;;CAgBrB,CAAC;AAEF,iBAAS,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,kLA+B9D;AAED,eAAO,MAAM,mBAAmB,EAAE,gBAA4B,CAAC"}
@@ -25,18 +25,29 @@ exports.KMLLoader = {
25
25
  parseTextSync,
26
26
  options: {
27
27
  kml: {},
28
- gis: { format: 'geojson' }
28
+ gis: {}
29
29
  }
30
30
  };
31
31
  function parseTextSync(text, options) {
32
32
  const doc = new DOMParser().parseFromString(text, 'text/xml');
33
33
  const geojson = (0, togeojson_1.kml)(doc);
34
- switch (options?.kml?.type) {
35
- case 'object-row-table':
36
- return geojson.features;
37
- default:
38
- }
39
- switch (options?.gis?.format) {
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
+ }
40
51
  case 'geojson':
41
52
  return geojson;
42
53
  case 'binary':
@@ -44,7 +55,8 @@ function parseTextSync(text, options) {
44
55
  case 'raw':
45
56
  return doc;
46
57
  default:
47
- throw new Error();
58
+ // Default to geojson for backwards compatibility
59
+ return geojson;
48
60
  }
49
61
  }
50
62
  exports._typecheckKMLLoader = exports.KMLLoader;
@@ -1,6 +1,15 @@
1
1
  import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
2
+ import type { GeoJSONRowTable, FeatureCollection, ObjectRowTable } from '@loaders.gl/schema';
2
3
  export declare type TCXLoaderOptions = LoaderOptions & {
3
- tcx?: {};
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: any) => Promise<any>;
26
+ parse: (arrayBuffer: any, options?: TCXLoaderOptions | undefined) => 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?: any): any;
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
@@ -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;AAQ9E,oBAAY,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,EAAE,CAAC;CACV,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;CAgBrB,CAAC;AAEF,iBAAS,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,GAAQ,OAoBrD;AAED,eAAO,MAAM,mBAAmB,EAAE,gBAA4B,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,oBAAY,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;;;;;;;;;;;;;;;CAgBrB,CAAC;AAEF,iBAAS,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,kLAgC9D;AAED,eAAO,MAAM,mBAAmB,EAAE,gBAA4B,CAAC"}
@@ -25,18 +25,29 @@ exports.TCXLoader = {
25
25
  parseTextSync,
26
26
  options: {
27
27
  tcx: {},
28
- gis: { format: 'geojson' }
28
+ gis: {}
29
29
  }
30
30
  };
31
- function parseTextSync(text, options = {}) {
31
+ function parseTextSync(text, options) {
32
32
  const doc = new DOMParser().parseFromString(text, 'text/xml');
33
33
  const geojson = (0, togeojson_1.tcx)(doc);
34
- switch (options?.tcx?.type) {
35
- case 'object-row-table':
36
- return geojson.features;
37
- default:
38
- }
39
- switch (options?.gis?.format) {
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
+ }
40
51
  case 'geojson':
41
52
  return geojson;
42
53
  case 'binary':
@@ -44,7 +55,8 @@ function parseTextSync(text, options = {}) {
44
55
  case 'raw':
45
56
  return doc;
46
57
  default:
47
- throw new Error();
58
+ // Default to geojson for backwards compatibility
59
+ return geojson;
48
60
  }
49
61
  }
50
62
  exports._typecheckTCXLoader = exports.TCXLoader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/kml",
3
- "version": "3.1.8",
3
+ "version": "3.2.0-alpha.3",
4
4
  "description": "Framework-independent loader for the KML format",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -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": "3.1.8",
36
- "@loaders.gl/loader-utils": "3.1.8",
37
- "@loaders.gl/schema": "3.1.8",
35
+ "@loaders.gl/gis": "3.2.0-alpha.3",
36
+ "@loaders.gl/loader-utils": "3.2.0-alpha.3",
37
+ "@loaders.gl/schema": "3.2.0-alpha.3",
38
38
  "@tmcw/togeojson": "^4.5.0"
39
39
  },
40
- "gitHead": "0ef07b4e9fc20f5a882224cf241c6fd1bad898d8"
40
+ "gitHead": "f0d4b801efeb7094283106352ee759eccfb21f10"
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: {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;
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: {format: 'geojson'}
43
+ gis: {}
35
44
  }
36
45
  };
37
46
 
38
- function parseTextSync(text: string, options: any) {
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
- switch (options?.kml?.type) {
43
- case 'object-row-table':
44
- return geojson.features;
45
- default:
46
- }
47
-
48
- switch (options?.gis?.format) {
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
- throw new Error();
75
+ // Default to geojson for backwards compatibility
76
+ return geojson;
57
77
  }
58
78
  }
59
79
 
package/src/tcx-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 {tcx} 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 TCXLoaderOptions = LoaderOptions & {
10
- tcx?: {};
11
+ tcx?: {
12
+ shape?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
13
+ /** @deprecated. Use options.tcx.shape */
14
+ type?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
15
+ };
16
+ gis?: {
17
+ /** @deprecated. Use options.tcx.shape */
18
+ format?: 'object-row-table' | 'geojson-row-table' | 'geojson' | 'binary' | 'raw';
19
+ };
11
20
  };
12
21
 
13
22
  const TCX_HEADER = `\
@@ -26,26 +35,37 @@ export const TCXLoader = {
26
35
  mimeTypes: ['application/vnd.garmin.tcx+xml'],
27
36
  text: true,
28
37
  tests: [TCX_HEADER],
29
- parse: async (arrayBuffer, options) =>
38
+ parse: async (arrayBuffer, options?: TCXLoaderOptions) =>
30
39
  parseTextSync(new TextDecoder().decode(arrayBuffer), options),
31
40
  parseTextSync,
32
41
  options: {
33
42
  tcx: {},
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?: TCXLoaderOptions) {
39
48
  const doc = new DOMParser().parseFromString(text, 'text/xml');
40
- const geojson = tcx(doc);
49
+ const geojson: FeatureCollection = tcx(doc);
41
50
 
42
- switch (options?.tcx?.type) {
43
- case 'object-row-table':
44
- return geojson.features;
45
- default:
46
- }
51
+ // backwards compatibility
52
+ const shape = options?.gis?.format || options?.tcx?.type || options?.tcx?.shape;
47
53
 
48
- switch (options?.gis?.format) {
54
+ switch (shape) {
55
+ case 'object-row-table': {
56
+ const table: ObjectRowTable = {
57
+ shape: 'object-row-table',
58
+ data: geojson.features
59
+ };
60
+ return table;
61
+ }
62
+ case 'geojson-row-table': {
63
+ const table: GeoJSONRowTable = {
64
+ shape: 'geojson-row-table',
65
+ data: geojson.features
66
+ };
67
+ return table;
68
+ }
49
69
  case 'geojson':
50
70
  return geojson;
51
71
  case 'binary':
@@ -53,7 +73,8 @@ function parseTextSync(text: string, options: any = {}) {
53
73
  case 'raw':
54
74
  return doc;
55
75
  default:
56
- throw new Error();
76
+ // Default to geojson for backwards compatibility
77
+ return geojson;
57
78
  }
58
79
  }
59
80