@loaders.gl/flatgeobuf 4.0.0-beta.4 → 4.0.0-beta.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 +9 -5
- package/dist/flatgeobuf-loader.d.ts +1 -3
- package/dist/flatgeobuf-loader.d.ts.map +1 -1
- package/dist/flatgeobuf-loader.js.map +1 -1
- package/dist/flatgeobuf-worker.js +10 -6
- package/dist/index.cjs +11 -6
- package/dist/lib/parse-flatgeobuf.d.ts.map +1 -1
- package/dist/lib/parse-flatgeobuf.js +11 -6
- package/dist/lib/parse-flatgeobuf.js.map +1 -1
- package/package.json +4 -4
- package/src/flatgeobuf-loader.ts +1 -3
- package/src/lib/parse-flatgeobuf.ts +9 -6
package/dist/dist.dev.js
CHANGED
|
@@ -8822,9 +8822,8 @@ var __exports__ = (() => {
|
|
|
8822
8822
|
return parsedGeometry;
|
|
8823
8823
|
}
|
|
8824
8824
|
function parseFlatGeobuf(arrayBuffer, options) {
|
|
8825
|
-
const shape = options?.
|
|
8825
|
+
const shape = options?.flatgeobuf?.shape;
|
|
8826
8826
|
switch (shape) {
|
|
8827
|
-
case "geojson":
|
|
8828
8827
|
case "geojson-table": {
|
|
8829
8828
|
const features = parseFlatGeobufToGeoJSON(arrayBuffer, options);
|
|
8830
8829
|
const table = {
|
|
@@ -8882,10 +8881,15 @@ var __exports__ = (() => {
|
|
|
8882
8881
|
return features;
|
|
8883
8882
|
}
|
|
8884
8883
|
function parseFlatGeobufInBatches(stream, options) {
|
|
8885
|
-
|
|
8886
|
-
|
|
8884
|
+
const shape = options.flatgeobuf?.shape;
|
|
8885
|
+
switch (shape) {
|
|
8886
|
+
case "binary":
|
|
8887
|
+
return parseFlatGeobufInBatchesToBinary(stream, options);
|
|
8888
|
+
case "geojson-table":
|
|
8889
|
+
return parseFlatGeobufInBatchesToGeoJSON(stream, options);
|
|
8890
|
+
default:
|
|
8891
|
+
throw new Error(shape);
|
|
8887
8892
|
}
|
|
8888
|
-
return parseFlatGeobufInBatchesToGeoJSON(stream, options);
|
|
8889
8893
|
}
|
|
8890
8894
|
function parseFlatGeobufInBatchesToBinary(stream, options) {
|
|
8891
8895
|
const iterator = (0, import_generic.deserialize)(stream, binaryFromFeature);
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { Loader, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
2
|
export type FlatGeobufLoaderOptions = LoaderOptions & {
|
|
3
3
|
flatgeobuf?: {
|
|
4
|
-
shape?: 'geojson-table' | 'columnar-table' | '
|
|
4
|
+
shape?: 'geojson-table' | 'columnar-table' | 'binary';
|
|
5
5
|
};
|
|
6
6
|
gis?: {
|
|
7
7
|
reproject?: boolean;
|
|
8
8
|
_targetCrs?: string;
|
|
9
|
-
/** @deprecated Use options.flatgeobuf.shape */
|
|
10
|
-
format?: never;
|
|
11
9
|
};
|
|
12
10
|
};
|
|
13
11
|
export declare const FlatGeobufLoader: Loader<any, any, FlatGeobufLoaderOptions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flatgeobuf-loader.d.ts","sourceRoot":"","sources":["../src/flatgeobuf-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAMpE,MAAM,MAAM,uBAAuB,GAAG,aAAa,GAAG;IACpD,UAAU,CAAC,EAAE;QACX,KAAK,CAAC,EAAE,eAAe,GAAG,gBAAgB,GAAG,
|
|
1
|
+
{"version":3,"file":"flatgeobuf-loader.d.ts","sourceRoot":"","sources":["../src/flatgeobuf-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAMpE,MAAM,MAAM,uBAAuB,GAAG,aAAa,GAAG;IACpD,UAAU,CAAC,EAAE;QACX,KAAK,CAAC,EAAE,eAAe,GAAG,gBAAgB,GAAG,QAAQ,CAAC;KACvD,CAAC;IACF,GAAG,CAAC,EAAE;QACJ,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,uBAAuB,CAiBtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flatgeobuf-loader.js","names":["VERSION","__VERSION__","FlatGeobufLoader","id","name","module","version","worker","extensions","mimeTypes","category","options","flatgeobuf","shape","gis","reproject"],"sources":["../src/flatgeobuf-loader.ts"],"sourcesContent":["import type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type FlatGeobufLoaderOptions = LoaderOptions & {\n flatgeobuf?: {\n shape?: 'geojson-table' | 'columnar-table' | '
|
|
1
|
+
{"version":3,"file":"flatgeobuf-loader.js","names":["VERSION","__VERSION__","FlatGeobufLoader","id","name","module","version","worker","extensions","mimeTypes","category","options","flatgeobuf","shape","gis","reproject"],"sources":["../src/flatgeobuf-loader.ts"],"sourcesContent":["import type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type FlatGeobufLoaderOptions = LoaderOptions & {\n flatgeobuf?: {\n shape?: 'geojson-table' | 'columnar-table' | 'binary';\n };\n gis?: {\n reproject?: boolean;\n _targetCrs?: string;\n };\n};\n\nexport const FlatGeobufLoader: Loader<any, any, FlatGeobufLoaderOptions> = {\n id: 'flatgeobuf',\n name: 'FlatGeobuf',\n module: 'flatgeobuf',\n version: VERSION,\n worker: true,\n extensions: ['fgb'],\n mimeTypes: ['application/octet-stream'],\n category: 'geometry',\n options: {\n flatgeobuf: {\n shape: 'geojson-table'\n },\n gis: {\n reproject: false\n }\n }\n};\n"],"mappings":"AAIA,MAAMA,OAAO,GAAG,OAAOC,WAAW,KAAK,WAAW,GAAGA,WAAW,GAAG,QAAQ;AAY3E,OAAO,MAAMC,gBAA2D,GAAG;EACzEC,EAAE,EAAE,YAAY;EAChBC,IAAI,EAAE,YAAY;EAClBC,MAAM,EAAE,YAAY;EACpBC,OAAO,EAAEN,OAAO;EAChBO,MAAM,EAAE,IAAI;EACZC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,0BAA0B,CAAC;EACvCC,QAAQ,EAAE,UAAU;EACpBC,OAAO,EAAE;IACPC,UAAU,EAAE;MACVC,KAAK,EAAE;IACT,CAAC;IACDC,GAAG,EAAE;MACHC,SAAS,EAAE;IACb;EACF;AACF,CAAC"}
|
|
@@ -3472,7 +3472,7 @@
|
|
|
3472
3472
|
}
|
|
3473
3473
|
|
|
3474
3474
|
// src/flatgeobuf-loader.ts
|
|
3475
|
-
var VERSION = true ? "4.0.0-beta.
|
|
3475
|
+
var VERSION = true ? "4.0.0-beta.6" : "latest";
|
|
3476
3476
|
var FlatGeobufLoader = {
|
|
3477
3477
|
id: "flatgeobuf",
|
|
3478
3478
|
name: "FlatGeobuf",
|
|
@@ -8985,9 +8985,8 @@
|
|
|
8985
8985
|
return parsedGeometry;
|
|
8986
8986
|
}
|
|
8987
8987
|
function parseFlatGeobuf(arrayBuffer, options) {
|
|
8988
|
-
const shape = options?.
|
|
8988
|
+
const shape = options?.flatgeobuf?.shape;
|
|
8989
8989
|
switch (shape) {
|
|
8990
|
-
case "geojson":
|
|
8991
8990
|
case "geojson-table": {
|
|
8992
8991
|
const features = parseFlatGeobufToGeoJSON(arrayBuffer, options);
|
|
8993
8992
|
const table = {
|
|
@@ -9034,10 +9033,15 @@
|
|
|
9034
9033
|
return features;
|
|
9035
9034
|
}
|
|
9036
9035
|
function parseFlatGeobufInBatches(stream, options) {
|
|
9037
|
-
|
|
9038
|
-
|
|
9036
|
+
const shape = options.flatgeobuf?.shape;
|
|
9037
|
+
switch (shape) {
|
|
9038
|
+
case "binary":
|
|
9039
|
+
return parseFlatGeobufInBatchesToBinary(stream, options);
|
|
9040
|
+
case "geojson-table":
|
|
9041
|
+
return parseFlatGeobufInBatchesToGeoJSON(stream, options);
|
|
9042
|
+
default:
|
|
9043
|
+
throw new Error(shape);
|
|
9039
9044
|
}
|
|
9040
|
-
return parseFlatGeobufInBatchesToGeoJSON(stream, options);
|
|
9041
9045
|
}
|
|
9042
9046
|
function parseFlatGeobufInBatchesToBinary(stream, options) {
|
|
9043
9047
|
const iterator = (0, import_generic.deserialize)(stream, binaryFromFeature);
|
package/dist/index.cjs
CHANGED
|
@@ -171,10 +171,9 @@ function binaryFromFeature(feature, header) {
|
|
|
171
171
|
return parsedGeometry;
|
|
172
172
|
}
|
|
173
173
|
function parseFlatGeobuf(arrayBuffer, options) {
|
|
174
|
-
var _a
|
|
175
|
-
const shape = (
|
|
174
|
+
var _a;
|
|
175
|
+
const shape = (_a = options == null ? void 0 : options.flatgeobuf) == null ? void 0 : _a.shape;
|
|
176
176
|
switch (shape) {
|
|
177
|
-
case "geojson":
|
|
178
177
|
case "geojson-table": {
|
|
179
178
|
const features = parseFlatGeobufToGeoJSON(arrayBuffer, options);
|
|
180
179
|
const table = {
|
|
@@ -221,10 +220,16 @@ function parseFlatGeobufToGeoJSON(arrayBuffer, options = {}) {
|
|
|
221
220
|
return features;
|
|
222
221
|
}
|
|
223
222
|
function parseFlatGeobufInBatches(stream, options) {
|
|
224
|
-
|
|
225
|
-
|
|
223
|
+
var _a;
|
|
224
|
+
const shape = (_a = options.flatgeobuf) == null ? void 0 : _a.shape;
|
|
225
|
+
switch (shape) {
|
|
226
|
+
case "binary":
|
|
227
|
+
return parseFlatGeobufInBatchesToBinary(stream, options);
|
|
228
|
+
case "geojson-table":
|
|
229
|
+
return parseFlatGeobufInBatchesToGeoJSON(stream, options);
|
|
230
|
+
default:
|
|
231
|
+
throw new Error(shape);
|
|
226
232
|
}
|
|
227
|
-
return parseFlatGeobufInBatchesToGeoJSON(stream, options);
|
|
228
233
|
}
|
|
229
234
|
function parseFlatGeobufInBatchesToBinary(stream, options) {
|
|
230
235
|
const iterator = (0, import_generic.deserialize)(stream, binaryFromFeature);
|
|
@@ -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,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAwB,KAAK,EAAC,MAAM,oBAAoB,CAAC;AA2BrE,wBAAgB,eAAe,CAC7B,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,uBAAuB,GAChC,KAAK,
|
|
1
|
+
{"version":3,"file":"parse-flatgeobuf.d.ts","sourceRoot":"","sources":["../../src/lib/parse-flatgeobuf.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAwB,KAAK,EAAC,MAAM,oBAAoB,CAAC;AA2BrE,wBAAgB,eAAe,CAC7B,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,uBAAuB,GAChC,KAAK,CA0BP;AAsDD,wBAAgB,wBAAwB,CAAC,MAAM,KAAA,EAAE,OAAO,EAAE,uBAAuB,oIAUhF"}
|
|
@@ -12,10 +12,9 @@ function binaryFromFeature(feature, header) {
|
|
|
12
12
|
return parsedGeometry;
|
|
13
13
|
}
|
|
14
14
|
export function parseFlatGeobuf(arrayBuffer, options) {
|
|
15
|
-
var _options$
|
|
16
|
-
const shape =
|
|
15
|
+
var _options$flatgeobuf;
|
|
16
|
+
const shape = options === null || options === void 0 ? void 0 : (_options$flatgeobuf = options.flatgeobuf) === null || _options$flatgeobuf === void 0 ? void 0 : _options$flatgeobuf.shape;
|
|
17
17
|
switch (shape) {
|
|
18
|
-
case 'geojson':
|
|
19
18
|
case 'geojson-table':
|
|
20
19
|
{
|
|
21
20
|
const features = parseFlatGeobufToGeoJSON(arrayBuffer, options);
|
|
@@ -75,10 +74,16 @@ function parseFlatGeobufToGeoJSON(arrayBuffer) {
|
|
|
75
74
|
return features;
|
|
76
75
|
}
|
|
77
76
|
export function parseFlatGeobufInBatches(stream, options) {
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
var _options$flatgeobuf2;
|
|
78
|
+
const shape = (_options$flatgeobuf2 = options.flatgeobuf) === null || _options$flatgeobuf2 === void 0 ? void 0 : _options$flatgeobuf2.shape;
|
|
79
|
+
switch (shape) {
|
|
80
|
+
case 'binary':
|
|
81
|
+
return parseFlatGeobufInBatchesToBinary(stream, options);
|
|
82
|
+
case 'geojson-table':
|
|
83
|
+
return parseFlatGeobufInBatchesToGeoJSON(stream, options);
|
|
84
|
+
default:
|
|
85
|
+
throw new Error(shape);
|
|
80
86
|
}
|
|
81
|
-
return parseFlatGeobufInBatchesToGeoJSON(stream, options);
|
|
82
87
|
}
|
|
83
88
|
function parseFlatGeobufInBatchesToBinary(stream, options) {
|
|
84
89
|
const iterator = deserializeGeneric(stream, binaryFromFeature);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-flatgeobuf.js","names":["Proj4Projection","transformGeoJsonCoords","deserialize","deserializeGeoJson","deserializeGeneric","parseProperties","parsePropertiesBinary","fromGeometry","binaryFromGeometry","binaryFromFeature","feature","header","geometry","geometryType","type","parsedGeometry","properties","columns","parseFlatGeobuf","arrayBuffer","options","_options$
|
|
1
|
+
{"version":3,"file":"parse-flatgeobuf.js","names":["Proj4Projection","transformGeoJsonCoords","deserialize","deserializeGeoJson","deserializeGeneric","parseProperties","parsePropertiesBinary","fromGeometry","binaryFromGeometry","binaryFromFeature","feature","header","geometry","geometryType","type","parsedGeometry","properties","columns","parseFlatGeobuf","arrayBuffer","options","_options$flatgeobuf","shape","flatgeobuf","features","parseFlatGeobufToGeoJSON","table","binary","parseFlatGeobufToBinary","data","Error","arguments","length","undefined","array","Uint8Array","byteLength","reproject","_targetCrs","gis","arr","headerMeta","crs","projection","from","wkt","to","e","coords","project","parseFlatGeobufInBatches","stream","_options$flatgeobuf2","parseFlatGeobufInBatchesToBinary","parseFlatGeobufInBatchesToGeoJSON","iterator","firstRecord"],"sources":["../../src/lib/parse-flatgeobuf.ts"],"sourcesContent":["import {Proj4Projection} from '@math.gl/proj4';\nimport {transformGeoJsonCoords} from '@loaders.gl/gis';\n\nimport {deserialize as deserializeGeoJson} from 'flatgeobuf/lib/cjs/geojson';\nimport {deserialize as deserializeGeneric} from 'flatgeobuf/lib/cjs/generic';\nimport {parseProperties as parsePropertiesBinary} from 'flatgeobuf/lib/cjs/generic/feature';\n\nimport type {FlatGeobufLoaderOptions} from '../flatgeobuf-loader';\nimport type {GeoJSONTable, Feature, Table} from '@loaders.gl/schema';\nimport {fromGeometry as binaryFromGeometry} from './binary-geometries';\n// import {Feature} from 'flatgeobuf/lib/cjs/feature_generated';\n\n// TODO: reproject binary features\nfunction binaryFromFeature(feature, header) {\n const geometry = feature.geometry();\n\n // FlatGeobuf files can only hold a single geometry type per file, otherwise\n // GeometryType is GeometryCollection\n // I believe geometry.type() is null (0) except when the geometry type isn't\n // known in the header?\n const geometryType = header.geometryType || geometry.type();\n const parsedGeometry = binaryFromGeometry(geometry, geometryType);\n // @ts-expect-error this looks wrong\n parsedGeometry.properties = parsePropertiesBinary(feature, header.columns);\n\n // TODO: wrap binary data either in points, lines, or polygons key\n return parsedGeometry;\n}\n\n/*\n * Parse FlatGeobuf arrayBuffer and return GeoJSON.\n *\n * @param arrayBuffer A FlatGeobuf arrayBuffer\n * @return A GeoJSON geometry object\n */\nexport function parseFlatGeobuf(\n arrayBuffer: ArrayBuffer,\n options?: FlatGeobufLoaderOptions\n): Table {\n const shape = options?.flatgeobuf?.shape;\n\n switch (shape) {\n case 'geojson-table': {\n const features = parseFlatGeobufToGeoJSON(arrayBuffer, options);\n const table: GeoJSONTable = {\n shape: 'geojson-table',\n type: 'FeatureCollection',\n features\n };\n return table;\n }\n\n case 'columnar-table': // binary + some JS arrays\n const binary = parseFlatGeobufToBinary(arrayBuffer, options);\n // @ts-expect-error\n return {shape: 'columnar-table', data: binary};\n\n case 'binary':\n // @ts-expect-error\n return parseFlatGeobufToBinary(arrayBuffer, options);\n\n default:\n throw new Error(shape);\n }\n}\n\nfunction parseFlatGeobufToBinary(arrayBuffer: ArrayBuffer, options: FlatGeobufLoaderOptions = {}) {\n // TODO: reproject binary features\n // const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};\n\n const array = new Uint8Array(arrayBuffer);\n // @ts-expect-error this looks wrong\n return deserializeGeneric(array, binaryFromFeature);\n}\n\nfunction parseFlatGeobufToGeoJSON(\n arrayBuffer: ArrayBuffer,\n options: FlatGeobufLoaderOptions = {}\n): Feature[] {\n if (arrayBuffer.byteLength === 0) {\n return [];\n }\n\n const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};\n\n const arr = new Uint8Array(arrayBuffer);\n\n let headerMeta;\n // @ts-expect-error this looks wrong\n const {features} = deserializeGeoJson(arr, undefined, (header) => {\n headerMeta = header;\n });\n\n const crs = headerMeta && headerMeta.crs;\n let projection;\n if (reproject && crs) {\n // Constructing the projection may fail for some invalid WKT strings\n try {\n projection = new Proj4Projection({from: crs.wkt, to: _targetCrs});\n } catch (e) {\n // no op\n }\n }\n\n if (projection) {\n return transformGeoJsonCoords(features, (coords) => projection.project(coords));\n }\n\n return features;\n}\n\n/*\n * Parse FlatGeobuf arrayBuffer and return GeoJSON.\n *\n * @param {ReadableStream} _ A FlatGeobuf arrayBuffer\n * @return A GeoJSON geometry object iterator\n */\n// eslint-disable-next-line complexity\nexport function parseFlatGeobufInBatches(stream, options: FlatGeobufLoaderOptions) {\n const shape = options.flatgeobuf?.shape;\n switch (shape) {\n case 'binary':\n return parseFlatGeobufInBatchesToBinary(stream, options);\n case 'geojson-table':\n return parseFlatGeobufInBatchesToGeoJSON(stream, options);\n default:\n throw new Error(shape);\n }\n}\n\nfunction parseFlatGeobufInBatchesToBinary(stream, options: FlatGeobufLoaderOptions) {\n // TODO: reproject binary streaming features\n // const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};\n\n // @ts-expect-error\n const iterator = deserializeGeneric(stream, binaryFromFeature);\n return iterator;\n}\n\n// eslint-disable-next-line complexity\nasync function* parseFlatGeobufInBatchesToGeoJSON(stream, options: FlatGeobufLoaderOptions) {\n const {reproject = false, _targetCrs = 'WGS84'} = (options && options.gis) || {};\n\n let headerMeta;\n const iterator = deserializeGeoJson(stream, undefined, (header) => {\n headerMeta = header;\n });\n\n let projection;\n let firstRecord = true;\n // @ts-expect-error this looks wrong\n for await (const feature of iterator) {\n if (firstRecord) {\n const crs = headerMeta && headerMeta.crs;\n if (reproject && crs) {\n projection = new Proj4Projection({from: crs.wkt, to: _targetCrs});\n }\n\n firstRecord = false;\n }\n\n if (reproject && projection) {\n // eslint-disable-next-line\n yield transformGeoJsonCoords([feature], (coords) => projection.project(coords));\n } else {\n yield feature;\n }\n }\n}\n"],"mappings":"AAAA,SAAQA,eAAe,QAAO,gBAAgB;AAC9C,SAAQC,sBAAsB,QAAO,iBAAiB;AAEtD,SAAQC,WAAW,IAAIC,kBAAkB,QAAO,4BAA4B;AAC5E,SAAQD,WAAW,IAAIE,kBAAkB,QAAO,4BAA4B;AAC5E,SAAQC,eAAe,IAAIC,qBAAqB,QAAO,oCAAoC;AAAC,SAIpFC,YAAY,IAAIC,kBAAkB;AAI1C,SAASC,iBAAiBA,CAACC,OAAO,EAAEC,MAAM,EAAE;EAC1C,MAAMC,QAAQ,GAAGF,OAAO,CAACE,QAAQ,CAAC,CAAC;EAMnC,MAAMC,YAAY,GAAGF,MAAM,CAACE,YAAY,IAAID,QAAQ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IACjF,CAAC,MAAM;MACL,MAAMtC,OAAO;IACf;EACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/flatgeobuf",
|
|
3
3
|
"description": "Loader for FlatGeobuf",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.6",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"publishConfig": {
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"build-worker": "esbuild src/workers/flatgeobuf-worker.ts --bundle --outfile=dist/flatgeobuf-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@loaders.gl/gis": "4.0.0-beta.
|
|
44
|
-
"@loaders.gl/loader-utils": "4.0.0-beta.
|
|
43
|
+
"@loaders.gl/gis": "4.0.0-beta.6",
|
|
44
|
+
"@loaders.gl/loader-utils": "4.0.0-beta.6",
|
|
45
45
|
"@math.gl/proj4": "^4.0.0",
|
|
46
46
|
"flatgeobuf": "3.6.5"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "2840f605b7a551e2ffef5f960231d989a0414c50"
|
|
49
49
|
}
|
package/src/flatgeobuf-loader.ts
CHANGED
|
@@ -6,13 +6,11 @@ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
|
6
6
|
|
|
7
7
|
export type FlatGeobufLoaderOptions = LoaderOptions & {
|
|
8
8
|
flatgeobuf?: {
|
|
9
|
-
shape?: 'geojson-table' | 'columnar-table' | '
|
|
9
|
+
shape?: 'geojson-table' | 'columnar-table' | 'binary';
|
|
10
10
|
};
|
|
11
11
|
gis?: {
|
|
12
12
|
reproject?: boolean;
|
|
13
13
|
_targetCrs?: string;
|
|
14
|
-
/** @deprecated Use options.flatgeobuf.shape */
|
|
15
|
-
format?: never;
|
|
16
14
|
};
|
|
17
15
|
};
|
|
18
16
|
|
|
@@ -37,10 +37,9 @@ export function parseFlatGeobuf(
|
|
|
37
37
|
arrayBuffer: ArrayBuffer,
|
|
38
38
|
options?: FlatGeobufLoaderOptions
|
|
39
39
|
): Table {
|
|
40
|
-
const shape = options?.
|
|
40
|
+
const shape = options?.flatgeobuf?.shape;
|
|
41
41
|
|
|
42
42
|
switch (shape) {
|
|
43
|
-
case 'geojson':
|
|
44
43
|
case 'geojson-table': {
|
|
45
44
|
const features = parseFlatGeobufToGeoJSON(arrayBuffer, options);
|
|
46
45
|
const table: GeoJSONTable = {
|
|
@@ -118,11 +117,15 @@ function parseFlatGeobufToGeoJSON(
|
|
|
118
117
|
*/
|
|
119
118
|
// eslint-disable-next-line complexity
|
|
120
119
|
export function parseFlatGeobufInBatches(stream, options: FlatGeobufLoaderOptions) {
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
const shape = options.flatgeobuf?.shape;
|
|
121
|
+
switch (shape) {
|
|
122
|
+
case 'binary':
|
|
123
|
+
return parseFlatGeobufInBatchesToBinary(stream, options);
|
|
124
|
+
case 'geojson-table':
|
|
125
|
+
return parseFlatGeobufInBatchesToGeoJSON(stream, options);
|
|
126
|
+
default:
|
|
127
|
+
throw new Error(shape);
|
|
123
128
|
}
|
|
124
|
-
|
|
125
|
-
return parseFlatGeobufInBatchesToGeoJSON(stream, options);
|
|
126
129
|
}
|
|
127
130
|
|
|
128
131
|
function parseFlatGeobufInBatchesToBinary(stream, options: FlatGeobufLoaderOptions) {
|