@loaders.gl/kml 4.0.4 → 4.1.0-alpha.2

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 CHANGED
@@ -6456,6 +6456,10 @@ var __exports__ = (() => {
6456
6456
  const table = {
6457
6457
  shape: "geojson-table",
6458
6458
  type: "FeatureCollection",
6459
+ schema: {
6460
+ metadata: {},
6461
+ fields: []
6462
+ },
6459
6463
  features: geojson.features
6460
6464
  };
6461
6465
  return table;
package/dist/index.cjs CHANGED
@@ -161,6 +161,7 @@ function parseTextSync3(text, options) {
161
161
  const table = {
162
162
  shape: "geojson-table",
163
163
  type: "FeatureCollection",
164
+ schema: { metadata: {}, fields: [] },
164
165
  features: geojson.features
165
166
  };
166
167
  return table;
@@ -44,6 +44,10 @@ function parseTextSync(text, options) {
44
44
  const table = {
45
45
  shape: 'geojson-table',
46
46
  type: 'FeatureCollection',
47
+ schema: {
48
+ metadata: {},
49
+ fields: []
50
+ },
47
51
  features: geojson.features
48
52
  };
49
53
  return table;
@@ -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","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,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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"}
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","schema","metadata","fields","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 schema: {metadata: {}, fields: []},\n features: geojson.features\n };\n return table;\n }\n case 'binary':\n return geojsonToBinary(geojson.features);\n\n default:\n throw new Error(tcxOptions.shape);\n }\n}\n"],"mappings":"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,EAAE,KAAK;EACbC,OAAO,EAAEP,OAAO;EAChBQ,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,gCAAgC,CAAC;EAC7CC,IAAI,EAAE,IAAI;EACVC,KAAK,EAAE,CAACT,UAAU,CAAC;EACnBU,KAAK,EAAE,MAAAA,CAAOC,WAAW,EAAEC,OAA0B,KACnDC,aAAa,CAAC,IAAIC,WAAW,CAA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"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.4",
44
- "@loaders.gl/loader-utils": "4.0.4",
45
- "@loaders.gl/schema": "4.0.4",
43
+ "@loaders.gl/gis": "4.1.0-alpha.2",
44
+ "@loaders.gl/loader-utils": "4.1.0-alpha.2",
45
+ "@loaders.gl/schema": "4.1.0-alpha.2",
46
46
  "@tmcw/togeojson": "^4.5.0",
47
47
  "@xmldom/xmldom": "^0.7.13"
48
48
  },
49
- "gitHead": "4dc810fa04bb400f4aedfef98a83c7ef882ed3d7"
49
+ "gitHead": "a248382edd20e846c1ccb23c15d089fb9b368dbc"
50
50
  }
package/src/tcx-loader.ts CHANGED
@@ -72,6 +72,7 @@ function parseTextSync(
72
72
  const table: GeoJSONTable = {
73
73
  shape: 'geojson-table',
74
74
  type: 'FeatureCollection',
75
+ schema: {metadata: {}, fields: []},
75
76
  features: geojson.features
76
77
  };
77
78
  return table;