@loaders.gl/flatgeobuf 4.2.0-alpha.5 → 4.2.0-beta.1

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.
@@ -1,7 +1,6 @@
1
- class Config {
2
- constructor() {
3
- this._extraRequestThreshold = 256 * 1024;
4
- }
1
+ export default class Config {
2
+ static global = new Config();
3
+ _extraRequestThreshold = 256 * 1024;
5
4
  /**
6
5
  * Fetch up to this many extra bytes if it will eliminate an extra request
7
6
  */
@@ -15,5 +14,3 @@ class Config {
15
14
  this._extraRequestThreshold = bytes;
16
15
  }
17
16
  }
18
- Config.global = new Config();
19
- export default Config;
@@ -2,10 +2,8 @@
2
2
  import * as flatbuffers from 'flatbuffers';
3
3
  import { ColumnType } from "../flat-geobuf/column-type.js";
4
4
  export class Column {
5
- constructor() {
6
- this.bb = null;
7
- this.bb_pos = 0;
8
- }
5
+ bb = null;
6
+ bb_pos = 0;
9
7
  __init(i, bb) {
10
8
  this.bb_pos = i;
11
9
  this.bb = bb;
@@ -1,10 +1,8 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  import * as flatbuffers from 'flatbuffers';
3
3
  export class Crs {
4
- constructor() {
5
- this.bb = null;
6
- this.bb_pos = 0;
7
- }
4
+ bb = null;
5
+ bb_pos = 0;
8
6
  __init(i, bb) {
9
7
  this.bb_pos = i;
10
8
  this.bb = bb;
@@ -3,10 +3,8 @@ import * as flatbuffers from 'flatbuffers';
3
3
  import { Column } from "../flat-geobuf/column.js";
4
4
  import { Geometry } from "../flat-geobuf/geometry.js";
5
5
  export class Feature {
6
- constructor() {
7
- this.bb = null;
8
- this.bb_pos = 0;
9
- }
6
+ bb = null;
7
+ bb_pos = 0;
10
8
  __init(i, bb) {
11
9
  this.bb_pos = i;
12
10
  this.bb = bb;
@@ -2,10 +2,8 @@
2
2
  import * as flatbuffers from 'flatbuffers';
3
3
  import { GeometryType } from "../flat-geobuf/geometry-type.js";
4
4
  export class Geometry {
5
- constructor() {
6
- this.bb = null;
7
- this.bb_pos = 0;
8
- }
5
+ bb = null;
6
+ bb_pos = 0;
9
7
  __init(i, bb) {
10
8
  this.bb_pos = i;
11
9
  this.bb = bb;
@@ -4,10 +4,8 @@ import { Column } from "../flat-geobuf/column.js";
4
4
  import { Crs } from "../flat-geobuf/crs.js";
5
5
  import { GeometryType } from "../flat-geobuf/geometry-type.js";
6
6
  export class Header {
7
- constructor() {
8
- this.bb = null;
9
- this.bb_pos = 0;
10
- }
7
+ bb = null;
8
+ bb_pos = 0;
11
9
  __init(i, bb) {
12
10
  this.bb_pos = i;
13
11
  this.bb = bb;
@@ -7,6 +7,10 @@ import Logger from "./logger.js";
7
7
  import { fromByteBuffer } from "./header-meta.js";
8
8
  import { Feature } from "./flat-geobuf/feature.js";
9
9
  export class HttpReader {
10
+ headerClient;
11
+ header;
12
+ headerLength;
13
+ indexLength;
10
14
  constructor(headerClient, header, headerLength, indexLength) {
11
15
  this.headerClient = headerClient;
12
16
  this.header = header;
@@ -170,13 +174,14 @@ export class HttpReader {
170
174
  }
171
175
  }
172
176
  class BufferedHttpRangeClient {
177
+ httpClient;
178
+ bytesEverUsed = 0;
179
+ bytesEverFetched = 0;
180
+ buffer = new ArrayBuffer(0);
181
+ // Byte offset of `buffer` with respect to the beginning of the file being
182
+ // buffered
183
+ head = 0;
173
184
  constructor(source) {
174
- this.bytesEverUsed = 0;
175
- this.bytesEverFetched = 0;
176
- this.buffer = new ArrayBuffer(0);
177
- // Byte offset of `buffer` with respect to the beginning of the file being
178
- // buffered
179
- this.head = 0;
180
185
  if (typeof source === 'string') {
181
186
  this.httpClient = new HttpRangeClient(source);
182
187
  }
@@ -210,9 +215,10 @@ class BufferedHttpRangeClient {
210
215
  }
211
216
  }
212
217
  class HttpRangeClient {
218
+ url;
219
+ requestsEverMade = 0;
220
+ bytesEverRequested = 0;
213
221
  constructor(url) {
214
- this.requestsEverMade = 0;
215
- this.bytesEverRequested = 0;
216
222
  this.url = url;
217
223
  }
218
224
  async getRange(begin, length, purpose) {
@@ -5,7 +5,8 @@ export var LogLevel;
5
5
  LogLevel[LogLevel["Warn"] = 2] = "Warn";
6
6
  LogLevel[LogLevel["Error"] = 3] = "Error";
7
7
  })(LogLevel || (LogLevel = {}));
8
- class Logger {
8
+ export default class Logger {
9
+ static logLevel = LogLevel.Warn;
9
10
  static debug(...args) {
10
11
  this.log(LogLevel.Debug, ...args);
11
12
  }
@@ -42,5 +43,3 @@ class Logger {
42
43
  }
43
44
  }
44
45
  }
45
- Logger.logLevel = LogLevel.Warn;
46
- export default Logger;
@@ -65,6 +65,8 @@ export function generateLevelBounds(numItems, nodeSize) {
65
65
  */
66
66
  export async function* streamSearch(numItems, nodeSize, rect, readNode) {
67
67
  class NodeRange {
68
+ _level;
69
+ nodes;
68
70
  constructor(nodes, level) {
69
71
  this._level = level;
70
72
  this.nodes = nodes;
@@ -1,13 +1,60 @@
1
- import type { Loader, LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
1
+ import type { LoaderOptions } from '@loaders.gl/loader-utils';
2
+ import { parseFlatGeobuf, parseFlatGeobufInBatches } from "./lib/parse-flatgeobuf.js";
2
3
  export type FlatGeobufLoaderOptions = LoaderOptions & {
3
4
  flatgeobuf?: {
4
5
  shape?: 'geojson-table' | 'columnar-table' | 'binary';
6
+ /** Override the URL to the worker bundle (by default loads from unpkg.com) */
7
+ workerUrl?: string;
5
8
  };
6
9
  gis?: {
7
10
  reproject?: boolean;
8
11
  _targetCrs?: string;
9
12
  };
10
13
  };
11
- export declare const FlatGeobufWorkerLoader: Loader<any, any, FlatGeobufLoaderOptions>;
12
- export declare const FlatGeobufLoader: LoaderWithParser<any, any, FlatGeobufLoaderOptions>;
14
+ export declare const FlatGeobufWorkerLoader: {
15
+ readonly dataType: any;
16
+ readonly batchType: any;
17
+ readonly id: "flatgeobuf";
18
+ readonly name: "FlatGeobuf";
19
+ readonly module: "flatgeobuf";
20
+ readonly version: any;
21
+ readonly worker: true;
22
+ readonly extensions: ["fgb"];
23
+ readonly mimeTypes: ["application/octet-stream"];
24
+ readonly category: "geometry";
25
+ readonly tests: [ArrayBufferLike];
26
+ readonly options: {
27
+ readonly flatgeobuf: {
28
+ readonly shape: "geojson-table";
29
+ };
30
+ readonly gis: {
31
+ readonly reproject: false;
32
+ };
33
+ };
34
+ };
35
+ export declare const FlatGeobufLoader: {
36
+ readonly parse: (arrayBuffer: ArrayBuffer, options: FlatGeobufLoaderOptions | undefined) => Promise<import("@loaders.gl/schema").Table>;
37
+ readonly parseSync: typeof parseFlatGeobuf;
38
+ readonly parseInBatchesFromStream: typeof parseFlatGeobufInBatches;
39
+ readonly binary: true;
40
+ readonly dataType: any;
41
+ readonly batchType: any;
42
+ readonly id: "flatgeobuf";
43
+ readonly name: "FlatGeobuf";
44
+ readonly module: "flatgeobuf";
45
+ readonly version: any;
46
+ readonly worker: true;
47
+ readonly extensions: ["fgb"];
48
+ readonly mimeTypes: ["application/octet-stream"];
49
+ readonly category: "geometry";
50
+ readonly tests: [ArrayBufferLike];
51
+ readonly options: {
52
+ readonly flatgeobuf: {
53
+ readonly shape: "geojson-table";
54
+ };
55
+ readonly gis: {
56
+ readonly reproject: false;
57
+ };
58
+ };
59
+ };
13
60
  //# sourceMappingURL=flatgeobuf-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"flatgeobuf-loader.d.ts","sourceRoot":"","sources":["../src/flatgeobuf-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAUtF,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,sBAAsB,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,uBAAuB,CAkB5E,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,uBAAuB,CAOhF,CAAC"}
1
+ {"version":3,"file":"flatgeobuf-loader.d.ts","sourceRoot":"","sources":["../src/flatgeobuf-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAA2B,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAC,eAAe,EAAE,wBAAwB,EAAC,kCAA+B;AASjF,MAAM,MAAM,uBAAuB,GAAG,aAAa,GAAG;IACpD,UAAU,CAAC,EAAE;QACX,KAAK,CAAC,EAAE,eAAe,GAAG,gBAAgB,GAAG,QAAQ,CAAC;QACtD,8EAA8E;QAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,GAAG,CAAC,EAAE;QACJ,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;CAqB2B,CAAC;AAE/D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;CAO2C,CAAC"}
@@ -4,10 +4,12 @@
4
4
  import { parseFlatGeobuf, parseFlatGeobufInBatches } from "./lib/parse-flatgeobuf.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "4.2.0-alpha.4" !== 'undefined' ? "4.2.0-alpha.4" : 'latest';
7
+ const VERSION = typeof "4.2.0-alpha.6" !== 'undefined' ? "4.2.0-alpha.6" : 'latest';
8
8
  // FGB\3FGB\1
9
9
  const FGB_MAGIC_NUMBER = [0x66, 0x67, 0x62, 0x03, 0x66, 0x67, 0x62, 0x01];
10
10
  export const FlatGeobufWorkerLoader = {
11
+ dataType: null,
12
+ batchType: null,
11
13
  id: 'flatgeobuf',
12
14
  name: 'FlatGeobuf',
13
15
  module: 'flatgeobuf',
@@ -1,5 +1,58 @@
1
1
  "use strict";
2
2
  (() => {
3
+ var __defProp = Object.defineProperty;
4
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
+ var __publicField = (obj, key, value) => {
6
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
+ return value;
8
+ };
9
+
10
+ // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
11
+ function _typeof(obj) {
12
+ "@babel/helpers - typeof";
13
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
14
+ return typeof obj2;
15
+ } : function(obj2) {
16
+ return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
17
+ }, _typeof(obj);
18
+ }
19
+
20
+ // ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
21
+ function _toPrimitive(input, hint) {
22
+ if (_typeof(input) !== "object" || input === null)
23
+ return input;
24
+ var prim = input[Symbol.toPrimitive];
25
+ if (prim !== void 0) {
26
+ var res = prim.call(input, hint || "default");
27
+ if (_typeof(res) !== "object")
28
+ return res;
29
+ throw new TypeError("@@toPrimitive must return a primitive value.");
30
+ }
31
+ return (hint === "string" ? String : Number)(input);
32
+ }
33
+
34
+ // ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
35
+ function _toPropertyKey(arg) {
36
+ var key = _toPrimitive(arg, "string");
37
+ return _typeof(key) === "symbol" ? key : String(key);
38
+ }
39
+
40
+ // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
41
+ function _defineProperty(obj, key, value) {
42
+ key = _toPropertyKey(key);
43
+ if (key in obj) {
44
+ Object.defineProperty(obj, key, {
45
+ value,
46
+ enumerable: true,
47
+ configurable: true,
48
+ writable: true
49
+ });
50
+ } else {
51
+ obj[key] = value;
52
+ }
53
+ return obj;
54
+ }
55
+
3
56
  // ../worker-utils/src/lib/node/worker_threads-browser.ts
4
57
  var parentPort = null;
5
58
 
@@ -59,7 +112,9 @@
59
112
  }
60
113
  getParentPort().then((parentPort2) => {
61
114
  if (parentPort2) {
62
- parentPort2.on("message", handleMessage);
115
+ parentPort2.on("message", (message) => {
116
+ handleMessage(message);
117
+ });
63
118
  parentPort2.on("exit", () => console.debug("Node worker closing"));
64
119
  } else {
65
120
  globalThis.onmessage = handleMessage;
@@ -197,52 +252,6 @@
197
252
  return await parser(data, { ...options }, context, loader);
198
253
  }
199
254
 
200
- // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
201
- function _typeof(obj) {
202
- "@babel/helpers - typeof";
203
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
204
- return typeof obj2;
205
- } : function(obj2) {
206
- return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
207
- }, _typeof(obj);
208
- }
209
-
210
- // ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
211
- function _toPrimitive(input, hint) {
212
- if (_typeof(input) !== "object" || input === null)
213
- return input;
214
- var prim = input[Symbol.toPrimitive];
215
- if (prim !== void 0) {
216
- var res = prim.call(input, hint || "default");
217
- if (_typeof(res) !== "object")
218
- return res;
219
- throw new TypeError("@@toPrimitive must return a primitive value.");
220
- }
221
- return (hint === "string" ? String : Number)(input);
222
- }
223
-
224
- // ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
225
- function _toPropertyKey(arg) {
226
- var key = _toPrimitive(arg, "string");
227
- return _typeof(key) === "symbol" ? key : String(key);
228
- }
229
-
230
- // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
231
- function _defineProperty(obj, key, value) {
232
- key = _toPropertyKey(key);
233
- if (key in obj) {
234
- Object.defineProperty(obj, key, {
235
- value,
236
- enumerable: true,
237
- configurable: true,
238
- writable: true
239
- });
240
- } else {
241
- obj[key] = value;
242
- }
243
- return obj;
244
- }
245
-
246
255
  // ../../node_modules/proj4/lib/global.js
247
256
  function global_default(defs2) {
248
257
  defs2("EPSG:4326", "+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees");
@@ -6080,10 +6089,8 @@
6080
6089
 
6081
6090
  // src/flatgeobuf/3.27.2/flat-geobuf/geometry.ts
6082
6091
  var Geometry = class {
6083
- constructor() {
6084
- this.bb = null;
6085
- this.bb_pos = 0;
6086
- }
6092
+ bb = null;
6093
+ bb_pos = 0;
6087
6094
  __init(i, bb) {
6088
6095
  this.bb_pos = i;
6089
6096
  this.bb = bb;
@@ -6392,10 +6399,8 @@
6392
6399
 
6393
6400
  // src/flatgeobuf/3.27.2/flat-geobuf/column.ts
6394
6401
  var Column = class {
6395
- constructor() {
6396
- this.bb = null;
6397
- this.bb_pos = 0;
6398
- }
6402
+ bb = null;
6403
+ bb_pos = 0;
6399
6404
  __init(i, bb) {
6400
6405
  this.bb_pos = i;
6401
6406
  this.bb = bb;
@@ -6512,10 +6517,8 @@
6512
6517
 
6513
6518
  // src/flatgeobuf/3.27.2/flat-geobuf/feature.ts
6514
6519
  var Feature = class {
6515
- constructor() {
6516
- this.bb = null;
6517
- this.bb_pos = 0;
6518
- }
6520
+ bb = null;
6521
+ bb_pos = 0;
6519
6522
  __init(i, bb) {
6520
6523
  this.bb_pos = i;
6521
6524
  this.bb = bb;
@@ -6794,10 +6797,8 @@
6794
6797
 
6795
6798
  // src/flatgeobuf/3.27.2/flat-geobuf/crs.ts
6796
6799
  var Crs = class {
6797
- constructor() {
6798
- this.bb = null;
6799
- this.bb_pos = 0;
6800
- }
6800
+ bb = null;
6801
+ bb_pos = 0;
6801
6802
  __init(i, bb) {
6802
6803
  this.bb_pos = i;
6803
6804
  this.bb = bb;
@@ -6873,10 +6874,8 @@
6873
6874
 
6874
6875
  // src/flatgeobuf/3.27.2/flat-geobuf/header.ts
6875
6876
  var Header = class {
6876
- constructor() {
6877
- this.bb = null;
6878
- this.bb_pos = 0;
6879
- }
6877
+ bb = null;
6878
+ bb_pos = 0;
6880
6879
  __init(i, bb) {
6881
6880
  this.bb_pos = i;
6882
6881
  this.bb = bb;
@@ -8200,9 +8199,7 @@
8200
8199
 
8201
8200
  // src/flatgeobuf/3.27.2/config.ts
8202
8201
  var _Config = class {
8203
- constructor() {
8204
- this._extraRequestThreshold = 256 * 1024;
8205
- }
8202
+ _extraRequestThreshold = 256 * 1024;
8206
8203
  /**
8207
8204
  * Fetch up to this many extra bytes if it will eliminate an extra request
8208
8205
  */
@@ -8217,7 +8214,7 @@
8217
8214
  }
8218
8215
  };
8219
8216
  var Config = _Config;
8220
- Config.global = new _Config();
8217
+ __publicField(Config, "global", new _Config());
8221
8218
 
8222
8219
  // src/flatgeobuf/3.27.2/logger.ts
8223
8220
  var Logger = class {
@@ -8257,7 +8254,7 @@
8257
8254
  }
8258
8255
  }
8259
8256
  };
8260
- Logger.logLevel = 2 /* Warn */;
8257
+ __publicField(Logger, "logLevel", 2 /* Warn */);
8261
8258
 
8262
8259
  // src/flatgeobuf/3.27.2/packedrtree.ts
8263
8260
  var NODE_ITEM_BYTE_LEN = 8 * 4 + 8;
@@ -8298,6 +8295,8 @@
8298
8295
  }
8299
8296
  async function* streamSearch(numItems, nodeSize, rect, readNode) {
8300
8297
  class NodeRange {
8298
+ _level;
8299
+ nodes;
8301
8300
  constructor(nodes, level) {
8302
8301
  this._level = level;
8303
8302
  this.nodes = nodes;
@@ -8421,6 +8420,10 @@
8421
8420
 
8422
8421
  // src/flatgeobuf/3.27.2/http-reader.ts
8423
8422
  var HttpReader = class {
8423
+ headerClient;
8424
+ header;
8425
+ headerLength;
8426
+ indexLength;
8424
8427
  constructor(headerClient, header, headerLength, indexLength) {
8425
8428
  this.headerClient = headerClient;
8426
8429
  this.header = header;
@@ -8571,13 +8574,14 @@
8571
8574
  }
8572
8575
  };
8573
8576
  var BufferedHttpRangeClient = class {
8577
+ httpClient;
8578
+ bytesEverUsed = 0;
8579
+ bytesEverFetched = 0;
8580
+ buffer = new ArrayBuffer(0);
8581
+ // Byte offset of `buffer` with respect to the beginning of the file being
8582
+ // buffered
8583
+ head = 0;
8574
8584
  constructor(source) {
8575
- this.bytesEverUsed = 0;
8576
- this.bytesEverFetched = 0;
8577
- this.buffer = new ArrayBuffer(0);
8578
- // Byte offset of `buffer` with respect to the beginning of the file being
8579
- // buffered
8580
- this.head = 0;
8581
8585
  if (typeof source === "string") {
8582
8586
  this.httpClient = new HttpRangeClient(source);
8583
8587
  } else if (source instanceof HttpRangeClient) {
@@ -8609,9 +8613,10 @@
8609
8613
  }
8610
8614
  };
8611
8615
  var HttpRangeClient = class {
8616
+ url;
8617
+ requestsEverMade = 0;
8618
+ bytesEverRequested = 0;
8612
8619
  constructor(url) {
8613
- this.requestsEverMade = 0;
8614
- this.bytesEverRequested = 0;
8615
8620
  this.url = url;
8616
8621
  }
8617
8622
  async getRange(begin, length, purpose) {
@@ -8855,9 +8860,11 @@
8855
8860
  }
8856
8861
 
8857
8862
  // src/flatgeobuf-loader.ts
8858
- var VERSION = true ? "4.2.0-alpha.4" : "latest";
8863
+ var VERSION = true ? "4.2.0-alpha.6" : "latest";
8859
8864
  var FGB_MAGIC_NUMBER = [102, 103, 98, 3, 102, 103, 98, 1];
8860
8865
  var FlatGeobufWorkerLoader = {
8866
+ dataType: null,
8867
+ batchType: null,
8861
8868
  id: "flatgeobuf",
8862
8869
  name: "FlatGeobuf",
8863
8870
  module: "flatgeobuf",