@loaders.gl/json 3.1.0-beta.5 → 3.1.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/bundle.js CHANGED
@@ -1431,7 +1431,7 @@ Char: ${this.c}`;
1431
1431
  let polygonRingsCount = 0;
1432
1432
  let polygonFeaturesCount = 0;
1433
1433
  const coordLengths = new Set();
1434
- const numericPropKeys = {};
1434
+ const propArrayTypes = {};
1435
1435
  for (const feature of features) {
1436
1436
  const geometry = feature.geometry;
1437
1437
  switch (geometry.type) {
@@ -1491,7 +1491,7 @@ Char: ${this.c}`;
1491
1491
  if (feature.properties) {
1492
1492
  for (const key in feature.properties) {
1493
1493
  const val = feature.properties[key];
1494
- numericPropKeys[key] = numericPropKeys[key] || numericPropKeys[key] === void 0 ? isNumeric(val) : numericPropKeys[key];
1494
+ propArrayTypes[key] = deduceArrayType(val, propArrayTypes[key]);
1495
1495
  }
1496
1496
  }
1497
1497
  }
@@ -1506,7 +1506,8 @@ Char: ${this.c}`;
1506
1506
  polygonObjectsCount,
1507
1507
  polygonRingsCount,
1508
1508
  polygonFeaturesCount,
1509
- numericPropKeys: Object.keys(numericPropKeys).filter((k) => numericPropKeys[k])
1509
+ numericPropKeys: Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array),
1510
+ propArrayTypes
1510
1511
  };
1511
1512
  }
1512
1513
  function secondPass(features, firstPassData, options) {
@@ -1519,6 +1520,7 @@ Char: ${this.c}`;
1519
1520
  polygonPositionsCount,
1520
1521
  polygonObjectsCount,
1521
1522
  polygonRingsCount,
1523
+ propArrayTypes,
1522
1524
  polygonFeaturesCount
1523
1525
  } = firstPassData;
1524
1526
  const { coordLength, numericPropKeys, PositionDataType = Float32Array } = options;
@@ -1552,7 +1554,8 @@ Char: ${this.c}`;
1552
1554
  };
1553
1555
  for (const object of [points, lines, polygons]) {
1554
1556
  for (const propName of numericPropKeys || []) {
1555
- object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);
1557
+ const TypedArray = propArrayTypes[propName];
1558
+ object.numericProps[propName] = new TypedArray(object.positions.length / coordLength);
1556
1559
  }
1557
1560
  }
1558
1561
  lines.pathIndices[linePathsCount] = linePositionsCount;
@@ -1720,8 +1723,11 @@ Char: ${this.c}`;
1720
1723
  function flatten(arrays) {
1721
1724
  return [].concat(...arrays);
1722
1725
  }
