@loaders.gl/flatgeobuf 4.2.0-alpha.4 → 4.2.0-alpha.6
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 +264 -218
- package/dist/dist.min.js +30 -0
- package/dist/flatgeobuf/3.27.2/column-meta.d.ts +1 -1
- package/dist/flatgeobuf/3.27.2/column-meta.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/column-meta.js +1 -2
- package/dist/flatgeobuf/3.27.2/config.js +13 -13
- package/dist/flatgeobuf/3.27.2/constants.js +3 -2
- package/dist/flatgeobuf/3.27.2/crs-meta.js +1 -2
- package/dist/flatgeobuf/3.27.2/dumptree.js +28 -23
- package/dist/flatgeobuf/3.27.2/feature.d.ts +1 -1
- package/dist/flatgeobuf/3.27.2/feature.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/feature.js +2 -3
- package/dist/flatgeobuf/3.27.2/flat-geobuf/column-type.js +19 -19
- package/dist/flatgeobuf/3.27.2/flat-geobuf/column.d.ts +1 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf/column.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf/column.js +115 -117
- package/dist/flatgeobuf/3.27.2/flat-geobuf/crs.js +74 -76
- package/dist/flatgeobuf/3.27.2/flat-geobuf/feature.d.ts +2 -2
- package/dist/flatgeobuf/3.27.2/flat-geobuf/feature.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf/feature.js +94 -90
- package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry-type.js +22 -22
- package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry.d.ts +1 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry.js +222 -210
- package/dist/flatgeobuf/3.27.2/flat-geobuf/header.d.ts +3 -3
- package/dist/flatgeobuf/3.27.2/flat-geobuf/header.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf/header.js +164 -160
- package/dist/flatgeobuf/3.27.2/flat-geobuf.d.ts +5 -5
- package/dist/flatgeobuf/3.27.2/flat-geobuf.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf.js +1 -1
- package/dist/flatgeobuf/3.27.2/generic/feature.d.ts +4 -4
- package/dist/flatgeobuf/3.27.2/generic/feature.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/generic/feature.js +195 -205
- package/dist/flatgeobuf/3.27.2/generic/featurecollection.d.ts +6 -6
- package/dist/flatgeobuf/3.27.2/generic/featurecollection.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/generic/featurecollection.js +150 -128
- package/dist/flatgeobuf/3.27.2/generic/geometry.d.ts +2 -2
- package/dist/flatgeobuf/3.27.2/generic/geometry.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/generic/geometry.js +78 -66
- package/dist/flatgeobuf/3.27.2/generic/header.d.ts +3 -3
- package/dist/flatgeobuf/3.27.2/generic/header.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/generic/header.js +18 -18
- package/dist/flatgeobuf/3.27.2/generic/index.d.ts +4 -4
- package/dist/flatgeobuf/3.27.2/generic/index.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/generic/index.js +2 -1
- package/dist/flatgeobuf/3.27.2/generic.d.ts +7 -7
- package/dist/flatgeobuf/3.27.2/generic.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/generic.js +11 -3
- package/dist/flatgeobuf/3.27.2/geojson/feature.d.ts +3 -3
- package/dist/flatgeobuf/3.27.2/geojson/feature.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/geojson/feature.js +8 -9
- package/dist/flatgeobuf/3.27.2/geojson/featurecollection.d.ts +2 -2
- package/dist/flatgeobuf/3.27.2/geojson/featurecollection.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/geojson/featurecollection.js +40 -38
- package/dist/flatgeobuf/3.27.2/geojson/geometry.d.ts +3 -3
- package/dist/flatgeobuf/3.27.2/geojson/geometry.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/geojson/geometry.js +107 -103
- package/dist/flatgeobuf/3.27.2/geojson/index.d.ts +3 -3
- package/dist/flatgeobuf/3.27.2/geojson/index.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/geojson/index.js +2 -1
- package/dist/flatgeobuf/3.27.2/geojson.d.ts +3 -3
- package/dist/flatgeobuf/3.27.2/geojson.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/geojson.js +17 -5
- package/dist/flatgeobuf/3.27.2/header-meta.d.ts +3 -3
- package/dist/flatgeobuf/3.27.2/header-meta.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/header-meta.js +46 -43
- package/dist/flatgeobuf/3.27.2/header.d.ts +1 -1
- package/dist/flatgeobuf/3.27.2/header.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/header.js +2 -3
- package/dist/flatgeobuf/3.27.2/http-reader.d.ts +3 -3
- package/dist/flatgeobuf/3.27.2/http-reader.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/http-reader.js +241 -171
- package/dist/flatgeobuf/3.27.2/index.d.ts +13 -13
- package/dist/flatgeobuf/3.27.2/index.d.ts.map +1 -1
- package/dist/flatgeobuf/3.27.2/index.js +5 -13
- package/dist/flatgeobuf/3.27.2/logger.js +36 -56
- package/dist/flatgeobuf/3.27.2/packedrtree.js +176 -123
- package/dist/flatgeobuf/3.27.2/streams/utils.js +59 -58
- package/dist/flatgeobuf-loader.js +29 -23
- package/dist/flatgeobuf-worker.js +40 -35
- package/dist/index.cjs +191 -213
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/binary-geometries.js +115 -117
- package/dist/lib/get-schema-from-fgb-header.js +110 -85
- package/dist/lib/parse-flatgeobuf.d.ts +1 -1
- package/dist/lib/parse-flatgeobuf.d.ts.map +1 -1
- package/dist/lib/parse-flatgeobuf.js +125 -109
- package/dist/workers/flatgeobuf-worker.js +3 -1
- package/package.json +11 -6
- package/dist/LICENSE +0 -9
- package/dist/flatgeobuf/3.27.2/LICENSE +0 -29
- package/dist/flatgeobuf/3.27.2/README.md +0 -45
- package/dist/flatgeobuf/3.27.2/column-meta.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/config.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/constants.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/crs-meta.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/dumptree.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/feature.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf/column-type.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf/column.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf/crs.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf/feature.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry-type.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf/header.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/flat-geobuf.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/generic/feature.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/generic/featurecollection.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/generic/geometry.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/generic/header.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/generic/index.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/generic.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/geojson/feature.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/geojson/featurecollection.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/geojson/geometry.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/geojson/index.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/geojson.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/header-meta.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/header.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/http-reader.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/index.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/logger.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/packedrtree.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/streams/utils.js.map +0 -1
- package/dist/flatgeobuf/3.27.2/types/jsts.d.ts +0 -23
- package/dist/flatgeobuf/3.27.2/types/slice.d.ts +0 -16
- package/dist/flatgeobuf-loader.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/binary-geometries.js.map +0 -1
- package/dist/lib/get-schema-from-fgb-header.js.map +0 -1
- package/dist/lib/parse-flatgeobuf.js.map +0 -1
- package/dist/workers/flatgeobuf-worker.js.map +0 -1
|
@@ -1,132 +1,130 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
export function fgbToBinaryFeature(geometry, type) {
|
|
2
|
-
|
|
3
|
-
|
|
5
|
+
const fgbGeometry = geometry?.geometry() || null;
|
|
6
|
+
return fgbToBinaryGeometry(fgbGeometry, type);
|
|
4
7
|
}
|
|
5
8
|
export function fgbToBinaryGeometry(geometry, type) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
if (geometry === null) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
switch (type) {
|
|
13
|
+
case GeometryType.Point:
|
|
14
|
+
case GeometryType.MultiPoint:
|
|
15
|
+
return parsePoint(geometry);
|
|
16
|
+
case GeometryType.LineString:
|
|
17
|
+
case GeometryType.MultiLineString:
|
|
18
|
+
return parseLines(geometry);
|
|
19
|
+
case GeometryType.Polygon:
|
|
20
|
+
return parsePolygons(geometry);
|
|
21
|
+
case GeometryType.MultiPolygon:
|
|
22
|
+
return parseMultiPolygons(geometry);
|
|
23
|
+
default:
|
|
24
|
+
throw new Error(`Unimplemented geometry type: ${type}`);
|
|
25
|
+
}
|
|
23
26
|
}
|
|
27
|
+
// Parse Point to flat array
|
|
24
28
|
function parsePoint(geometry) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
positions
|
|
30
|
-
};
|
|
29
|
+
const xy = geometry.xyArray();
|
|
30
|
+
const z = geometry.zArray();
|
|
31
|
+
// @ts-expect-error TODO handle null geometries
|
|
32
|
+
const positions = blitArrays(xy, z);
|
|
33
|
+
return { positions };
|
|
31
34
|
}
|
|
32
35
|
function parseLines(geometry) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
const xy = geometry.xyArray();
|
|
37
|
+
const z = geometry.zArray();
|
|
38
|
+
const positions = blitArrays(xy, z);
|
|
39
|
+
// If endsArray is null, a single LineString. Otherwise, contains the end
|
|
40
|
+
// indices of each part of the MultiLineString. geometry.endsArray() omits the
|
|
41
|
+
// initial 0 that we have in our internal format.
|
|
42
|
+
// @ts-expect-error TODO handle null geometries
|
|
43
|
+
const ends = (geometry.endsArray() && Array.from(geometry.endsArray())) || [xy.length / 2];
|
|
44
|
+
ends.unshift(0);
|
|
45
|
+
const pathIndices = { value: new Uint16Array(ends), size: 1 };
|
|
46
|
+
return {
|
|
47
|
+
positions,
|
|
48
|
+
pathIndices
|
|
49
|
+
};
|
|
46
50
|
}
|
|
47
51
|
function parsePolygons(geometry) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
value: new Uint16Array(
|
|
59
|
-
size: 1
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
};
|
|
52
|
+
const xy = geometry.xyArray();
|
|
53
|
+
const z = geometry.zArray();
|
|
54
|
+
// @ts-expect-error TODO handle null geometries
|
|
55
|
+
const positions = blitArrays(xy, z);
|
|
56
|
+
// If endsArray is null, a simple Polygon with no inner rings. Otherwise,
|
|
57
|
+
// contains the end indices of each ring of the Polygon. geometry.endsArray()
|
|
58
|
+
// omits the initial 0 that we have in our internal format.
|
|
59
|
+
// @ts-expect-error TODO handle null geometries
|
|
60
|
+
const ends = (geometry.endsArray() && Array.from(geometry.endsArray())) || [xy.length / 2];
|
|
61
|
+
ends.unshift(0);
|
|
62
|
+
const primitivePolygonIndices = { value: new Uint16Array(ends), size: 1 };
|
|
63
|
+
const polygonIndices = { value: new Uint16Array([0, xy.length / 2]), size: 1 };
|
|
64
|
+
return {
|
|
65
|
+
positions,
|
|
66
|
+
primitivePolygonIndices,
|
|
67
|
+
polygonIndices
|
|
68
|
+
};
|
|
66
69
|
}
|
|
70
|
+
// eslint-disable-next-line max-statements
|
|
67
71
|
function parseMultiPolygons(geometry) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
},
|
|
104
|
-
polygonIndices: {
|
|
105
|
-
value: concatPolygonIndices,
|
|
106
|
-
size: 1
|
|
72
|
+
// Create arrays for each geometry part, then concatenate
|
|
73
|
+
const parsedParts = [];
|
|
74
|
+
let nPositions = 0;
|
|
75
|
+
let nPrimitivePolygonIndices = 1;
|
|
76
|
+
let nPolygonIndices = 1;
|
|
77
|
+
for (let i = 0; i < geometry.partsLength(); i++) {
|
|
78
|
+
const part = geometry.parts(i);
|
|
79
|
+
// @ts-expect-error TODO handle null geometries
|
|
80
|
+
const polygon = parsePolygons(part);
|
|
81
|
+
nPositions += polygon.positions.value.length;
|
|
82
|
+
nPrimitivePolygonIndices += polygon.primitivePolygonIndices.value.length - 1;
|
|
83
|
+
nPolygonIndices += polygon.polygonIndices.value.length - 1;
|
|
84
|
+
parsedParts.push(polygon);
|
|
85
|
+
}
|
|
86
|
+
const concatPositions = new Float64Array(nPositions);
|
|
87
|
+
const concatPrimitivePolygonIndices = new Uint32Array(nPrimitivePolygonIndices);
|
|
88
|
+
const concatPolygonIndices = new Uint32Array(nPolygonIndices);
|
|
89
|
+
let positionCounter = 0;
|
|
90
|
+
let primitivePolygonIndicesCounter = 1;
|
|
91
|
+
let polygonIndicesCounter = 1;
|
|
92
|
+
// Assumes all parts of the multipolygon have the same size
|
|
93
|
+
const positionSize = parsedParts[0].positions.size;
|
|
94
|
+
for (const parsedPart of parsedParts) {
|
|
95
|
+
concatPositions.set(parsedPart.positions.value, positionCounter * positionSize);
|
|
96
|
+
// For indices, need to add positionCounter so that position indices are
|
|
97
|
+
// correct in the concatenated positions
|
|
98
|
+
concatPrimitivePolygonIndices.set(
|
|
99
|
+
// eslint-disable-next-line
|
|
100
|
+
parsedPart.primitivePolygonIndices.value.subarray(1).map((x) => x + positionCounter), primitivePolygonIndicesCounter);
|
|
101
|
+
concatPolygonIndices.set(
|
|
102
|
+
// eslint-disable-next-line
|
|
103
|
+
parsedPart.polygonIndices.value.subarray(1).map((x) => x + positionCounter), polygonIndicesCounter);
|
|
104
|
+
positionCounter += parsedPart.positions.value.length / positionSize;
|
|
105
|
+
primitivePolygonIndicesCounter += parsedPart.primitivePolygonIndices.value.length - 1;
|
|
106
|
+
polygonIndicesCounter += parsedPart.polygonIndices.value.length - 1;
|
|
107
107
|
}
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
function blitArrays(xy, z) {
|
|
111
|
-
if (!z) {
|
|
112
108
|
return {
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
positions: { value: concatPositions, size: positionSize },
|
|
110
|
+
primitivePolygonIndices: { value: concatPrimitivePolygonIndices, size: 1 },
|
|
111
|
+
polygonIndices: { value: concatPolygonIndices, size: 1 }
|
|
115
112
|
};
|
|
116
|
-
}
|
|
117
|
-
if (z.length * 2 !== xy.length) {
|
|
118
|
-
throw new Error('Z array must be half XY array\'s length');
|
|
119
|
-
}
|
|
120
|
-
const totalLength = xy.length + z.length;
|
|
121
|
-
const xyz = new Float64Array(totalLength);
|
|
122
|
-
for (let i = 0; i < xy.length / 2; i++) {
|
|
123
|
-
xyz[i * 3 + 0] = xy[i * 2 + 0];
|
|
124
|
-
xyz[i * 3 + 1] = xy[i * 2 + 1];
|
|
125
|
-
xyz[i * 3 + 2] = z[i];
|
|
126
|
-
}
|
|
127
|
-
return {
|
|
128
|
-
value: xyz,
|
|
129
|
-
size: 3
|
|
130
|
-
};
|
|
131
113
|
}
|
|
132
|
-
|
|
114
|
+
// Combine xy and z arrays
|
|
115
|
+
function blitArrays(xy, z) {
|
|
116
|
+
if (!z) {
|
|
117
|
+
return { value: xy, size: 2 };
|
|
118
|
+
}
|
|
119
|
+
if (z.length * 2 !== xy.length) {
|
|
120
|
+
throw new Error('Z array must be half XY array\'s length');
|
|
121
|
+
}
|
|
122
|
+
const totalLength = xy.length + z.length;
|
|
123
|
+
const xyz = new Float64Array(totalLength);
|
|
124
|
+
for (let i = 0; i < xy.length / 2; i++) {
|
|
125
|
+
xyz[i * 3 + 0] = xy[i * 2 + 0];
|
|
126
|
+
xyz[i * 3 + 1] = xy[i * 2 + 1];
|
|
127
|
+
xyz[i * 3 + 2] = z[i];
|
|
128
|
+
}
|
|
129
|
+
return { value: xyz, size: 3 };
|
|
130
|
+
}
|
|
@@ -1,90 +1,115 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/**
|
|
5
|
+
* @param fgbHeader
|
|
6
|
+
* geometryType: GeometryType;
|
|
7
|
+
* columns: ColumnMeta[] | null;
|
|
8
|
+
* envelope: Float64Array | null;
|
|
9
|
+
* featuresCount: number;
|
|
10
|
+
* indexNodeSize: number;
|
|
11
|
+
* crs: CrsMeta | null;
|
|
12
|
+
* title: string | null;
|
|
13
|
+
* description: string | null;
|
|
14
|
+
* metadata: string | null;
|
|
15
|
+
*/
|
|
1
16
|
export function getSchemaFromFGBHeader(fgbHeader) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
metadata,
|
|
16
|
-
fields
|
|
17
|
-
};
|
|
17
|
+
const metadata = {
|
|
18
|
+
title: fgbHeader.title || '',
|
|
19
|
+
description: fgbHeader.description || '',
|
|
20
|
+
crs: JSON.stringify(fgbHeader.crs) || '',
|
|
21
|
+
metadata: fgbHeader.metadata || '',
|
|
22
|
+
geometryType: String(fgbHeader.geometryType),
|
|
23
|
+
indexNodeSize: String(fgbHeader.indexNodeSize),
|
|
24
|
+
featureCount: String(fgbHeader.featuresCount),
|
|
25
|
+
bounds: fgbHeader.envelope?.join(',') || ''
|
|
26
|
+
};
|
|
27
|
+
const fields = fgbHeader.columns?.map((column) => getFieldFromFGBColumn(column)) || [];
|
|
28
|
+
return { metadata, fields };
|
|
18
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* name: string;
|
|
32
|
+
* type: ColumnType;
|
|
33
|
+
* title: string | null;
|
|
34
|
+
* description: string | null;
|
|
35
|
+
* width: number;
|
|
36
|
+
* precision: number;
|
|
37
|
+
* scale: number;
|
|
38
|
+
* nullable: boolean;
|
|
39
|
+
* unique: boolean;
|
|
40
|
+
* primary_key: boolean;
|
|
41
|
+
*/
|
|
19
42
|
function getFieldFromFGBColumn(fgbColumn) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
const metadata = {
|
|
44
|
+
title: fgbColumn.title || '',
|
|
45
|
+
description: fgbColumn.description || '',
|
|
46
|
+
width: String(fgbColumn.width),
|
|
47
|
+
precision: String(fgbColumn.precision),
|
|
48
|
+
scale: String(fgbColumn.scale),
|
|
49
|
+
unique: String(fgbColumn.unique),
|
|
50
|
+
primary_key: String(fgbColumn.primary_key)
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
name: fgbColumn.name,
|
|
54
|
+
type: getTypeFromFGBType(fgbColumn.type),
|
|
55
|
+
nullable: fgbColumn.nullable,
|
|
56
|
+
metadata
|
|
57
|
+
};
|
|
35
58
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
59
|
+
/** Note: fgb.ColumType does not appear to be exported */
|
|
60
|
+
var fgbColumnType;
|
|
61
|
+
(function (fgbColumnType) {
|
|
62
|
+
fgbColumnType[fgbColumnType["Byte"] = 0] = "Byte";
|
|
63
|
+
fgbColumnType[fgbColumnType["UByte"] = 1] = "UByte";
|
|
64
|
+
fgbColumnType[fgbColumnType["Bool"] = 2] = "Bool";
|
|
65
|
+
fgbColumnType[fgbColumnType["Short"] = 3] = "Short";
|
|
66
|
+
fgbColumnType[fgbColumnType["UShort"] = 4] = "UShort";
|
|
67
|
+
fgbColumnType[fgbColumnType["Int"] = 5] = "Int";
|
|
68
|
+
fgbColumnType[fgbColumnType["UInt"] = 6] = "UInt";
|
|
69
|
+
fgbColumnType[fgbColumnType["Long"] = 7] = "Long";
|
|
70
|
+
fgbColumnType[fgbColumnType["ULong"] = 8] = "ULong";
|
|
71
|
+
fgbColumnType[fgbColumnType["Float"] = 9] = "Float";
|
|
72
|
+
fgbColumnType[fgbColumnType["Double"] = 10] = "Double";
|
|
73
|
+
fgbColumnType[fgbColumnType["String"] = 11] = "String";
|
|
74
|
+
fgbColumnType[fgbColumnType["Json"] = 12] = "Json";
|
|
75
|
+
fgbColumnType[fgbColumnType["DateTime"] = 13] = "DateTime";
|
|
76
|
+
fgbColumnType[fgbColumnType["Binary"] = 14] = "Binary";
|
|
77
|
+
})(fgbColumnType || (fgbColumnType = {}));
|
|
78
|
+
/** Convert FGB types to arrow like types */
|
|
79
|
+
// eslint-disable-next-line complexity
|
|
80
|
+
function getTypeFromFGBType(fgbType /* fgb.ColumnMeta['type'] */) {
|
|
81
|
+
switch (fgbType) {
|
|
82
|
+
case fgbColumnType.Byte:
|
|
83
|
+
return 'int8';
|
|
84
|
+
case fgbColumnType.UByte:
|
|
85
|
+
return 'uint8';
|
|
86
|
+
case fgbColumnType.Bool:
|
|
87
|
+
return 'bool';
|
|
88
|
+
case fgbColumnType.Short:
|
|
89
|
+
return 'int16';
|
|
90
|
+
case fgbColumnType.UShort:
|
|
91
|
+
return 'uint16';
|
|
92
|
+
case fgbColumnType.Int:
|
|
93
|
+
return 'int32';
|
|
94
|
+
case fgbColumnType.UInt:
|
|
95
|
+
return 'uint32';
|
|
96
|
+
case fgbColumnType.Long:
|
|
97
|
+
return 'int64';
|
|
98
|
+
case fgbColumnType.ULong:
|
|
99
|
+
return 'uint64';
|
|
100
|
+
case fgbColumnType.Float:
|
|
101
|
+
return 'float32';
|
|
102
|
+
case fgbColumnType.Double:
|
|
103
|
+
return 'float64';
|
|
104
|
+
case fgbColumnType.String:
|
|
105
|
+
return 'utf8';
|
|
106
|
+
case fgbColumnType.Json:
|
|
107
|
+
return 'null';
|
|
108
|
+
case fgbColumnType.DateTime:
|
|
109
|
+
return 'date-millisecond';
|
|
110
|
+
case fgbColumnType.Binary:
|
|
111
|
+
return 'binary';
|
|
112
|
+
default:
|
|
113
|
+
return 'null';
|
|
114
|
+
}
|
|
89
115
|
}
|
|
90
|
-
//# sourceMappingURL=get-schema-from-fgb-header.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FlatGeobufLoaderOptions } from
|
|
1
|
+
import type { FlatGeobufLoaderOptions } from "../flatgeobuf-loader.js";
|
|
2
2
|
import type { Table } from '@loaders.gl/schema';
|
|
3
3
|
import * as fgb from '../flatgeobuf/3.27.2';
|
|
4
4
|
export declare function parseFlatGeobuf(arrayBuffer: ArrayBuffer, options?: FlatGeobufLoaderOptions): Table;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-flatgeobuf.d.ts","sourceRoot":"","sources":["../../src/lib/parse-flatgeobuf.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,uBAAuB,EAAC,
|
|
1
|
+
{"version":3,"file":"parse-flatgeobuf.d.ts","sourceRoot":"","sources":["../../src/lib/parse-flatgeobuf.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,uBAAuB,EAAC,gCAA6B;AAClE,OAAO,KAAK,EAAe,KAAK,EAAS,MAAM,oBAAoB,CAAC;AAKpE,OAAO,KAAK,GAAG,MAAM,sBAAsB,CAAC;AAgC5C,wBAAgB,eAAe,CAC7B,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,uBAAuB,GAChC,KAAK,CAoBP;AAyDD,wBAAgB,wBAAwB,CAAC,MAAM,KAAA,EAAE,OAAO,EAAE,uBAAuB,2FAUhF"}
|