@loaders.gl/flatgeobuf 4.0.4 → 4.1.0-alpha.10
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/LICENSE +9 -0
- package/dist/dist.dev.js +8719 -0
- package/dist/flatgeobuf/3.27.2/LICENSE +29 -0
- package/dist/flatgeobuf/3.27.2/README.md +45 -0
- package/dist/flatgeobuf/3.27.2/column-meta.d.ts +14 -0
- package/dist/flatgeobuf/3.27.2/column-meta.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/column-meta.js +2 -0
- package/dist/flatgeobuf/3.27.2/column-meta.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/config.d.ts +10 -0
- package/dist/flatgeobuf/3.27.2/config.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/config.js +16 -0
- package/dist/flatgeobuf/3.27.2/config.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/constants.d.ts +3 -0
- package/dist/flatgeobuf/3.27.2/constants.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/constants.js +3 -0
- package/dist/flatgeobuf/3.27.2/constants.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/crs-meta.d.ts +9 -0
- package/dist/flatgeobuf/3.27.2/crs-meta.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/crs-meta.js +2 -0
- package/dist/flatgeobuf/3.27.2/crs-meta.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/dumptree.d.ts +2 -0
- package/dist/flatgeobuf/3.27.2/dumptree.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/dumptree.js +61 -0
- package/dist/flatgeobuf/3.27.2/dumptree.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/feature.d.ts +2 -0
- package/dist/flatgeobuf/3.27.2/feature.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/feature.js +3 -0
- package/dist/flatgeobuf/3.27.2/feature.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/column-type.d.ts +18 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/column-type.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/column-type.js +19 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/column-type.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/column.d.ts +39 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/column.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/column.js +121 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/column.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/crs.d.ts +29 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/crs.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/crs.js +79 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/crs.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/feature.d.ts +29 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/feature.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/feature.js +95 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/feature.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry-type.d.ts +21 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry-type.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry-type.js +22 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry-type.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry.d.ts +75 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry.js +214 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/geometry.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/header.d.ts +59 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/header.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/header.js +166 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf/header.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf.d.ts +6 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf.js +6 -0
- package/dist/flatgeobuf/3.27.2/flat-geobuf.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/generic/feature.d.ts +19 -0
- package/dist/flatgeobuf/3.27.2/generic/feature.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/generic/feature.js +220 -0
- package/dist/flatgeobuf/3.27.2/generic/feature.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/generic/featurecollection.d.ts +18 -0
- package/dist/flatgeobuf/3.27.2/generic/featurecollection.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/generic/featurecollection.js +162 -0
- package/dist/flatgeobuf/3.27.2/generic/featurecollection.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/generic/geometry.d.ts +33 -0
- package/dist/flatgeobuf/3.27.2/generic/geometry.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/generic/geometry.js +81 -0
- package/dist/flatgeobuf/3.27.2/generic/geometry.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/generic/header.d.ts +5 -0
- package/dist/flatgeobuf/3.27.2/generic/header.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/generic/header.js +27 -0
- package/dist/flatgeobuf/3.27.2/generic/header.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/generic.d.ts +16 -0
- package/dist/flatgeobuf/3.27.2/generic.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/generic.js +9 -0
- package/dist/flatgeobuf/3.27.2/generic.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/geojson/feature.d.ts +8 -0
- package/dist/flatgeobuf/3.27.2/geojson/feature.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/geojson/feature.js +13 -0
- package/dist/flatgeobuf/3.27.2/geojson/feature.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/geojson/featurecollection.d.ts +8 -0
- package/dist/flatgeobuf/3.27.2/geojson/featurecollection.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/geojson/featurecollection.js +54 -0
- package/dist/flatgeobuf/3.27.2/geojson/featurecollection.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/geojson/geometry.d.ts +13 -0
- package/dist/flatgeobuf/3.27.2/geojson/geometry.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/geojson/geometry.js +118 -0
- package/dist/flatgeobuf/3.27.2/geojson/geometry.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/geojson.d.ts +17 -0
- package/dist/flatgeobuf/3.27.2/geojson.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/geojson.js +10 -0
- package/dist/flatgeobuf/3.27.2/geojson.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/header-meta.d.ts +17 -0
- package/dist/flatgeobuf/3.27.2/header-meta.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/header-meta.js +46 -0
- package/dist/flatgeobuf/3.27.2/header-meta.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/header.d.ts +2 -0
- package/dist/flatgeobuf/3.27.2/header.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/header.js +3 -0
- package/dist/flatgeobuf/3.27.2/header.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/http-reader.d.ts +41 -0
- package/dist/flatgeobuf/3.27.2/http-reader.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/http-reader.js +193 -0
- package/dist/flatgeobuf/3.27.2/http-reader.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/index.d.ts +14 -0
- package/dist/flatgeobuf/3.27.2/index.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/index.js +16 -0
- package/dist/flatgeobuf/3.27.2/index.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/logger.d.ts +15 -0
- package/dist/flatgeobuf/3.27.2/logger.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/logger.js +65 -0
- package/dist/flatgeobuf/3.27.2/logger.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/packedrtree.d.ts +43 -0
- package/dist/flatgeobuf/3.27.2/packedrtree.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/packedrtree.js +138 -0
- package/dist/flatgeobuf/3.27.2/packedrtree.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/streams/utils.d.ts +7 -0
- package/dist/flatgeobuf/3.27.2/streams/utils.d.ts.map +1 -0
- package/dist/flatgeobuf/3.27.2/streams/utils.js +67 -0
- package/dist/flatgeobuf/3.27.2/streams/utils.js.map +1 -0
- package/dist/flatgeobuf/3.27.2/types/jsts.d.ts +23 -0
- package/dist/flatgeobuf/3.27.2/types/slice.d.ts +16 -0
- package/dist/flatgeobuf-loader.d.ts +3 -2
- package/dist/flatgeobuf-loader.d.ts.map +1 -1
- package/dist/flatgeobuf-loader.js +12 -2
- package/dist/flatgeobuf-loader.js.map +1 -1
- package/dist/flatgeobuf-worker.js +8908 -0
- package/dist/index.cjs +1658 -51
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -10
- package/dist/index.js.map +1 -1
- package/dist/lib/binary-geometries.d.ts +1 -1
- package/dist/lib/binary-geometries.d.ts.map +1 -1
- package/dist/lib/binary-geometries.js.map +1 -1
- package/dist/lib/get-schema-from-fgb-header.d.ts +16 -0
- package/dist/lib/get-schema-from-fgb-header.d.ts.map +1 -0
- package/dist/lib/get-schema-from-fgb-header.js +90 -0
- package/dist/lib/get-schema-from-fgb-header.js.map +1 -0
- package/dist/lib/parse-flatgeobuf.d.ts +2 -1
- package/dist/lib/parse-flatgeobuf.d.ts.map +1 -1
- package/dist/lib/parse-flatgeobuf.js +29 -23
- package/dist/lib/parse-flatgeobuf.js.map +1 -1
- package/dist/workers/flatgeobuf-worker.js.map +1 -1
- package/package.json +17 -11
- package/src/LICENSE +9 -0
- package/src/flatgeobuf/3.27.2/LICENSE +29 -0
- package/src/flatgeobuf/3.27.2/README.md +45 -0
- package/src/flatgeobuf/3.27.2/column-meta.ts +14 -0
- package/src/flatgeobuf/3.27.2/config.ts +19 -0
- package/src/flatgeobuf/3.27.2/constants.ts +4 -0
- package/src/flatgeobuf/3.27.2/crs-meta.ts +8 -0
- package/src/flatgeobuf/3.27.2/dumptree.ts +82 -0
- package/src/flatgeobuf/3.27.2/feature.ts +3 -0
- package/src/flatgeobuf/3.27.2/flat-geobuf/column-type.ts +19 -0
- package/src/flatgeobuf/3.27.2/flat-geobuf/column.ts +170 -0
- package/src/flatgeobuf/3.27.2/flat-geobuf/crs.ts +114 -0
- package/src/flatgeobuf/3.27.2/flat-geobuf/feature.ts +140 -0
- package/src/flatgeobuf/3.27.2/flat-geobuf/geometry-type.ts +22 -0
- package/src/flatgeobuf/3.27.2/flat-geobuf/geometry.ts +382 -0
- package/src/flatgeobuf/3.27.2/flat-geobuf/header.ts +246 -0
- package/src/flatgeobuf/3.27.2/flat-geobuf.ts +7 -0
- package/src/flatgeobuf/3.27.2/generic/feature.ts +243 -0
- package/src/flatgeobuf/3.27.2/generic/featurecollection.ts +227 -0
- package/src/flatgeobuf/3.27.2/generic/geometry.ts +120 -0
- package/src/flatgeobuf/3.27.2/generic/header.ts +32 -0
- package/src/flatgeobuf/3.27.2/generic.ts +33 -0
- package/src/flatgeobuf/3.27.2/geojson/feature.ts +20 -0
- package/src/flatgeobuf/3.27.2/geojson/featurecollection.ts +101 -0
- package/src/flatgeobuf/3.27.2/geojson/geometry.ts +142 -0
- package/src/flatgeobuf/3.27.2/geojson.ts +37 -0
- package/src/flatgeobuf/3.27.2/header-meta.ts +66 -0
- package/src/flatgeobuf/3.27.2/header.ts +3 -0
- package/src/flatgeobuf/3.27.2/http-reader.ts +351 -0
- package/src/flatgeobuf/3.27.2/index.ts +19 -0
- package/src/flatgeobuf/3.27.2/logger.ts +51 -0
- package/src/flatgeobuf/3.27.2/packedrtree.ts +255 -0
- package/src/flatgeobuf/3.27.2/streams/utils.ts +80 -0
- package/src/flatgeobuf/3.27.2/types/jsts.d.ts +23 -0
- package/src/flatgeobuf/3.27.2/types/slice.d.ts +16 -0
- package/src/flatgeobuf-loader.ts +20 -2
- package/src/index.ts +5 -14
- package/src/lib/binary-geometries.ts +4 -3
- package/src/lib/get-schema-from-fgb-header.ts +122 -0
- package/src/lib/parse-flatgeobuf.ts +35 -27
- package/src/workers/flatgeobuf-worker.ts +4 -0
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
// loaders.gl
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
2
3
|
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
5
|
import {Proj4Projection} from '@math.gl/proj4';
|
|
5
6
|
import {transformGeoJsonCoords} from '@loaders.gl/gis';
|
|
6
7
|
|
|
7
8
|
import type {FlatGeobufLoaderOptions} from '../flatgeobuf-loader';
|
|
8
|
-
import type {GeoJSONTable,
|
|
9
|
+
import type {GeoJSONTable, Table, Schema} from '@loaders.gl/schema';
|
|
10
|
+
|
|
9
11
|
import {fgbToBinaryGeometry} from './binary-geometries';
|
|
12
|
+
import {getSchemaFromFGBHeader} from './get-schema-from-fgb-header';
|
|
13
|
+
|
|
14
|
+
import * as fgb from '../flatgeobuf/3.27.2';
|
|
15
|
+
import * as geojson from '../flatgeobuf/3.27.2/geojson';
|
|
16
|
+
import * as generic from '../flatgeobuf/3.27.2/generic';
|
|
17
|
+
import {parseProperties as parsePropertiesBinary} from '../flatgeobuf/3.27.2/generic/feature';
|
|
10
18
|
|
|
11
|
-
import {Feature as FBGFeature, HeaderMeta as FGBHeader} from 'flatgeobuf';
|
|
12
|
-
import * as geojson from 'flatgeobuf/lib/mjs/geojson.js';
|
|
13
|
-
import * as generic from 'flatgeobuf/lib/mjs/generic.js';
|
|
14
|
-
import {parseProperties as parsePropertiesBinary} from 'flatgeobuf/lib/mjs/generic/feature';
|
|
15
19
|
const deserializeGeoJson = geojson.deserialize;
|
|
16
20
|
const deserializeGeneric = generic.deserialize;
|
|
17
21
|
// const parsePropertiesBinary = FlatgeobufFeature.parseProperties;
|
|
18
22
|
|
|
19
23
|
// TODO: reproject binary features
|
|
20
|
-
function binaryFromFeature(feature:
|
|
24
|
+
function binaryFromFeature(feature: fgb.Feature, header: fgb.HeaderMeta) {
|
|
21
25
|
const geometry = feature.geometry();
|
|
22
26
|
|
|
23
27
|
// FlatGeobuf files can only hold a single geometry type per file, otherwise
|
|
@@ -47,13 +51,7 @@ export function parseFlatGeobuf(
|
|
|
47
51
|
|
|
48
52
|
switch (shape) {
|
|
49
53
|
case 'geojson-table': {
|
|
50
|
-
|
|
51
|
-
const table: GeoJSONTable = {
|
|
52
|
-
shape: 'geojson-table',
|
|
53
|
-
type: 'FeatureCollection',
|
|
54
|
-
features
|
|
55
|
-
};
|
|
56
|
-
return table;
|
|
54
|
+
return parseFlatGeobufToGeoJSONTable(arrayBuffer, options);
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
case 'columnar-table': // binary + some JS arrays
|
|
@@ -79,25 +77,28 @@ function parseFlatGeobufToBinary(arrayBuffer: ArrayBuffer, options: FlatGeobufLo
|
|
|
79
77
|
return deserializeGeneric(array, fgbToBinaryGeometry);
|
|
80
78
|
}
|
|
81
79
|
|
|
82
|
-
function
|
|
80
|
+
function parseFlatGeobufToGeoJSONTable(
|
|
83
81
|
arrayBuffer: ArrayBuffer,
|
|
84
82
|
options: FlatGeobufLoaderOptions = {}
|
|
85
|
-
):
|
|
83
|
+
): GeoJSONTable {
|
|
86
84
|
if (arrayBuffer.byteLength === 0) {
|
|
87
|
-
return [];
|
|
85
|
+
return {shape: 'geojson-table', type: 'FeatureCollection', features: []};
|
|
88
86
|
}
|
|
89
87
|
|
|
90
88
|
const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};
|
|
91
89
|
|
|
92
90
|
const arr = new Uint8Array(arrayBuffer);
|
|
93
91
|
|
|
94
|
-
let
|
|
92
|
+
let fgbHeader;
|
|
93
|
+
let schema: Schema | undefined;
|
|
94
|
+
|
|
95
95
|
// @ts-expect-error this looks wrong
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
let {features} = deserializeGeoJson(arr, undefined, (headerMeta) => {
|
|
97
|
+
fgbHeader = headerMeta;
|
|
98
|
+
schema = getSchemaFromFGBHeader(fgbHeader);
|
|
98
99
|
});
|
|
99
100
|
|
|
100
|
-
const crs =
|
|
101
|
+
const crs = fgbHeader && fgbHeader.crs;
|
|
101
102
|
let projection;
|
|
102
103
|
if (reproject && crs) {
|
|
103
104
|
// Constructing the projection may fail for some invalid WKT strings
|
|
@@ -109,10 +110,10 @@ function parseFlatGeobufToGeoJSON(
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
if (projection) {
|
|
112
|
-
|
|
113
|
+
features = transformGeoJsonCoords(features, (coords) => projection.project(coords));
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
return features;
|
|
116
|
+
return {shape: 'geojson-table', schema, type: 'FeatureCollection', features};
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
/*
|
|
@@ -143,13 +144,20 @@ function parseFlatGeobufInBatchesToBinary(stream, options: FlatGeobufLoaderOptio
|
|
|
143
144
|
return iterator;
|
|
144
145
|
}
|
|
145
146
|
|
|
147
|
+
/**
|
|
148
|
+
* @todo this does not return proper GeoJSONTable batches
|
|
149
|
+
* @param stream
|
|
150
|
+
* @param options
|
|
151
|
+
*/
|
|
146
152
|
// eslint-disable-next-line complexity
|
|
147
153
|
async function* parseFlatGeobufInBatchesToGeoJSON(stream, options: FlatGeobufLoaderOptions) {
|
|
148
154
|
const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};
|
|
149
155
|
|
|
150
|
-
let
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
let fgbHeader;
|
|
157
|
+
// let schema: Schema | undefined;
|
|
158
|
+
const iterator = deserializeGeoJson(stream, undefined, (headerMeta) => {
|
|
159
|
+
fgbHeader = headerMeta;
|
|
160
|
+
// schema = getSchemaFromFGBHeader(fgbHeader);
|
|
153
161
|
});
|
|
154
162
|
|
|
155
163
|
let projection;
|
|
@@ -157,7 +165,7 @@ async function* parseFlatGeobufInBatchesToGeoJSON(stream, options: FlatGeobufLoa
|
|
|
157
165
|
// @ts-expect-error this looks wrong
|
|
158
166
|
for await (const feature of iterator) {
|
|
159
167
|
if (firstRecord) {
|
|
160
|
-
const crs =
|
|
168
|
+
const crs = fgbHeader && fgbHeader.crs;
|
|
161
169
|
if (reproject && crs) {
|
|
162
170
|
projection = new Proj4Projection({from: crs.wkt, to: _targetCrs});
|
|
163
171
|
}
|