@loaders.gl/json 4.0.0-alpha.16 → 4.0.0-alpha.18
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 +17 -7
- package/dist/es5/geojson-loader.js +1 -1
- package/dist/es5/json-loader.js +1 -1
- package/dist/es5/ndgeoson-loader.js +1 -1
- package/dist/es5/ndjson-loader.js +1 -1
- package/dist/esm/geojson-loader.js +1 -1
- package/dist/esm/json-loader.js +1 -1
- package/dist/esm/ndgeoson-loader.js +1 -1
- package/dist/esm/ndjson-loader.js +1 -1
- package/dist/geojson-worker.js +18 -8
- package/package.json +5 -5
package/dist/dist.min.js
CHANGED
|
@@ -2371,7 +2371,8 @@ Char: ${this.c}`;
|
|
|
2371
2371
|
...geometryInfo
|
|
2372
2372
|
}, {
|
|
2373
2373
|
numericPropKeys: options && options.numericPropKeys || numericPropKeys,
|
|
2374
|
-
PositionDataType: options ? options.PositionDataType : Float32Array
|
|
2374
|
+
PositionDataType: options ? options.PositionDataType : Float32Array,
|
|
2375
|
+
triangulate: options ? options.triangulate : true
|
|
2375
2376
|
});
|
|
2376
2377
|
}
|
|
2377
2378
|
function extractNumericPropTypes(features) {
|
|
@@ -2400,7 +2401,7 @@ Char: ${this.c}`;
|
|
|
2400
2401
|
propArrayTypes,
|
|
2401
2402
|
coordLength
|
|
2402
2403
|
} = geometryInfo;
|
|
2403
|
-
const { numericPropKeys = [], PositionDataType = Float32Array } = options;
|
|
2404
|
+
const { numericPropKeys = [], PositionDataType = Float32Array, triangulate = true } = options;
|
|
2404
2405
|
const hasGlobalId = features[0] && "id" in features[0];
|
|
2405
2406
|
const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
|
|
2406
2407
|
const points = {
|
|
@@ -2427,13 +2428,15 @@ Char: ${this.c}`;
|
|
|
2427
2428
|
polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
|
|
2428
2429
|
primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
|
|
2429
2430
|
positions: new PositionDataType(polygonPositionsCount * coordLength),
|
|
2430
|
-
triangles: [],
|
|
2431
2431
|
globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),
|
|
2432
2432
|
featureIds: polygonFeaturesCount > 65535 ? new Uint32Array(polygonPositionsCount) : new Uint16Array(polygonPositionsCount),
|
|
2433
2433
|
numericProps: {},
|
|
2434
2434
|
properties: [],
|
|
2435
2435
|
fields: []
|
|
2436
2436
|
};
|
|
2437
|
+
if (triangulate) {
|
|
2438
|
+
polygons.triangles = [];
|
|
2439
|
+
}
|
|
2437
2440
|
for (const object of [points, lines, polygons]) {
|
|
2438
2441
|
for (const propName of numericPropKeys) {
|
|
2439
2442
|
const T = propArrayTypes[propName];
|
|
@@ -2538,6 +2541,9 @@ Char: ${this.c}`;
|
|
|
2538
2541
|
endPosition,
|
|
2539
2542
|
coordLength
|
|
2540
2543
|
}) {
|
|
2544
|
+
if (!polygons.triangles) {
|
|
2545
|
+
return;
|
|
2546
|
+
}
|
|
2541
2547
|
const start = startPosition * coordLength;
|
|
2542
2548
|
const end = endPosition * coordLength;
|
|
2543
2549
|
const polygonPositions = polygons.positions.subarray(start, end);
|
|
@@ -2556,7 +2562,7 @@ Char: ${this.c}`;
|
|
|
2556
2562
|
return returnObj;
|
|
2557
2563
|
}
|
|
2558
2564
|
function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
2559
|
-
|
|
2565
|
+
const binaryFeatures = {
|
|
2560
2566
|
points: {
|
|
2561
2567
|
...points,
|
|
2562
2568
|
positions: { value: points.positions, size: coordLength },
|
|
@@ -2577,12 +2583,15 @@ Char: ${this.c}`;
|
|
|
2577
2583
|
positions: { value: polygons.positions, size: coordLength },
|
|
2578
2584
|
polygonIndices: { value: polygons.polygonIndices, size: 1 },
|
|
2579
2585
|
primitivePolygonIndices: { value: polygons.primitivePolygonIndices, size: 1 },
|
|
2580
|
-
triangles: { value: new Uint32Array(polygons.triangles), size: 1 },
|
|
2581
2586
|
globalFeatureIds: { value: polygons.globalFeatureIds, size: 1 },
|
|
2582
2587
|
featureIds: { value: polygons.featureIds, size: 1 },
|
|
2583
2588
|
numericProps: wrapProps(polygons.numericProps, 1)
|
|
2584
2589
|
}
|
|
2585
2590
|
};
|
|
2591
|
+
if (polygons.triangles) {
|
|
2592
|
+
binaryFeatures.polygons.triangles = { value: new Uint32Array(polygons.triangles), size: 1 };
|
|
2593
|
+
}
|
|
2594
|
+
return binaryFeatures;
|
|
2586
2595
|
}
|
|
2587
2596
|
function fillNumericProperties(object, properties, index, length) {
|
|
2588
2597
|
for (const numericPropName in object.numericProps) {
|
|
@@ -2791,14 +2800,15 @@ Char: ${this.c}`;
|
|
|
2791
2800
|
});
|
|
2792
2801
|
|
|
2793
2802
|
// ../gis/src/lib/geojson-to-binary.ts
|
|
2794
|
-
function geojsonToBinary(features, options = { fixRingWinding: true }) {
|
|
2803
|
+
function geojsonToBinary(features, options = { fixRingWinding: true, triangulate: true }) {
|
|
2795
2804
|
const geometryInfo = extractGeometryInfo(features);
|
|
2796
2805
|
const coordLength = geometryInfo.coordLength;
|
|
2797
2806
|
const { fixRingWinding } = options;
|
|
2798
2807
|
const flatFeatures = geojsonToFlatGeojson(features, { coordLength, fixRingWinding });
|
|
2799
2808
|
return flatGeojsonToBinary(flatFeatures, geometryInfo, {
|
|
2800
2809
|
numericPropKeys: options.numericPropKeys,
|
|
2801
|
-
PositionDataType: options.PositionDataType || Float32Array
|
|
2810
|
+
PositionDataType: options.PositionDataType || Float32Array,
|
|
2811
|
+
triangulate: options.triangulate
|
|
2802
2812
|
});
|
|
2803
2813
|
}
|
|
2804
2814
|
var init_geojson_to_binary = __esm({
|
|
@@ -17,7 +17,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
17
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
18
|
function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterable[async])) return method.call(iterable); if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
|
|
19
19
|
function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(value) { var ret = this.s.return; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, throw: function _throw(value) { var thr = this.s.return; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); }
|
|
20
|
-
var VERSION = typeof "4.0.0-alpha.
|
|
20
|
+
var VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : 'latest';
|
|
21
21
|
var DEFAULT_GEOJSON_LOADER_OPTIONS = {
|
|
22
22
|
geojson: {
|
|
23
23
|
shape: 'object-row-table'
|
package/dist/es5/json-loader.js
CHANGED
|
@@ -12,7 +12,7 @@ var _parseJson = require("./lib/parsers/parse-json");
|
|
|
12
12
|
var _parseJsonInBatches = require("./lib/parsers/parse-json-in-batches");
|
|
13
13
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
-
var VERSION = typeof "4.0.0-alpha.
|
|
15
|
+
var VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : 'latest';
|
|
16
16
|
var DEFAULT_JSON_LOADER_OPTIONS = {
|
|
17
17
|
json: {
|
|
18
18
|
shape: 'row-table',
|
|
@@ -9,7 +9,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _parseNdjson = require("./lib/parsers/parse-ndjson");
|
|
11
11
|
var _parseNdjsonInBatches = require("./lib/parsers/parse-ndjson-in-batches");
|
|
12
|
-
var VERSION = typeof "4.0.0-alpha.
|
|
12
|
+
var VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : 'latest';
|
|
13
13
|
var DEFAULT_NDGEOJSON_LOADER_OPTIONS = {
|
|
14
14
|
geojson: {
|
|
15
15
|
shape: 'object-row-table'
|
|
@@ -9,7 +9,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _parseNdjson = require("./lib/parsers/parse-ndjson");
|
|
11
11
|
var _parseNdjsonInBatches = require("./lib/parsers/parse-ndjson-in-batches");
|
|
12
|
-
var VERSION = typeof "4.0.0-alpha.
|
|
12
|
+
var VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : 'latest';
|
|
13
13
|
var NDJSONLoader = {
|
|
14
14
|
name: 'NDJSON',
|
|
15
15
|
id: 'ndjson',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { geojsonToBinary } from '@loaders.gl/gis';
|
|
2
2
|
import { parseJSONSync } from './lib/parsers/parse-json';
|
|
3
3
|
import { parseJSONInBatches } from './lib/parsers/parse-json-in-batches';
|
|
4
|
-
const VERSION = typeof "4.0.0-alpha.
|
|
4
|
+
const VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : 'latest';
|
|
5
5
|
const DEFAULT_GEOJSON_LOADER_OPTIONS = {
|
|
6
6
|
geojson: {
|
|
7
7
|
shape: 'object-row-table'
|
package/dist/esm/json-loader.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseJSONSync } from './lib/parsers/parse-json';
|
|
2
2
|
import { parseJSONInBatches } from './lib/parsers/parse-json-in-batches';
|
|
3
|
-
const VERSION = typeof "4.0.0-alpha.
|
|
3
|
+
const VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : '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/parsers/parse-ndjson';
|
|
2
2
|
import { parseNDJSONInBatches } from './lib/parsers/parse-ndjson-in-batches';
|
|
3
|
-
const VERSION = typeof "4.0.0-alpha.
|
|
3
|
+
const VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : 'latest';
|
|
4
4
|
const DEFAULT_NDGEOJSON_LOADER_OPTIONS = {
|
|
5
5
|
geojson: {
|
|
6
6
|
shape: 'object-row-table'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseNDJSONSync } from './lib/parsers/parse-ndjson';
|
|
2
2
|
import { parseNDJSONInBatches } from './lib/parsers/parse-ndjson-in-batches';
|
|
3
|
-
const VERSION = typeof "4.0.0-alpha.
|
|
3
|
+
const VERSION = typeof "4.0.0-alpha.18" !== 'undefined' ? "4.0.0-alpha.18" : 'latest';
|
|
4
4
|
export const NDJSONLoader = {
|
|
5
5
|
name: 'NDJSON',
|
|
6
6
|
id: 'ndjson',
|
package/dist/geojson-worker.js
CHANGED
|
@@ -687,7 +687,8 @@
|
|
|
687
687
|
...geometryInfo
|
|
688
688
|
}, {
|
|
689
689
|
numericPropKeys: options && options.numericPropKeys || numericPropKeys,
|
|
690
|
-
PositionDataType: options ? options.PositionDataType : Float32Array
|
|
690
|
+
PositionDataType: options ? options.PositionDataType : Float32Array,
|
|
691
|
+
triangulate: options ? options.triangulate : true
|
|
691
692
|
});
|
|
692
693
|
}
|
|
693
694
|
function extractNumericPropTypes(features) {
|
|
@@ -716,7 +717,7 @@
|
|
|
716
717
|
propArrayTypes,
|
|
717
718
|
coordLength
|
|
718
719
|
} = geometryInfo;
|
|
719
|
-
const { numericPropKeys = [], PositionDataType = Float32Array } = options;
|
|
720
|
+
const { numericPropKeys = [], PositionDataType = Float32Array, triangulate = true } = options;
|
|
720
721
|
const hasGlobalId = features[0] && "id" in features[0];
|
|
721
722
|
const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
|
|
722
723
|
const points = {
|
|
@@ -743,13 +744,15 @@
|
|
|
743
744
|
polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
|
|
744
745
|
primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
|
|
745
746
|
positions: new PositionDataType(polygonPositionsCount * coordLength),
|
|
746
|
-
triangles: [],
|
|
747
747
|
globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),
|
|
748
748
|
featureIds: polygonFeaturesCount > 65535 ? new Uint32Array(polygonPositionsCount) : new Uint16Array(polygonPositionsCount),
|
|
749
749
|
numericProps: {},
|
|
750
750
|
properties: [],
|
|
751
751
|
fields: []
|
|
752
752
|
};
|
|
753
|
+
if (triangulate) {
|
|
754
|
+
polygons.triangles = [];
|
|
755
|
+
}
|
|
753
756
|
for (const object of [points, lines, polygons]) {
|
|
754
757
|
for (const propName of numericPropKeys) {
|
|
755
758
|
const T = propArrayTypes[propName];
|
|
@@ -854,6 +857,9 @@
|
|
|
854
857
|
endPosition,
|
|
855
858
|
coordLength
|
|
856
859
|
}) {
|
|
860
|
+
if (!polygons.triangles) {
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
857
863
|
const start = startPosition * coordLength;
|
|
858
864
|
const end = endPosition * coordLength;
|
|
859
865
|
const polygonPositions = polygons.positions.subarray(start, end);
|
|
@@ -872,7 +878,7 @@
|
|
|
872
878
|
return returnObj;
|
|
873
879
|
}
|
|
874
880
|
function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
875
|
-
|
|
881
|
+
const binaryFeatures = {
|
|
876
882
|
points: {
|
|
877
883
|
...points,
|
|
878
884
|
positions: { value: points.positions, size: coordLength },
|
|
@@ -893,12 +899,15 @@
|
|
|
893
899
|
positions: { value: polygons.positions, size: coordLength },
|
|
894
900
|
polygonIndices: { value: polygons.polygonIndices, size: 1 },
|
|
895
901
|
primitivePolygonIndices: { value: polygons.primitivePolygonIndices, size: 1 },
|
|
896
|
-
triangles: { value: new Uint32Array(polygons.triangles), size: 1 },
|
|
897
902
|
globalFeatureIds: { value: polygons.globalFeatureIds, size: 1 },
|
|
898
903
|
featureIds: { value: polygons.featureIds, size: 1 },
|
|
899
904
|
numericProps: wrapProps(polygons.numericProps, 1)
|
|
900
905
|
}
|
|
901
906
|
};
|
|
907
|
+
if (polygons.triangles) {
|
|
908
|
+
binaryFeatures.polygons.triangles = { value: new Uint32Array(polygons.triangles), size: 1 };
|
|
909
|
+
}
|
|
910
|
+
return binaryFeatures;
|
|
902
911
|
}
|
|
903
912
|
function fillNumericProperties(object, properties, index, length) {
|
|
904
913
|
for (const numericPropName in object.numericProps) {
|
|
@@ -1093,14 +1102,15 @@
|
|
|
1093
1102
|
}
|
|
1094
1103
|
|
|
1095
1104
|
// ../gis/src/lib/geojson-to-binary.ts
|
|
1096
|
-
function geojsonToBinary(features, options = { fixRingWinding: true }) {
|
|
1105
|
+
function geojsonToBinary(features, options = { fixRingWinding: true, triangulate: true }) {
|
|
1097
1106
|
const geometryInfo = extractGeometryInfo(features);
|
|
1098
1107
|
const coordLength = geometryInfo.coordLength;
|
|
1099
1108
|
const { fixRingWinding } = options;
|
|
1100
1109
|
const flatFeatures = geojsonToFlatGeojson(features, { coordLength, fixRingWinding });
|
|
1101
1110
|
return flatGeojsonToBinary(flatFeatures, geometryInfo, {
|
|
1102
1111
|
numericPropKeys: options.numericPropKeys,
|
|
1103
|
-
PositionDataType: options.PositionDataType || Float32Array
|
|
1112
|
+
PositionDataType: options.PositionDataType || Float32Array,
|
|
1113
|
+
triangulate: options.triangulate
|
|
1104
1114
|
});
|
|
1105
1115
|
}
|
|
1106
1116
|
|
|
@@ -2417,7 +2427,7 @@ Char: ${this.c}`;
|
|
|
2417
2427
|
}
|
|
2418
2428
|
|
|
2419
2429
|
// src/geojson-loader.ts
|
|
2420
|
-
var VERSION = true ? "4.0.0-alpha.
|
|
2430
|
+
var VERSION = true ? "4.0.0-alpha.18" : "latest";
|
|
2421
2431
|
var DEFAULT_GEOJSON_LOADER_OPTIONS = {
|
|
2422
2432
|
geojson: {
|
|
2423
2433
|
shape: "object-row-table"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/json",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.18",
|
|
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 --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@loaders.gl/gis": "4.0.0-alpha.
|
|
39
|
-
"@loaders.gl/loader-utils": "4.0.0-alpha.
|
|
40
|
-
"@loaders.gl/schema": "4.0.0-alpha.
|
|
38
|
+
"@loaders.gl/gis": "4.0.0-alpha.18",
|
|
39
|
+
"@loaders.gl/loader-utils": "4.0.0-alpha.18",
|
|
40
|
+
"@loaders.gl/schema": "4.0.0-alpha.18"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "7bc633f46560f661bdd46cf1015ea27b3694ebce"
|
|
43
43
|
}
|