@loaders.gl/kml 4.0.0-beta.5 → 4.0.0-beta.7
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 +19 -15
- package/dist/gpx-loader.d.ts +3 -8
- package/dist/gpx-loader.d.ts.map +1 -1
- package/dist/gpx-loader.js +3 -7
- package/dist/gpx-loader.js.map +1 -1
- package/dist/index.cjs +19 -18
- package/dist/kml-loader.d.ts +3 -9
- package/dist/kml-loader.d.ts.map +1 -1
- package/dist/kml-loader.js +16 -4
- package/dist/kml-loader.js.map +1 -1
- package/dist/tcx-loader.d.ts +3 -8
- package/dist/tcx-loader.d.ts.map +1 -1
- package/dist/tcx-loader.js +3 -7
- package/dist/tcx-loader.js.map +1 -1
- package/package.json +5 -5
- package/src/gpx-loader.ts +19 -17
- package/src/kml-loader.ts +16 -20
- package/src/tcx-loader.ts +19 -17
package/dist/dist.dev.js
CHANGED
|
@@ -5296,6 +5296,7 @@ var __exports__ = (() => {
|
|
|
5296
5296
|
}
|
|
5297
5297
|
function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
5298
5298
|
const binaryFeatures = {
|
|
5299
|
+
shape: "binary-feature-collection",
|
|
5299
5300
|
points: {
|
|
5300
5301
|
...points,
|
|
5301
5302
|
positions: {
|
|
@@ -6334,7 +6335,7 @@ var __exports__ = (() => {
|
|
|
6334
6335
|
function parseTextSync(text, options) {
|
|
6335
6336
|
const doc = new import_xmldom.DOMParser().parseFromString(text, "text/xml");
|
|
6336
6337
|
const geojson = gpx(doc);
|
|
6337
|
-
const shape = options?.
|
|
6338
|
+
const shape = options?.gpx?.shape;
|
|
6338
6339
|
switch (shape) {
|
|
6339
6340
|
case "object-row-table": {
|
|
6340
6341
|
const table = {
|
|
@@ -6351,14 +6352,10 @@ var __exports__ = (() => {
|
|
|
6351
6352
|
};
|
|
6352
6353
|
return table;
|
|
6353
6354
|
}
|
|
6354
|
-
case "geojson":
|
|
6355
|
-
return geojson;
|
|
6356
6355
|
case "binary":
|
|
6357
6356
|
return geojsonToBinary(geojson.features);
|
|
6358
|
-
case "raw":
|
|
6359
|
-
return doc;
|
|
6360
6357
|
default:
|
|
6361
|
-
|
|
6358
|
+
throw new Error(shape);
|
|
6362
6359
|
}
|
|
6363
6360
|
}
|
|
6364
6361
|
|
|
@@ -6379,22 +6376,33 @@ var __exports__ = (() => {
|
|
|
6379
6376
|
parse: async (arrayBuffer, options) => parseTextSync2(new TextDecoder().decode(arrayBuffer), options),
|
|
6380
6377
|
parseTextSync: parseTextSync2,
|
|
6381
6378
|
options: {
|
|
6382
|
-
kml: {
|
|
6379
|
+
kml: {
|
|
6380
|
+
shape: "geojson-table"
|
|
6381
|
+
},
|
|
6383
6382
|
gis: {}
|
|
6384
6383
|
}
|
|
6385
6384
|
};
|
|
6386
6385
|
function parseTextSync2(text, options) {
|
|
6387
6386
|
const doc = new import_xmldom2.DOMParser().parseFromString(text, "text/xml");
|
|
6388
6387
|
const geojson = kml(doc);
|
|
6389
|
-
const shape = options?.
|
|
6388
|
+
const shape = options?.kml?.shape || KMLLoader.options.kml?.shape;
|
|
6390
6389
|
switch (shape) {
|
|
6390
|
+
case "geojson-table": {
|
|
6391
|
+
const table2 = {
|
|
6392
|
+
shape: "geojson-table",
|
|
6393
|
+
type: "FeatureCollection",
|
|
6394
|
+
features: geojson.features
|
|
6395
|
+
};
|
|
6396
|
+
return table2;
|
|
6397
|
+
}
|
|
6391
6398
|
case "object-row-table":
|
|
6392
|
-
default:
|
|
6393
6399
|
const table = {
|
|
6394
6400
|
shape: "object-row-table",
|
|
6395
6401
|
data: geojson.features
|
|
6396
6402
|
};
|
|
6397
6403
|
return table;
|
|
6404
|
+
default:
|
|
6405
|
+
throw new Error(shape);
|
|
6398
6406
|
}
|
|
6399
6407
|
}
|
|
6400
6408
|
|
|
@@ -6422,7 +6430,7 @@ var __exports__ = (() => {
|
|
|
6422
6430
|
function parseTextSync3(text, options) {
|
|
6423
6431
|
const doc = new import_xmldom3.DOMParser().parseFromString(text, "text/xml");
|
|
6424
6432
|
const geojson = tcx(doc);
|
|
6425
|
-
const shape = options?.
|
|
6433
|
+
const shape = options?.tcx?.shape;
|
|
6426
6434
|
switch (shape) {
|
|
6427
6435
|
case "object-row-table": {
|
|
6428
6436
|
const table = {
|
|
@@ -6439,14 +6447,10 @@ var __exports__ = (() => {
|
|
|
6439
6447
|
};
|
|
6440
6448
|
return table;
|
|
6441
6449
|
}
|
|
6442
|
-
case "geojson":
|
|
6443
|
-
return geojson;
|
|
6444
6450
|
case "binary":
|
|
6445
6451
|
return geojsonToBinary(geojson.features);
|
|
6446
|
-
case "raw":
|
|
6447
|
-
return doc;
|
|
6448
6452
|
default:
|
|
6449
|
-
|
|
6453
|
+
throw new Error(shape);
|
|
6450
6454
|
}
|
|
6451
6455
|
}
|
|
6452
6456
|
return __toCommonJS(src_exports);
|
package/dist/gpx-loader.d.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import type { LoaderOptions, LoaderWithParser } from '@loaders.gl/loader-utils';
|
|
2
|
+
import type { GeoJSONTable, ObjectRowTable, BinaryFeatureCollection } from '@loaders.gl/schema';
|
|
2
3
|
export type GPXLoaderOptions = LoaderOptions & {
|
|
3
4
|
gpx?: {
|
|
4
|
-
shape?: 'object-row-table' | 'geojson-table' | '
|
|
5
|
-
/** @deprecated. Use options.gpx.shape */
|
|
6
|
-
type?: 'object-row-table' | 'geojson-table' | 'geojson' | 'binary' | 'raw';
|
|
7
|
-
};
|
|
8
|
-
gis?: {
|
|
9
|
-
/** @deprecated. Use options.gpx.shape */
|
|
10
|
-
format?: 'object-row-table' | 'geojson-table' | 'geojson' | 'binary' | 'raw';
|
|
5
|
+
shape?: 'object-row-table' | 'geojson-table' | 'binary' | 'raw';
|
|
11
6
|
};
|
|
12
7
|
};
|
|
13
8
|
/**
|
|
14
9
|
* Loader for GPX (GPS exchange format)
|
|
15
10
|
*/
|
|
16
|
-
export declare const GPXLoader: LoaderWithParser<
|
|
11
|
+
export declare const GPXLoader: LoaderWithParser<ObjectRowTable | GeoJSONTable | BinaryFeatureCollection, never, GPXLoaderOptions>;
|
|
17
12
|
//# sourceMappingURL=gpx-loader.d.ts.map
|
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":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,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;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
|
@@ -22,10 +22,10 @@ export const GPXLoader = {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
function parseTextSync(text, options) {
|
|
25
|
-
var _options$
|
|
25
|
+
var _options$gpx;
|
|
26
26
|
const doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
27
27
|
const geojson = gpx(doc);
|
|
28
|
-
const shape =
|
|
28
|
+
const shape = options === null || options === void 0 ? void 0 : (_options$gpx = options.gpx) === null || _options$gpx === void 0 ? void 0 : _options$gpx.shape;
|
|
29
29
|
switch (shape) {
|
|
30
30
|
case 'object-row-table':
|
|
31
31
|
{
|
|
@@ -44,14 +44,10 @@ function parseTextSync(text, options) {
|
|
|
44
44
|
};
|
|
45
45
|
return table;
|
|
46
46
|
}
|
|
47
|
-
case 'geojson':
|
|
48
|
-
return geojson;
|
|
49
47
|
case 'binary':
|
|
50
48
|
return geojsonToBinary(geojson.features);
|
|
51
|
-
case 'raw':
|
|
52
|
-
return doc;
|
|
53
49
|
default:
|
|
54
|
-
|
|
50
|
+
throw new Error(shape);
|
|
55
51
|
}
|
|
56
52
|
}
|
|
57
53
|
//# 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","gis","_options$
|
|
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","gis","_options$gpx","doc","parseFromString","geojson","shape","table","data","features","type","Error"],"sources":["../src/gpx-loader.ts"],"sourcesContent":["import 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: {},\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 shape = 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-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(shape);\n }\n}\n"],"mappings":"AACA,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,CAAC,CAAC;IACPoB,GAAG,EAAE,CAAC;EACR;AACF,CAAC;AAED,SAASH,aAAaA,CACpBL,IAAY,EACZI,OAA0B,EAC+B;EAAA,IAAAK,YAAA;EACzD,MAAMC,GAAG,GAAG,IAAIrB,SAAS,CAAC,CAAC,CAACsB,eAAe,CAACX,IAAI,EAAE,UAAU,CAAC;EAC7D,MAAMY,OAA0B,GAAGxB,GAAG,CAACsB,GAAG,CAAC;EAE3C,MAAMG,KAAK,GAAGT,OAAO,aAAPA,OAAO,wBAAAK,YAAA,GAAPL,OAAO,CAAEhB,GAAG,cAAAqB,YAAA,uBAAZA,YAAA,CAAcI,KAAK;EAEjC,QAAQA,KAAK;IACX,KAAK,kBAAkB;MAAE;QACvB,MAAMC,KAAqB,GAAG;UAC5BD,KAAK,EAAE,kBAAkB;UACzBE,IAAI,EAAEH,OAAO,CAACI;QAChB,CAAC;QACD,OAAOF,KAAK;MACd;IACA,KAAK,eAAe;MAAE;QACpB,MAAMA,KAAmB,GAAG;UAC1BD,KAAK,EAAE,eAAe;UACtBI,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,KAAK,CAAC;EAC1B;AACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -50,10 +50,10 @@ var GPXLoader = {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
function parseTextSync(text, options) {
|
|
53
|
-
var _a
|
|
53
|
+
var _a;
|
|
54
54
|
const doc = new import_xmldom.DOMParser().parseFromString(text, "text/xml");
|
|
55
55
|
const geojson = (0, import_togeojson.gpx)(doc);
|
|
56
|
-
const shape = (
|
|
56
|
+
const shape = (_a = options == null ? void 0 : options.gpx) == null ? void 0 : _a.shape;
|
|
57
57
|
switch (shape) {
|
|
58
58
|
case "object-row-table": {
|
|
59
59
|
const table = {
|
|
@@ -70,14 +70,10 @@ function parseTextSync(text, options) {
|
|
|
70
70
|
};
|
|
71
71
|
return table;
|
|
72
72
|
}
|
|
73
|
-
case "geojson":
|
|
74
|
-
return geojson;
|
|
75
73
|
case "binary":
|
|
76
74
|
return (0, import_gis.geojsonToBinary)(geojson.features);
|
|
77
|
-
case "raw":
|
|
78
|
-
return doc;
|
|
79
75
|
default:
|
|
80
|
-
|
|
76
|
+
throw new Error(shape);
|
|
81
77
|
}
|
|
82
78
|
}
|
|
83
79
|
|
|
@@ -99,23 +95,32 @@ var KMLLoader = {
|
|
|
99
95
|
parse: async (arrayBuffer, options) => parseTextSync2(new TextDecoder().decode(arrayBuffer), options),
|
|
100
96
|
parseTextSync: parseTextSync2,
|
|
101
97
|
options: {
|
|
102
|
-
kml: {},
|
|
98
|
+
kml: { shape: "geojson-table" },
|
|
103
99
|
gis: {}
|
|
104
100
|
}
|
|
105
101
|
};
|
|
106
102
|
function parseTextSync2(text, options) {
|
|
107
|
-
var _a, _b
|
|
103
|
+
var _a, _b;
|
|
108
104
|
const doc = new import_xmldom2.DOMParser().parseFromString(text, "text/xml");
|
|
109
105
|
const geojson = (0, import_togeojson2.kml)(doc);
|
|
110
|
-
const shape = ((_a = options == null ? void 0 : options.
|
|
106
|
+
const shape = ((_a = options == null ? void 0 : options.kml) == null ? void 0 : _a.shape) || ((_b = KMLLoader.options.kml) == null ? void 0 : _b.shape);
|
|
111
107
|
switch (shape) {
|
|
108
|
+
case "geojson-table": {
|
|
109
|
+
const table2 = {
|
|
110
|
+
shape: "geojson-table",
|
|
111
|
+
type: "FeatureCollection",
|
|
112
|
+
features: geojson.features
|
|
113
|
+
};
|
|
114
|
+
return table2;
|
|
115
|
+
}
|
|
112
116
|
case "object-row-table":
|
|
113
|
-
default:
|
|
114
117
|
const table = {
|
|
115
118
|
shape: "object-row-table",
|
|
116
119
|
data: geojson.features
|
|
117
120
|
};
|
|
118
121
|
return table;
|
|
122
|
+
default:
|
|
123
|
+
throw new Error(shape);
|
|
119
124
|
}
|
|
120
125
|
}
|
|
121
126
|
|
|
@@ -143,10 +148,10 @@ var TCXLoader = {
|
|
|
143
148
|
}
|
|
144
149
|
};
|
|
145
150
|
function parseTextSync3(text, options) {
|
|
146
|
-
var _a
|
|
151
|
+
var _a;
|
|
147
152
|
const doc = new import_xmldom3.DOMParser().parseFromString(text, "text/xml");
|
|
148
153
|
const geojson = (0, import_togeojson3.tcx)(doc);
|
|
149
|
-
const shape = (
|
|
154
|
+
const shape = (_a = options == null ? void 0 : options.tcx) == null ? void 0 : _a.shape;
|
|
150
155
|
switch (shape) {
|
|
151
156
|
case "object-row-table": {
|
|
152
157
|
const table = {
|
|
@@ -163,13 +168,9 @@ function parseTextSync3(text, options) {
|
|
|
163
168
|
};
|
|
164
169
|
return table;
|
|
165
170
|
}
|
|
166
|
-
case "geojson":
|
|
167
|
-
return geojson;
|
|
168
171
|
case "binary":
|
|
169
172
|
return (0, import_gis2.geojsonToBinary)(geojson.features);
|
|
170
|
-
case "raw":
|
|
171
|
-
return doc;
|
|
172
173
|
default:
|
|
173
|
-
|
|
174
|
+
throw new Error(shape);
|
|
174
175
|
}
|
|
175
176
|
}
|
package/dist/kml-loader.d.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
-
import { ObjectRowTable } from '@loaders.gl/schema';
|
|
2
|
+
import { GeoJSONTable, ObjectRowTable } from '@loaders.gl/schema';
|
|
3
3
|
export type KMLLoaderOptions = LoaderOptions & {
|
|
4
4
|
kml?: {
|
|
5
|
-
shape?: 'object-row-table' | 'geojson-table';
|
|
6
|
-
/** @deprecated. Use options.kml.shape */
|
|
7
|
-
type?: 'object-row-table' | 'geojson-table';
|
|
8
|
-
};
|
|
9
|
-
gis?: {
|
|
10
|
-
/** @deprecated. Use options.kml.shape */
|
|
11
|
-
format?: 'object-row-table' | 'geojson-table' | 'geojson' | 'binary' | 'raw';
|
|
5
|
+
shape?: 'object-row-table' | 'geojson-table' | 'binary' | 'raw';
|
|
12
6
|
};
|
|
13
7
|
};
|
|
14
8
|
/**
|
|
15
9
|
* Loader for KML (Keyhole Markup Language)
|
|
16
10
|
*/
|
|
17
|
-
export declare const KMLLoader: LoaderWithParser<ObjectRowTable, never, KMLLoaderOptions>;
|
|
11
|
+
export declare const KMLLoader: LoaderWithParser<ObjectRowTable | GeoJSONTable, never, KMLLoaderOptions>;
|
|
18
12
|
//# sourceMappingURL=kml-loader.d.ts.map
|
package/dist/kml-loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kml-loader.d.ts","sourceRoot":"","sources":["../src/kml-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAG9E,OAAO,EAAoB,cAAc,EAAC,MAAM,oBAAoB,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,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
|
@@ -16,23 +16,35 @@ export const KMLLoader = {
|
|
|
16
16
|
parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
|
|
17
17
|
parseTextSync,
|
|
18
18
|
options: {
|
|
19
|
-
kml: {
|
|
19
|
+
kml: {
|
|
20
|
+
shape: 'geojson-table'
|
|
21
|
+
},
|
|
20
22
|
gis: {}
|
|
21
23
|
}
|
|
22
24
|
};
|
|
23
25
|
function parseTextSync(text, options) {
|
|
24
|
-
var _options$
|
|
26
|
+
var _options$kml, _KMLLoader$options$km;
|
|
25
27
|
const doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
26
28
|
const geojson = kml(doc);
|
|
27
|
-
const shape = (options === null || options === void 0 ? void 0 : (_options$
|
|
29
|
+
const shape = (options === null || options === void 0 ? void 0 : (_options$kml = options.kml) === null || _options$kml === void 0 ? void 0 : _options$kml.shape) || ((_KMLLoader$options$km = KMLLoader.options.kml) === null || _KMLLoader$options$km === void 0 ? void 0 : _KMLLoader$options$km.shape);
|
|
28
30
|
switch (shape) {
|
|
31
|
+
case 'geojson-table':
|
|
32
|
+
{
|
|
33
|
+
const table = {
|
|
34
|
+
shape: 'geojson-table',
|
|
35
|
+
type: 'FeatureCollection',
|
|
36
|
+
features: geojson.features
|
|
37
|
+
};
|
|
38
|
+
return table;
|
|
39
|
+
}
|
|
29
40
|
case 'object-row-table':
|
|
30
|
-
default:
|
|
31
41
|
const table = {
|
|
32
42
|
shape: 'object-row-table',
|
|
33
43
|
data: geojson.features
|
|
34
44
|
};
|
|
35
45
|
return table;
|
|
46
|
+
default:
|
|
47
|
+
throw new Error(shape);
|
|
36
48
|
}
|
|
37
49
|
}
|
|
38
50
|
//# 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","
|
|
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","_options$kml","_KMLLoader$options$km","doc","parseFromString","geojson","table","type","features","data","Error"],"sources":["../src/kml-loader.ts"],"sourcesContent":["import 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 // backwards compatibility\n const shape = options?.kml?.shape || KMLLoader.options.kml?.shape;\n switch (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(shape);\n }\n}\n"],"mappings":"AAIA,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,KAAK;EACbC,OAAO,EAAEP,OAAO;EAChBQ,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,sCAAsC,CAAC;EACnDC,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,CAACL,IAAY,EAAEI,OAA0B,EAAiC;EAAA,IAAAM,YAAA,EAAAC,qBAAA;EAC9F,MAAMC,GAAG,GAAG,IAAIvB,SAAS,CAAC,CAAC,CAACwB,eAAe,CAACb,IAAI,EAAE,UAAU,CAAC;EAC7D,MAAMc,OAA0B,GAAG1B,GAAG,CAACwB,GAAG,CAAC;EAG3C,MAAMJ,KAAK,GAAG,CAAAJ,OAAO,aAAPA,OAAO,wBAAAM,YAAA,GAAPN,OAAO,CAAEhB,GAAG,cAAAsB,YAAA,uBAAZA,YAAA,CAAcF,KAAK,OAAAG,qBAAA,GAAIlB,SAAS,CAACW,OAAO,CAAChB,GAAG,cAAAuB,qBAAA,uBAArBA,qBAAA,CAAuBH,KAAK;EACjE,QAAQA,KAAK;IACX,KAAK,eAAe;MAAE;QACpB,MAAMO,KAAmB,GAAG;UAC1BP,KAAK,EAAE,eAAe;UACtBQ,IAAI,EAAE,mBAAmB;UACzBC,QAAQ,EAAEH,OAAO,CAACG;QACpB,CAAC;QACD,OAAOF,KAAK;MACd;IAOA,KAAK,kBAAkB;MACrB,MAAMA,KAAqB,GAAG;QAC5BP,KAAK,EAAE,kBAAkB;QACzBU,IAAI,EAAEJ,OAAO,CAACG;MAChB,CAAC;MACD,OAAOF,KAAK;IACd;MACE,MAAM,IAAII,KAAK,CAACX,KAAK,CAAC;EAC1B;AACF"}
|
package/dist/tcx-loader.d.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
+
import type { GeoJSONTable, ObjectRowTable, BinaryFeatureCollection } from '@loaders.gl/schema';
|
|
2
3
|
export type TCXLoaderOptions = LoaderOptions & {
|
|
3
4
|
tcx?: {
|
|
4
|
-
shape?: 'object-row-table' | 'geojson-table' | '
|
|
5
|
-
/** @deprecated. Use options.tcx.shape */
|
|
6
|
-
type?: 'object-row-table' | 'geojson-table' | 'geojson' | 'binary' | 'raw';
|
|
7
|
-
};
|
|
8
|
-
gis?: {
|
|
9
|
-
/** @deprecated. Use options.tcx.shape */
|
|
10
|
-
format?: 'object-row-table' | 'geojson-table' | 'geojson' | 'binary' | 'raw';
|
|
5
|
+
shape?: 'object-row-table' | 'geojson-table' | 'binary' | 'raw';
|
|
11
6
|
};
|
|
12
7
|
};
|
|
13
8
|
/**
|
|
14
9
|
* Loader for TCX (Training Center XML) - Garmin GPS track format
|
|
15
10
|
*/
|
|
16
|
-
export declare const TCXLoader: LoaderWithParser<
|
|
11
|
+
export declare const TCXLoader: LoaderWithParser<ObjectRowTable | GeoJSONTable | BinaryFeatureCollection, never, TCXLoaderOptions>;
|
|
17
12
|
//# sourceMappingURL=tcx-loader.d.ts.map
|
package/dist/tcx-loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcx-loader.d.ts","sourceRoot":"","sources":["../src/tcx-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"tcx-loader.d.ts","sourceRoot":"","sources":["../src/tcx-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;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
|
@@ -22,10 +22,10 @@ export const TCXLoader = {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
function parseTextSync(text, options) {
|
|
25
|
-
var _options$
|
|
25
|
+
var _options$tcx;
|
|
26
26
|
const doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
27
27
|
const geojson = tcx(doc);
|
|
28
|
-
const shape =
|
|
28
|
+
const shape = options === null || options === void 0 ? void 0 : (_options$tcx = options.tcx) === null || _options$tcx === void 0 ? void 0 : _options$tcx.shape;
|
|
29
29
|
switch (shape) {
|
|
30
30
|
case 'object-row-table':
|
|
31
31
|
{
|
|
@@ -44,14 +44,10 @@ function parseTextSync(text, options) {
|
|
|
44
44
|
};
|
|
45
45
|
return table;
|
|
46
46
|
}
|
|
47
|
-
case 'geojson':
|
|
48
|
-
return geojson;
|
|
49
47
|
case 'binary':
|
|
50
48
|
return geojsonToBinary(geojson.features);
|
|
51
|
-
case 'raw':
|
|
52
|
-
return doc;
|
|
53
49
|
default:
|
|
54
|
-
|
|
50
|
+
throw new Error(shape);
|
|
55
51
|
}
|
|
56
52
|
}
|
|
57
53
|
//# 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","gis","_options$
|
|
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","gis","_options$tcx","doc","parseFromString","geojson","shape","table","data","features","type","Error"],"sources":["../src/tcx-loader.ts"],"sourcesContent":["import 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: {},\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 // backwards compatibility\n const shape = 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-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(shape);\n }\n}\n"],"mappings":"AACA,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,CAAC,CAAC,CAACC,MAAM,CAACJ,WAAW,CAAC,EAAEC,OAAO,CAAC;EAC/DC,aAAa;EACbD,OAAO,EAAE;IACPhB,GAAG,EAAE,CAAC,CAAC;IACPoB,GAAG,EAAE,CAAC;EACR;AACF,CAAC;AAED,SAASH,aAAaA,CACpBL,IAAY,EACZI,OAA0B,EAC+B;EAAA,IAAAK,YAAA;EACzD,MAAMC,GAAG,GAAG,IAAIrB,SAAS,CAAC,CAAC,CAACsB,eAAe,CAACX,IAAI,EAAE,UAAU,CAAC;EAC7D,MAAMY,OAA0B,GAAGxB,GAAG,CAACsB,GAAG,CAAC;EAG3C,MAAMG,KAAK,GAAGT,OAAO,aAAPA,OAAO,wBAAAK,YAAA,GAAPL,OAAO,CAAEhB,GAAG,cAAAqB,YAAA,uBAAZA,YAAA,CAAcI,KAAK;EAEjC,QAAQA,KAAK;IACX,KAAK,kBAAkB;MAAE;QACvB,MAAMC,KAAqB,GAAG;UAC5BD,KAAK,EAAE,kBAAkB;UACzBE,IAAI,EAAEH,OAAO,CAACI;QAChB,CAAC;QACD,OAAOF,KAAK;MACd;IACA,KAAK,eAAe;MAAE;QACpB,MAAMA,KAAmB,GAAG;UAC1BD,KAAK,EAAE,eAAe;UACtBI,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,KAAK,CAAC;EAC1B;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/kml",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.7",
|
|
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.0-beta.
|
|
44
|
-
"@loaders.gl/loader-utils": "4.0.0-beta.
|
|
45
|
-
"@loaders.gl/schema": "4.0.0-beta.
|
|
43
|
+
"@loaders.gl/gis": "4.0.0-beta.7",
|
|
44
|
+
"@loaders.gl/loader-utils": "4.0.0-beta.7",
|
|
45
|
+
"@loaders.gl/schema": "4.0.0-beta.7",
|
|
46
46
|
"@tmcw/togeojson": "^4.5.0",
|
|
47
47
|
"@xmldom/xmldom": "^0.7.13"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "5b6cab0ab5d73212cfa37fa5da6e25ad7ef83fe5"
|
|
50
50
|
}
|
package/src/gpx-loader.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
2
2
|
import {geojsonToBinary} from '@loaders.gl/gis';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
GeoJSONTable,
|
|
5
|
+
FeatureCollection,
|
|
6
|
+
ObjectRowTable,
|
|
7
|
+
BinaryFeatureCollection
|
|
8
|
+
} from '@loaders.gl/schema';
|
|
4
9
|
import {gpx} from '@tmcw/togeojson';
|
|
5
10
|
import {DOMParser} from '@xmldom/xmldom';
|
|
6
11
|
|
|
@@ -10,13 +15,7 @@ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
|
10
15
|
|
|
11
16
|
export type GPXLoaderOptions = LoaderOptions & {
|
|
12
17
|
gpx?: {
|
|
13
|
-
shape?: 'object-row-table' | 'geojson-table' | '
|
|
14
|
-
/** @deprecated. Use options.gpx.shape */
|
|
15
|
-
type?: 'object-row-table' | 'geojson-table' | 'geojson' | 'binary' | 'raw';
|
|
16
|
-
};
|
|
17
|
-
gis?: {
|
|
18
|
-
/** @deprecated. Use options.gpx.shape */
|
|
19
|
-
format?: 'object-row-table' | 'geojson-table' | 'geojson' | 'binary' | 'raw';
|
|
18
|
+
shape?: 'object-row-table' | 'geojson-table' | 'binary' | 'raw';
|
|
20
19
|
};
|
|
21
20
|
};
|
|
22
21
|
|
|
@@ -27,7 +26,11 @@ const GPX_HEADER = `\
|
|
|
27
26
|
/**
|
|
28
27
|
* Loader for GPX (GPS exchange format)
|
|
29
28
|
*/
|
|
30
|
-
export const GPXLoader: LoaderWithParser<
|
|
29
|
+
export const GPXLoader: LoaderWithParser<
|
|
30
|
+
ObjectRowTable | GeoJSONTable | BinaryFeatureCollection,
|
|
31
|
+
never,
|
|
32
|
+
GPXLoaderOptions
|
|
33
|
+
> = {
|
|
31
34
|
name: 'GPX (GPS exchange format)',
|
|
32
35
|
id: 'gpx',
|
|
33
36
|
module: 'kml',
|
|
@@ -45,11 +48,14 @@ export const GPXLoader: LoaderWithParser<any, never, GPXLoaderOptions> = {
|
|
|
45
48
|
}
|
|
46
49
|
};
|
|
47
50
|
|
|
48
|
-
function parseTextSync(
|
|
51
|
+
function parseTextSync(
|
|
52
|
+
text: string,
|
|
53
|
+
options?: GPXLoaderOptions
|
|
54
|
+
): ObjectRowTable | GeoJSONTable | BinaryFeatureCollection {
|
|
49
55
|
const doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
50
56
|
const geojson: FeatureCollection = gpx(doc);
|
|
51
57
|
|
|
52
|
-
const shape = options?.
|
|
58
|
+
const shape = options?.gpx?.shape;
|
|
53
59
|
|
|
54
60
|
switch (shape) {
|
|
55
61
|
case 'object-row-table': {
|
|
@@ -67,14 +73,10 @@ function parseTextSync(text: string, options?: GPXLoaderOptions) {
|
|
|
67
73
|
};
|
|
68
74
|
return table;
|
|
69
75
|
}
|
|
70
|
-
case 'geojson':
|
|
71
|
-
return geojson;
|
|
72
76
|
case 'binary':
|
|
73
77
|
return geojsonToBinary(geojson.features);
|
|
74
|
-
|
|
75
|
-
return doc;
|
|
78
|
+
|
|
76
79
|
default:
|
|
77
|
-
|
|
78
|
-
return geojson;
|
|
80
|
+
throw new Error(shape);
|
|
79
81
|
}
|
|
80
82
|
}
|
package/src/kml-loader.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
2
2
|
// import {geojsonToBinary} from '@loaders.gl/gis';
|
|
3
3
|
// import {GeoJSONTable} from '@loaders.gl/schema';
|
|
4
|
-
import {FeatureCollection, ObjectRowTable} from '@loaders.gl/schema';
|
|
4
|
+
import {FeatureCollection, GeoJSONTable, ObjectRowTable} from '@loaders.gl/schema';
|
|
5
5
|
import {kml} from '@tmcw/togeojson';
|
|
6
6
|
import {DOMParser} from '@xmldom/xmldom';
|
|
7
7
|
|
|
@@ -11,13 +11,7 @@ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
|
11
11
|
|
|
12
12
|
export type KMLLoaderOptions = LoaderOptions & {
|
|
13
13
|
kml?: {
|
|
14
|
-
shape?: 'object-row-table' | 'geojson-table';
|
|
15
|
-
/** @deprecated. Use options.kml.shape */
|
|
16
|
-
type?: 'object-row-table' | 'geojson-table';
|
|
17
|
-
};
|
|
18
|
-
gis?: {
|
|
19
|
-
/** @deprecated. Use options.kml.shape */
|
|
20
|
-
format?: 'object-row-table' | 'geojson-table' | 'geojson' | 'binary' | 'raw';
|
|
14
|
+
shape?: 'object-row-table' | 'geojson-table' | 'binary' | 'raw';
|
|
21
15
|
};
|
|
22
16
|
};
|
|
23
17
|
|
|
@@ -28,7 +22,7 @@ const KML_HEADER = `\
|
|
|
28
22
|
/**
|
|
29
23
|
* Loader for KML (Keyhole Markup Language)
|
|
30
24
|
*/
|
|
31
|
-
export const KMLLoader: LoaderWithParser<ObjectRowTable, never, KMLLoaderOptions> = {
|
|
25
|
+
export const KMLLoader: LoaderWithParser<ObjectRowTable | GeoJSONTable, never, KMLLoaderOptions> = {
|
|
32
26
|
name: 'KML (Keyhole Markup Language)',
|
|
33
27
|
id: 'kml',
|
|
34
28
|
module: 'kml',
|
|
@@ -41,25 +35,26 @@ export const KMLLoader: LoaderWithParser<ObjectRowTable, never, KMLLoaderOptions
|
|
|
41
35
|
parseTextSync(new TextDecoder().decode(arrayBuffer), options),
|
|
42
36
|
parseTextSync,
|
|
43
37
|
options: {
|
|
44
|
-
kml: {},
|
|
38
|
+
kml: {shape: 'geojson-table'},
|
|
45
39
|
gis: {}
|
|
46
40
|
}
|
|
47
41
|
};
|
|
48
42
|
|
|
49
|
-
function parseTextSync(text: string, options?: KMLLoaderOptions): ObjectRowTable {
|
|
43
|
+
function parseTextSync(text: string, options?: KMLLoaderOptions): ObjectRowTable | GeoJSONTable {
|
|
50
44
|
const doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
51
45
|
const geojson: FeatureCollection = kml(doc);
|
|
52
46
|
|
|
53
47
|
// backwards compatibility
|
|
54
|
-
const shape = options?.
|
|
48
|
+
const shape = options?.kml?.shape || KMLLoader.options.kml?.shape;
|
|
55
49
|
switch (shape) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
50
|
+
case 'geojson-table': {
|
|
51
|
+
const table: GeoJSONTable = {
|
|
52
|
+
shape: 'geojson-table',
|
|
53
|
+
type: 'FeatureCollection',
|
|
54
|
+
features: geojson.features
|
|
55
|
+
};
|
|
56
|
+
return table;
|
|
57
|
+
}
|
|
63
58
|
// case 'geojson':
|
|
64
59
|
// return geojson;
|
|
65
60
|
// case 'binary':
|
|
@@ -67,11 +62,12 @@ function parseTextSync(text: string, options?: KMLLoaderOptions): ObjectRowTable
|
|
|
67
62
|
// case 'raw':
|
|
68
63
|
// return doc;
|
|
69
64
|
case 'object-row-table':
|
|
70
|
-
default:
|
|
71
65
|
const table: ObjectRowTable = {
|
|
72
66
|
shape: 'object-row-table',
|
|
73
67
|
data: geojson.features
|
|
74
68
|
};
|
|
75
69
|
return table;
|
|
70
|
+
default:
|
|
71
|
+
throw new Error(shape);
|
|
76
72
|
}
|
|
77
73
|
}
|
package/src/tcx-loader.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
2
2
|
import {geojsonToBinary} from '@loaders.gl/gis';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
GeoJSONTable,
|
|
5
|
+
FeatureCollection,
|
|
6
|
+
ObjectRowTable,
|
|
7
|
+
BinaryFeatureCollection
|
|
8
|
+
} from '@loaders.gl/schema';
|
|
4
9
|
import {tcx} from '@tmcw/togeojson';
|
|
5
10
|
import {DOMParser} from '@xmldom/xmldom';
|
|
6
11
|
|
|
@@ -10,13 +15,7 @@ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
|
10
15
|
|
|
11
16
|
export type TCXLoaderOptions = LoaderOptions & {
|
|
12
17
|
tcx?: {
|
|
13
|
-
shape?: 'object-row-table' | 'geojson-table' | '
|
|
14
|
-
/** @deprecated. Use options.tcx.shape */
|
|
15
|
-
type?: 'object-row-table' | 'geojson-table' | 'geojson' | 'binary' | 'raw';
|
|
16
|
-
};
|
|
17
|
-
gis?: {
|
|
18
|
-
/** @deprecated. Use options.tcx.shape */
|
|
19
|
-
format?: 'object-row-table' | 'geojson-table' | 'geojson' | 'binary' | 'raw';
|
|
18
|
+
shape?: 'object-row-table' | 'geojson-table' | 'binary' | 'raw';
|
|
20
19
|
};
|
|
21
20
|
};
|
|
22
21
|
|
|
@@ -27,7 +26,11 @@ const TCX_HEADER = `\
|
|
|
27
26
|
/**
|
|
28
27
|
* Loader for TCX (Training Center XML) - Garmin GPS track format
|
|
29
28
|
*/
|
|
30
|
-
export const TCXLoader: LoaderWithParser<
|
|
29
|
+
export const TCXLoader: LoaderWithParser<
|
|
30
|
+
ObjectRowTable | GeoJSONTable | BinaryFeatureCollection,
|
|
31
|
+
never,
|
|
32
|
+
TCXLoaderOptions
|
|
33
|
+
> = {
|
|
31
34
|
name: 'TCX (Training Center XML)',
|
|
32
35
|
id: 'tcx',
|
|
33
36
|
module: 'kml',
|
|
@@ -45,12 +48,15 @@ export const TCXLoader: LoaderWithParser<any, never, TCXLoaderOptions> = {
|
|
|
45
48
|
}
|
|
46
49
|
};
|
|
47
50
|
|
|
48
|
-
function parseTextSync(
|
|
51
|
+
function parseTextSync(
|
|
52
|
+
text: string,
|
|
53
|
+
options?: TCXLoaderOptions
|
|
54
|
+
): ObjectRowTable | GeoJSONTable | BinaryFeatureCollection {
|
|
49
55
|
const doc = new DOMParser().parseFromString(text, 'text/xml');
|
|
50
56
|
const geojson: FeatureCollection = tcx(doc);
|
|
51
57
|
|
|
52
58
|
// backwards compatibility
|
|
53
|
-
const shape = options?.
|
|
59
|
+
const shape = options?.tcx?.shape;
|
|
54
60
|
|
|
55
61
|
switch (shape) {
|
|
56
62
|
case 'object-row-table': {
|
|
@@ -68,14 +74,10 @@ function parseTextSync(text: string, options?: TCXLoaderOptions) {
|
|
|
68
74
|
};
|
|
69
75
|
return table;
|
|
70
76
|
}
|
|
71
|
-
case 'geojson':
|
|
72
|
-
return geojson;
|
|
73
77
|
case 'binary':
|
|
74
78
|
return geojsonToBinary(geojson.features);
|
|
75
|
-
|
|
76
|
-
return doc;
|
|
79
|
+
|
|
77
80
|
default:
|
|
78
|
-
|
|
79
|
-
return geojson;
|
|
81
|
+
throw new Error(shape);
|
|
80
82
|
}
|
|
81
83
|
}
|