@loaders.gl/flatgeobuf 4.0.0-beta.6 → 4.0.0-beta.8
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/LICENSE +7 -7
- package/dist/index.cjs +40 -26
- package/dist/lib/binary-geometries.d.ts +43 -3
- package/dist/lib/binary-geometries.d.ts.map +1 -1
- package/dist/lib/binary-geometries.js +23 -17
- package/dist/lib/binary-geometries.js.map +1 -1
- 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 +9 -7
- package/dist/lib/parse-flatgeobuf.js.map +1 -1
- package/package.json +7 -7
- package/src/lib/binary-geometries.ts +63 -25
- package/src/lib/parse-flatgeobuf.ts +17 -11
- package/dist/dist.dev.js +0 -8939
- package/dist/flatgeobuf-worker.js +0 -9086
|
@@ -1,25 +1,31 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
1
4
|
import {Proj4Projection} from '@math.gl/proj4';
|
|
2
5
|
import {transformGeoJsonCoords} from '@loaders.gl/gis';
|
|
3
6
|
|
|
4
|
-
import {deserialize as deserializeGeoJson} from 'flatgeobuf/lib/cjs/geojson';
|
|
5
|
-
import {deserialize as deserializeGeneric} from 'flatgeobuf/lib/cjs/generic';
|
|
6
|
-
import {parseProperties as parsePropertiesBinary} from 'flatgeobuf/lib/cjs/generic/feature';
|
|
7
|
-
|
|
8
7
|
import type {FlatGeobufLoaderOptions} from '../flatgeobuf-loader';
|
|
9
8
|
import type {GeoJSONTable, Feature, Table} from '@loaders.gl/schema';
|
|
10
|
-
import {
|
|
11
|
-
|
|
9
|
+
import {fgbToBinaryGeometry} from './binary-geometries';
|
|
10
|
+
|
|
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
|
+
const deserializeGeoJson = geojson.deserialize;
|
|
16
|
+
const deserializeGeneric = generic.deserialize;
|
|
17
|
+
// const parsePropertiesBinary = FlatgeobufFeature.parseProperties;
|
|
12
18
|
|
|
13
19
|
// TODO: reproject binary features
|
|
14
|
-
function binaryFromFeature(feature, header) {
|
|
20
|
+
function binaryFromFeature(feature: FBGFeature, header: FGBHeader) {
|
|
15
21
|
const geometry = feature.geometry();
|
|
16
22
|
|
|
17
23
|
// FlatGeobuf files can only hold a single geometry type per file, otherwise
|
|
18
24
|
// GeometryType is GeometryCollection
|
|
19
25
|
// I believe geometry.type() is null (0) except when the geometry type isn't
|
|
20
26
|
// known in the header?
|
|
21
|
-
const geometryType = header.geometryType || geometry
|
|
22
|
-
const parsedGeometry =
|
|
27
|
+
const geometryType = header.geometryType || geometry?.type();
|
|
28
|
+
const parsedGeometry = fgbToBinaryGeometry(geometry, geometryType!);
|
|
23
29
|
// @ts-expect-error this looks wrong
|
|
24
30
|
parsedGeometry.properties = parsePropertiesBinary(feature, header.columns);
|
|
25
31
|
|
|
@@ -69,8 +75,8 @@ function parseFlatGeobufToBinary(arrayBuffer: ArrayBuffer, options: FlatGeobufLo
|
|
|
69
75
|
// const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};
|
|
70
76
|
|
|
71
77
|
const array = new Uint8Array(arrayBuffer);
|
|
72
|
-
// @ts-expect-error
|
|
73
|
-
return deserializeGeneric(array,
|
|
78
|
+
// @ts-expect-error
|
|
79
|
+
return deserializeGeneric(array, fgbToBinaryGeometry);
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
function parseFlatGeobufToGeoJSON(
|