1723
- function isNumeric(x) {
1724
- return Number.isFinite(x);
1726
+ function deduceArrayType(x, constructor) {
1727
+ if (constructor === Array || !Number.isFinite(x)) {
1728
+ return Array;
1729
+ }
1730
+ return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;
1725
1731
  }
1726
1732
  var init_geojson_to_binary = __esm({
1727
1733
  "../gis/src/lib/geojson-to-binary.ts"() {
@@ -13,7 +13,7 @@ var _parseJson = _interopRequireDefault(require("./lib/parse-json"));
13
13
 
14
14
  var _parseJsonInBatches = _interopRequireDefault(require("./lib/parse-json-in-batches"));
15
15
 
16
- const VERSION = typeof "3.1.0-beta.5" !== 'undefined' ? "3.1.0-beta.5" : 'latest';
16
+ const VERSION = typeof "3.1.0-beta.7" !== 'undefined' ? "3.1.0-beta.7" : 'latest';
17
17
  const DEFAULT_GEOJSON_LOADER_OPTIONS = {
18
18
  geojson: {
19
19
  shape: 'object-row-table'
@@ -11,7 +11,7 @@ var _parseJson = _interopRequireDefault(require("./lib/parse-json"));
11
11
 
12
12
  var _parseJsonInBatches = _interopRequireDefault(require("./lib/parse-json-in-batches"));
13
13
 
14
- const VERSION = typeof "3.1.0-beta.5" !== 'undefined' ? "3.1.0-beta.5" : 'latest';
14
+ const VERSION = typeof "3.1.0-beta.7" !== 'undefined' ? "3.1.0-beta.7" : 'latest';
15
15
  const DEFAULT_JSON_LOADER_OPTIONS = {
16
16
  json: {
17
17
  shape: 'row-table',
@@ -11,7 +11,7 @@ var _parseNdjson = _interopRequireDefault(require("./lib/parse-ndjson"));
11
11
 
12
12
  var _parseNdjsonInBatches = _interopRequireDefault(require("./lib/parse-ndjson-in-batches"));
13
13
 
14
- const VERSION = typeof "3.1.0-beta.5" !== 'undefined' ? "3.1.0-beta.5" : 'latest';
14
+ const VERSION = typeof "3.1.0-beta.7" !== 'undefined' ? "3.1.0-beta.7" : 'latest';
15
15
  const NDJSONLoader = {
16
16
  name: 'NDJSON',
17
17
  id: 'ndjson',
@@ -1,7 +1,7 @@
1
1
  import { geojsonToBinary } from '@loaders.gl/gis';
2
2
  import parseJSONSync from './lib/parse-json';
3
3
  import parseJSONInBatches from './lib/parse-json-in-batches';
4
- const VERSION = typeof "3.1.0-beta.5" !== 'undefined' ? "3.1.0-beta.5" : 'latest';
4
+ const VERSION = typeof "3.1.0-beta.7" !== 'undefined' ? "3.1.0-beta.7" : 'latest';
5
5
  const DEFAULT_GEOJSON_LOADER_OPTIONS = {
6
6
  geojson: {
7
7
  shape: 'object-row-table'
@@ -1,6 +1,6 @@
1
1
  import parseJSONSync from './lib/parse-json';
2
2
  import parseJSONInBatches from './lib/parse-json-in-batches';
3
- const VERSION = typeof "3.1.0-beta.5" !== 'undefined' ? "3.1.0-beta.5" : 'latest';
3
+ const VERSION = typeof "3.1.0-beta.7" !== 'undefined' ? "3.1.0-beta.7" : 'latest';
4
4
  const DEFAULT_JSON_LOADER_OPTIONS = {
5
5
  json: {
6
6
  shape: 'row-table',
@@ -1,6 +1,6 @@
1
1
  import parseNDJSONSync from './lib/parse-ndjson';
2
2
  import parseNDJSONInBatches from './lib/parse-ndjson-in-batches';
3
- const VERSION = typeof "3.1.0-beta.5" !== 'undefined' ? "3.1.0-beta.5" : 'latest';
3
+ const VERSION = typeof "3.1.0-beta.7" !== 'undefined' ? "3.1.0-beta.7" : 'latest';
4
4
  export const NDJSONLoader = {
5
5
  name: 'NDJSON',
6
6
  id: 'ndjson',
@@ -179,7 +179,7 @@
179
179
  let polygonRingsCount = 0;
180
180
  let polygonFeaturesCount = 0;
181
181
  const coordLengths = new Set();
182
- const numericPropKeys = {};
182
+ const propArrayTypes = {};
183
183
  for (const feature of features) {
184
184
  const geometry = feature.geometry;
185
185
  switch (geometry.type) {
@@ -239,7 +239,7 @@
239
239
  if (feature.properties) {
240
240
  for (const key in feature.properties) {
241
241
  const val = feature.properties[key];
242
- numericPropKeys[key] = numericPropKeys[key] || numericPropKeys[key] === void 0 ? isNumeric(val) : numericPropKeys[key];
242
+ propArrayTypes[key] = deduceArrayType(val, propArrayTypes[key]);
243
243
  }
244
244
  }
245
245
  }
@@ -254,7 +254,8 @@
254
254
  polygonObjectsCount,
255
255
  polygonRingsCount,
256
256
  polygonFeaturesCount,
257
- numericPropKeys: Object.keys(numericPropKeys).filter((k) => numericPropKeys[k])
257
+ numericPropKeys: Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array),
258
+ propArrayTypes
258
259
  };
259
260
  }
260
261
  function secondPass(features, firstPassData, options) {
@@ -267,6 +268,7 @@
267
268
  polygonPositionsCount,
268
269
  polygonObjectsCount,
269
270
  polygonRingsCount,
271
+ propArrayTypes,
270
272
  polygonFeaturesCount
271
273
  } = firstPassData;
272
274
  const { coordLength, numericPropKeys, PositionDataType = Float32Array } = options;
@@ -300,7 +302,8 @@
300
302
  };
301
303
  for (const object of [points, lines, polygons]) {
302
304
  for (const propName of numericPropKeys || []) {
303
- object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);
305
+ const TypedArray = propArrayTypes[propName];
306
+ object.numericProps[propName] = new TypedArray(object.positions.length / coordLength);
304
307
  }
305
308
  }
306
309
  lines.pathIndices[linePathsCount] = linePositionsCount;
@@ -468,8 +471,11 @@
468
471
  function flatten(arrays) {
469
472
  return [].concat(...arrays);
470
473
  }
471
- function isNumeric(x) {
472
- return Number.isFinite(x);
474
+ function deduceArrayType(x, constructor) {
475
+ if (constructor === Array || !Number.isFinite(x)) {
476
+ return Array;
477
+ }
478
+ return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;
473
479
  }
474
480
 
475
481
  // src/lib/parse-json.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/json",
3
- "version": "3.1.0-beta.5",
3
+ "version": "3.1.0-beta.7",
4
4
  "description": "Framework-independent loader for JSON and streaming JSON formats",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -35,9 +35,9 @@
35
35
  "build-worker": "esbuild src/workers/geojson-worker.ts --bundle --outfile=dist/geojson-worker.js"
36
36
  },
37
37
  "dependencies": {
38
- "@loaders.gl/gis": "3.1.0-beta.5",
39
- "@loaders.gl/loader-utils": "3.1.0-beta.5",
40
- "@loaders.gl/schema": "3.1.0-beta.5"
38
+ "@loaders.gl/gis": "3.1.0-beta.7",
39
+ "@loaders.gl/loader-utils": "3.1.0-beta.7",
40
+ "@loaders.gl/schema": "3.1.0-beta.7"
41
41
  },
42
- "gitHead": "5d66468457cc878d2dbff3d7807d737ceb181c9a"
42
+ "gitHead": "f3b4d81ac02758398c4e4eef5e556b206ef2dfbe"
43
43
  }