@loaders.gl/kml 4.2.0-alpha.3 → 4.2.0-alpha.5

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
@@ -2,8 +2,8 @@
2
2
  if (typeof exports === 'object' && typeof module === 'object')
3
3
  module.exports = factory();
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
- else if (typeof exports === 'object') exports['loader'] = factory();
6
- else root['loader'] = factory();})(globalThis, function () {
5
+ else if (typeof exports === 'object') exports['loaders'] = factory();
6
+ else root['loaders'] = factory();})(globalThis, function () {
7
7
  "use strict";
8
8
  var __exports__ = (() => {
9
9
  var __create = Object.create;
@@ -27,6 +27,7 @@ var __exports__ = (() => {
27
27
  }
28
28
  return to;
29
29
  };
30
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
30
31
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
31
32
  // If the importer is in node compatibility mode or this is not an ESM
32
33
  // file that has been converted to a CommonJS file using a Babel-
@@ -37,6 +38,13 @@ var __exports__ = (() => {
37
38
  ));
38
39
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
40
 
41
+ // external-global-plugin:@loaders.gl/core
42
+ var require_core = __commonJS({
43
+ "external-global-plugin:@loaders.gl/core"(exports, module) {
44
+ module.exports = globalThis.loaders;
45
+ }
46
+ });
47
+
40
48
  // ../../node_modules/@xmldom/xmldom/lib/conventions.js
41
49
  var require_conventions = __commonJS({
42
50
  "../../node_modules/@xmldom/xmldom/lib/conventions.js"(exports) {
@@ -4511,13 +4519,14 @@ var __exports__ = (() => {
4511
4519
  }
4512
4520
  });
4513
4521
 
4514
- // src/index.ts
4515
- var src_exports = {};
4516
- __export(src_exports, {
4522
+ // bundle.ts
4523
+ var bundle_exports = {};
4524
+ __export(bundle_exports, {
4517
4525
  GPXLoader: () => GPXLoader,
4518
4526
  KMLLoader: () => KMLLoader,
4519
4527
  TCXLoader: () => TCXLoader
4520
4528
  });
4529
+ __reExport(bundle_exports, __toESM(require_core(), 1));
4521
4530
 
4522
4531
  // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
4523
4532
  function _typeof(obj) {
@@ -5082,14 +5091,18 @@ var __exports__ = (() => {
5082
5091
  function flatGeojsonToBinary(features, geometryInfo, options) {
5083
5092
  const propArrayTypes = extractNumericPropTypes(features);
5084
5093
  const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);
5085
- return fillArrays(features, {
5086
- propArrayTypes,
5087
- ...geometryInfo
5088
- }, {
5089
- numericPropKeys: options && options.numericPropKeys || numericPropKeys,
5090
- PositionDataType: options ? options.PositionDataType : Float32Array,
5091
- triangulate: options ? options.triangulate : true
5092
- });
5094
+ return fillArrays(
5095
+ features,
5096
+ {
5097
+ propArrayTypes,
5098
+ ...geometryInfo
5099
+ },
5100
+ {
5101
+ numericPropKeys: options && options.numericPropKeys || numericPropKeys,
5102
+ PositionDataType: options ? options.PositionDataType : Float32Array,
5103
+ triangulate: options ? options.triangulate : true
5104
+ }
5105
+ );
5093
5106
  }
5094
5107
  function extractNumericPropTypes(features) {
5095
5108
  const propArrayTypes = {};
@@ -5117,11 +5130,7 @@ var __exports__ = (() => {
5117
5130
  propArrayTypes,
5118
5131
  coordLength
5119
5132
  } = geometryInfo;
5120
- const {
5121
- numericPropKeys = [],
5122
- PositionDataType = Float32Array,
5123
- triangulate = true
5124
- } = options;
5133
+ const { numericPropKeys = [], PositionDataType = Float32Array, triangulate = true } = options;
5125
5134
  const hasGlobalId = features[0] && "id" in features[0];
5126
5135
  const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
5127
5136
  const points = {
@@ -5186,9 +5195,7 @@ var __exports__ = (() => {
5186
5195
  handlePoint(geometry, points, indexMap, coordLength, properties);
5187
5196
  points.properties.push(keepStringProperties(properties, numericPropKeys));
5188
5197
  if (hasGlobalId) {
5189
- points.fields.push({
5190
- id: feature.id
5191
- });
5198
+ points.fields.push({ id: feature.id });
5192
5199
  }
5193
5200
  indexMap.pointFeature++;
5194
5201
  break;
@@ -5196,9 +5203,7 @@ var __exports__ = (() => {
5196
5203
  handleLineString(geometry, lines, indexMap, coordLength, properties);
5197
5204
  lines.properties.push(keepStringProperties(properties, numericPropKeys));
5198
5205
  if (hasGlobalId) {
5199
- lines.fields.push({
5200
- id: feature.id
5201
- });
5206
+ lines.fields.push({ id: feature.id });
5202
5207
  }
5203
5208
  indexMap.lineFeature++;
5204
5209
  break;
@@ -5206,9 +5211,7 @@ var __exports__ = (() => {
5206
5211
  handlePolygon(geometry, polygons, indexMap, coordLength, properties);
5207
5212
  polygons.properties.push(keepStringProperties(properties, numericPropKeys));
5208
5213
  if (hasGlobalId) {
5209
- polygons.fields.push({
5210
- id: feature.id
5211
- });
5214
+ polygons.fields.push({ id: feature.id });
5212
5215
  }
5213
5216
  indexMap.polygonFeature++;
5214
5217
  break;
@@ -5223,16 +5226,32 @@ var __exports__ = (() => {
5223
5226
  points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
5224
5227
  const nPositions = geometry.data.length / coordLength;
5225
5228
  fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);
5226
- points.globalFeatureIds.fill(indexMap.feature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
5227
- points.featureIds.fill(indexMap.pointFeature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
5229
+ points.globalFeatureIds.fill(
5230
+ indexMap.feature,
5231
+ indexMap.pointPosition,
5232
+ indexMap.pointPosition + nPositions
5233
+ );
5234
+ points.featureIds.fill(
5235
+ indexMap.pointFeature,
5236
+ indexMap.pointPosition,
5237
+ indexMap.pointPosition + nPositions
5238
+ );
5228
5239
  indexMap.pointPosition += nPositions;
5229
5240
  }
5230
5241
  function handleLineString(geometry, lines, indexMap, coordLength, properties) {
5231
5242
  lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
5232
5243
  const nPositions = geometry.data.length / coordLength;
5233
5244
  fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
5234
- lines.globalFeatureIds.fill(indexMap.feature, indexMap.linePosition, indexMap.linePosition + nPositions);
5235
- lines.featureIds.fill(indexMap.lineFeature, indexMap.linePosition, indexMap.linePosition + nPositions);
5245
+ lines.globalFeatureIds.fill(
5246
+ indexMap.feature,
5247
+ indexMap.linePosition,
5248
+ indexMap.linePosition + nPositions
5249
+ );
5250
+ lines.featureIds.fill(
5251
+ indexMap.lineFeature,
5252
+ indexMap.linePosition,
5253
+ indexMap.linePosition + nPositions
5254
+ );
5236
5255
  for (let i = 0, il = geometry.indices.length; i < il; ++i) {
5237
5256
  const start = geometry.indices[i];
5238
5257
  const end = i === il - 1 ? geometry.data.length : geometry.indices[i + 1];
@@ -5244,8 +5263,16 @@ var __exports__ = (() => {
5244
5263
  polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
5245
5264
  const nPositions = geometry.data.length / coordLength;
5246
5265
  fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
5247
- polygons.globalFeatureIds.fill(indexMap.feature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
5248
- polygons.featureIds.fill(indexMap.polygonFeature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
5266
+ polygons.globalFeatureIds.fill(
5267
+ indexMap.feature,
5268
+ indexMap.polygonPosition,
5269
+ indexMap.polygonPosition + nPositions
5270
+ );
5271
+ polygons.featureIds.fill(
5272
+ indexMap.polygonFeature,
5273
+ indexMap.polygonPosition,
5274
+ indexMap.polygonPosition + nPositions
5275
+ );
5249
5276
  for (let l = 0, ll = geometry.indices.length; l < ll; ++l) {
5250
5277
  const startPosition = indexMap.polygonPosition;
5251
5278
  polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
@@ -5254,16 +5281,15 @@ var __exports__ = (() => {
5254
5281
  const nextIndices = geometry.indices[l + 1];
5255
5282
  for (let i = 0, il = indices.length; i < il; ++i) {
5256
5283
  const start = indices[i];
5257
- const end = i === il - 1 ? nextIndices === void 0 ? geometry.data.length : nextIndices[0] : indices[i + 1];
5284
+ const end = i === il - 1 ? (
5285
+ // last line, so either read to:
5286
+ nextIndices === void 0 ? geometry.data.length : nextIndices[0]
5287
+ ) : indices[i + 1];
5258
5288
  polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
5259
5289
  indexMap.polygonPosition += (end - start) / coordLength;
5260
5290
  }
5261
5291
  const endPosition = indexMap.polygonPosition;
5262
- triangulatePolygon(polygons, areas, indices, {
5263
- startPosition,
5264
- endPosition,
5265
- coordLength
5266
- });
5292
+ triangulatePolygon(polygons, areas, indices, { startPosition, endPosition, coordLength });
5267
5293
  }
5268
5294
  }
5269
5295
  function triangulatePolygon(polygons, areas, indices, {
@@ -5287,10 +5313,7 @@ var __exports__ = (() => {
5287
5313
  function wrapProps(obj, size) {
5288
5314
  const returnObj = {};
5289
5315
  for (const key in obj) {
5290
- returnObj[key] = {
5291
- value: obj[key],
5292
- size
5293
- };
5316
+ returnObj[key] = { value: obj[key], size };
5294
5317
  }
5295
5318
  return returnObj;
5296
5319
  }
@@ -5299,70 +5322,32 @@ var __exports__ = (() => {
5299
5322
  shape: "binary-feature-collection",
5300
5323
  points: {
5301
5324
  ...points,
5302
- positions: {
5303
- value: points.positions,
5304
- size: coordLength
5305
- },
5306
- globalFeatureIds: {
5307
- value: points.globalFeatureIds,
5308
- size: 1
5309
- },
5310
- featureIds: {
5311
- value: points.featureIds,
5312
- size: 1
5313
- },
5325
+ positions: { value: points.positions, size: coordLength },
5326
+ globalFeatureIds: { value: points.globalFeatureIds, size: 1 },
5327
+ featureIds: { value: points.featureIds, size: 1 },
5314
5328
  numericProps: wrapProps(points.numericProps, 1)
5315
5329
  },
5316
5330
  lines: {
5317
5331
  ...lines,
5318
- positions: {
5319
- value: lines.positions,
5320
- size: coordLength
5321
- },
5322
- pathIndices: {
5323
- value: lines.pathIndices,
5324
- size: 1
5325
- },
5326
- globalFeatureIds: {
5327
- value: lines.globalFeatureIds,
5328
- size: 1
5329
- },
5330
- featureIds: {
5331
- value: lines.featureIds,
5332
- size: 1
5333
- },
5332
+ positions: { value: lines.positions, size: coordLength },
5333
+ pathIndices: { value: lines.pathIndices, size: 1 },
5334
+ globalFeatureIds: { value: lines.globalFeatureIds, size: 1 },
5335
+ featureIds: { value: lines.featureIds, size: 1 },
5334
5336
  numericProps: wrapProps(lines.numericProps, 1)
5335
5337
  },
5336
5338
  polygons: {
5337
5339
  ...polygons,
5338
- positions: {
5339
- value: polygons.positions,
5340
- size: coordLength
5341
- },
5342
- polygonIndices: {
5343
- value: polygons.polygonIndices,
5344
- size: 1
5345
- },
5346
- primitivePolygonIndices: {
5347
- value: polygons.primitivePolygonIndices,
5348
- size: 1
5349
- },
5350
- globalFeatureIds: {
5351
- value: polygons.globalFeatureIds,
5352
- size: 1
5353
- },
5354
- featureIds: {
5355
- value: polygons.featureIds,
5356
- size: 1
5357
- },
5340
+ positions: { value: polygons.positions, size: coordLength },
5341
+ polygonIndices: { value: polygons.polygonIndices, size: 1 },
5342
+ primitivePolygonIndices: { value: polygons.primitivePolygonIndices, size: 1 },
5343
+ globalFeatureIds: { value: polygons.globalFeatureIds, size: 1 },
5344
+ featureIds: { value: polygons.featureIds, size: 1 },
5358
5345
  numericProps: wrapProps(polygons.numericProps, 1)
5359
5346
  }
5347
+ // triangles not expected
5360
5348
  };
5361
5349
  if (binaryFeatures.polygons && polygons.triangles) {
5362
- binaryFeatures.polygons.triangles = {
5363
- value: new Uint32Array(polygons.triangles),
5364
- size: 1
5365
- };
5350
+ binaryFeatures.polygons.triangles = { value: new Uint32Array(polygons.triangles), size: 1 };
5366
5351
  }
5367
5352
  return binaryFeatures;
5368
5353
  }
@@ -5476,10 +5461,7 @@ var __exports__ = (() => {
5476
5461
  }
5477
5462
 
5478
5463
  // ../gis/src/lib/binary-features/geojson-to-flat-geojson.ts
5479
- function geojsonToFlatGeojson(features, options = {
5480
- coordLength: 2,
5481
- fixRingWinding: true
5482
- }) {
5464
+ function geojsonToFlatGeojson(features, options = { coordLength: 2, fixRingWinding: true }) {
5483
5465
  return features.map((feature) => flattenFeature(feature, options));
5484
5466
  }
5485
5467
  function flattenPoint(coordinates, data, indices, options) {
@@ -5520,9 +5502,7 @@ var __exports__ = (() => {
5520
5502
  }
5521
5503
  }
5522
5504
  function flattenFeature(feature, options) {
5523
- const {
5524
- geometry
5525
- } = feature;
5505
+ const { geometry } = feature;
5526
5506
  if (geometry.type === "GeometryCollection") {
5527
5507
  throw new Error("GeometryCollection type not supported");
5528
5508
  }
@@ -5560,31 +5540,15 @@ var __exports__ = (() => {
5560
5540
  default:
5561
5541
  throw new Error(`Unknown type: ${type}`);
5562
5542
  }
5563
- return {
5564
- ...feature,
5565
- geometry: {
5566
- type,
5567
- indices,
5568
- data,
5569
- areas
5570
- }
5571
- };
5543
+ return { ...feature, geometry: { type, indices, data, areas } };
5572
5544
  }
5573
5545
 
5574
5546
  // ../gis/src/lib/binary-features/geojson-to-binary.ts
5575
- function geojsonToBinary(features, options = {
5576
- fixRingWinding: true,
5577
- triangulate: true
5578
- }) {
5547
+ function geojsonToBinary(features, options = { fixRingWinding: true, triangulate: true }) {
5579
5548
  const geometryInfo = extractGeometryInfo(features);
5580
5549
  const coordLength = geometryInfo.coordLength;
5581
- const {
5582
- fixRingWinding
5583
- } = options;
5584
- const flatFeatures = geojsonToFlatGeojson(features, {
5585
- coordLength,
5586
- fixRingWinding
5587
- });
5550
+ const { fixRingWinding } = options;
5551
+ const flatFeatures = geojsonToFlatGeojson(features, { coordLength, fixRingWinding });
5588
5552
  return flatGeojsonToBinary(flatFeatures, geometryInfo, {
5589
5553
  numericPropKeys: options.numericPropKeys,
5590
5554
  PositionDataType: options.PositionDataType || Float32Array,
@@ -6313,7 +6277,7 @@ var __exports__ = (() => {
6313
6277
 
6314
6278
  // src/gpx-loader.ts
6315
6279
  var import_xmldom = __toESM(require_lib(), 1);
6316
- var VERSION = true ? "4.2.0-alpha.3" : "latest";
6280
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
6317
6281
  var GPX_HEADER = `<?xml version="1.0" encoding="UTF-8"?>
6318
6282
  <gpx`;
6319
6283
  var GPXLoader = {
@@ -6328,19 +6292,14 @@ var __exports__ = (() => {
6328
6292
  parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
6329
6293
  parseTextSync,
6330
6294
  options: {
6331
- gpx: {
6332
- shape: "geojson-table"
6333
- },
6295
+ gpx: { shape: "geojson-table" },
6334
6296
  gis: {}
6335
6297
  }
6336
6298
  };
6337
6299
  function parseTextSync(text, options) {
6338
6300
  const doc = new import_xmldom.DOMParser().parseFromString(text, "text/xml");
6339
6301
  const geojson = gpx(doc);
6340
- const gpxOptions = {
6341
- ...GPXLoader.options.gpx,
6342
- ...options?.gpx
6343
- };
6302
+ const gpxOptions = { ...GPXLoader.options.gpx, ...options?.gpx };
6344
6303
  switch (gpxOptions.shape) {
6345
6304
  case "object-row-table": {
6346
6305
  const table = {
@@ -6366,7 +6325,7 @@ var __exports__ = (() => {
6366
6325
 
6367
6326
  // src/kml-loader.ts
6368
6327
  var import_xmldom2 = __toESM(require_lib(), 1);
6369
- var VERSION2 = true ? "4.2.0-alpha.3" : "latest";
6328
+ var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
6370
6329
  var KML_HEADER = `<?xml version="1.0" encoding="UTF-8"?>
6371
6330
  <kml xmlns="http://www.opengis.net/kml/2.2">`;
6372
6331
  var KMLLoader = {
@@ -6381,19 +6340,14 @@ var __exports__ = (() => {
6381
6340
  parse: async (arrayBuffer, options) => parseTextSync2(new TextDecoder().decode(arrayBuffer), options),
6382
6341
  parseTextSync: parseTextSync2,
6383
6342
  options: {
6384
- kml: {
6385
- shape: "geojson-table"
6386
- },
6343
+ kml: { shape: "geojson-table" },
6387
6344
  gis: {}
6388
6345
  }
6389
6346
  };
6390
6347
  function parseTextSync2(text, options) {
6391
6348
  const doc = new import_xmldom2.DOMParser().parseFromString(text, "text/xml");
6392
6349
  const geojson = kml(doc);
6393
- const kmlOptions = {
6394
- ...KMLLoader.options.kml,
6395
- ...options?.kml
6396
- };
6350
+ const kmlOptions = { ...KMLLoader.options.kml, ...options?.kml };
6397
6351
  switch (kmlOptions.shape) {
6398
6352
  case "geojson-table": {
6399
6353
  const table2 = {
@@ -6416,7 +6370,7 @@ var __exports__ = (() => {
6416
6370
 
6417
6371
  // src/tcx-loader.ts
6418
6372
  var import_xmldom3 = __toESM(require_lib(), 1);
6419
- var VERSION3 = true ? "4.2.0-alpha.3" : "latest";
6373
+ var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
6420
6374
  var TCX_HEADER = `<?xml version="1.0" encoding="UTF-8"?>
6421
6375
  <TrainingCenterDatabase`;
6422
6376
  var TCXLoader = {
@@ -6431,19 +6385,14 @@ var __exports__ = (() => {
6431
6385
  parse: async (arrayBuffer, options) => parseTextSync3(new TextDecoder().decode(arrayBuffer), options),
6432
6386
  parseTextSync: parseTextSync3,
6433
6387
  options: {
6434
- tcx: {
6435
- shape: "geojson-table"
6436
- },
6388
+ tcx: { shape: "geojson-table" },
6437
6389
  gis: {}
6438
6390
  }
6439
6391
  };
6440
6392
  function parseTextSync3(text, options) {
6441
6393
  const doc = new import_xmldom3.DOMParser().parseFromString(text, "text/xml");
6442
6394
  const geojson = tcx(doc);
6443
- const tcxOptions = {
6444
- ...TCXLoader.options.tcx,
6445
- ...options?.tcx
6446
- };
6395
+ const tcxOptions = { ...TCXLoader.options.tcx, ...options?.tcx };
6447
6396
  switch (tcxOptions.shape) {
6448
6397
  case "object-row-table": {
6449
6398
  const table = {
@@ -6456,10 +6405,7 @@ var __exports__ = (() => {
6456
6405
  const table = {
6457
6406
  shape: "geojson-table",
6458
6407
  type: "FeatureCollection",
6459
- schema: {
6460
- metadata: {},
6461
- fields: []
6462
- },
6408
+ schema: { metadata: {}, fields: [] },
6463
6409
  features: geojson.features
6464
6410
  };
6465
6411
  return table;
@@ -6470,7 +6416,7 @@ var __exports__ = (() => {
6470
6416
  throw new Error(tcxOptions.shape);
6471
6417
  }
6472
6418
  }
6473
- return __toCommonJS(src_exports);
6419
+ return __toCommonJS(bundle_exports);
6474
6420
  })();
6475
6421
  return __exports__;
6476
6422
  });