@loaders.gl/shapefile 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.
- package/dist/dbf-loader.d.ts +25 -2
- package/dist/dbf-loader.d.ts.map +1 -1
- package/dist/dbf-loader.js +6 -1
- package/dist/dbf-worker.js +16 -7
- package/dist/dist.dev.js +30 -19
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +33 -22
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/lib/parsers/parse-dbf.d.ts.map +1 -1
- package/dist/lib/parsers/parse-dbf.js +9 -5
- package/dist/lib/parsers/parse-shapefile.d.ts.map +1 -1
- package/dist/lib/parsers/parse-shapefile.js +3 -0
- package/dist/lib/parsers/parse-shp-geometry.d.ts.map +1 -1
- package/dist/lib/parsers/parse-shp-geometry.js +3 -0
- package/dist/lib/parsers/parse-shp-header.d.ts.map +1 -1
- package/dist/lib/parsers/parse-shp-header.js +3 -0
- package/dist/lib/parsers/parse-shp.d.ts.map +1 -1
- package/dist/lib/parsers/parse-shp.js +17 -14
- package/dist/lib/parsers/parse-shx.d.ts.map +1 -1
- package/dist/lib/parsers/parse-shx.js +3 -0
- package/dist/lib/parsers/types.d.ts.map +1 -1
- package/dist/lib/parsers/types.js +3 -0
- package/dist/lib/streaming/binary-chunk-reader.js +4 -0
- package/dist/lib/streaming/binary-reader.js +2 -0
- package/dist/shapefile-loader.d.ts +24 -3
- package/dist/shapefile-loader.d.ts.map +1 -1
- package/dist/shapefile-loader.js +4 -1
- package/dist/shp-loader.d.ts +27 -2
- package/dist/shp-loader.d.ts.map +1 -1
- package/dist/shp-loader.js +6 -1
- package/dist/shp-worker.js +24 -16
- package/dist/workers/dbf-worker.js +3 -0
- package/dist/workers/shp-worker.js +3 -0
- package/package.json +5 -5
- package/src/dbf-loader.ts +18 -3
- package/src/index.ts +9 -0
- package/src/lib/parsers/parse-dbf.ts +4 -0
- package/src/lib/parsers/parse-shapefile.ts +4 -0
- package/src/lib/parsers/parse-shp-geometry.ts +4 -0
- package/src/lib/parsers/parse-shp-header.ts +4 -0
- package/src/lib/parsers/parse-shp.ts +4 -0
- package/src/lib/parsers/parse-shx.ts +4 -0
- package/src/lib/parsers/types.ts +4 -0
- package/src/shapefile-loader.ts +8 -2
- package/src/shp-loader.ts +19 -3
- package/src/workers/dbf-worker.ts +4 -0
- package/src/workers/shp-worker.ts +4 -0
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { BinaryChunkReader } from "../streaming/binary-chunk-reader.js";
|
|
2
5
|
import { parseSHPHeader } from "./parse-shp-header.js";
|
|
3
6
|
import { parseRecord } from "./parse-shp-geometry.js";
|
|
@@ -14,21 +17,21 @@ const STATE = {
|
|
|
14
17
|
ERROR: 3
|
|
15
18
|
};
|
|
16
19
|
class SHPParser {
|
|
20
|
+
options = {};
|
|
21
|
+
binaryReader = new BinaryChunkReader({ maxRewindBytes: SHP_RECORD_HEADER_SIZE });
|
|
22
|
+
state = STATE.EXPECTING_HEADER;
|
|
23
|
+
result = {
|
|
24
|
+
geometries: [],
|
|
25
|
+
// Initialize with number values to make TS happy
|
|
26
|
+
// These are initialized for real in STATE.EXPECTING_HEADER
|
|
27
|
+
progress: {
|
|
28
|
+
bytesTotal: NaN,
|
|
29
|
+
bytesUsed: NaN,
|
|
30
|
+
rows: NaN
|
|
31
|
+
},
|
|
32
|
+
currentIndex: NaN
|
|
33
|
+
};
|
|
17
34
|
constructor(options) {
|
|
18
|
-
this.options = {};
|
|
19
|
-
this.binaryReader = new BinaryChunkReader({ maxRewindBytes: SHP_RECORD_HEADER_SIZE });
|
|
20
|
-
this.state = STATE.EXPECTING_HEADER;
|
|
21
|
-
this.result = {
|
|
22
|
-
geometries: [],
|
|
23
|
-
// Initialize with number values to make TS happy
|
|
24
|
-
// These are initialized for real in STATE.EXPECTING_HEADER
|
|
25
|
-
progress: {
|
|
26
|
-
bytesTotal: NaN,
|
|
27
|
-
bytesUsed: NaN,
|
|
28
|
-
rows: NaN
|
|
29
|
-
},
|
|
30
|
-
currentIndex: NaN
|
|
31
|
-
};
|
|
32
35
|
this.options = options;
|
|
33
36
|
}
|
|
34
37
|
write(arrayBuffer) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-shx.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-shx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-shx.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-shx.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,UAAU,CAAC;IACpB,OAAO,EAAE,UAAU,CAAC;CACrB;AAKD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,WAAW,EAAE,WAAW,GAAG,SAAS,CAoB5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAE5D,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE;QACJ,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE;QACJ,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,kBAAkB,CAAC;KAC/C,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAChD,gBAAgB,GAAG;IACjB,SAAS,CAAC,EAAE;QACV,KAAK,CAAC,EAAE,eAAe,CAAC;KACzB,CAAC;IACF,GAAG,CAAC,EAAE;QACJ,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAC;AAEJ,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,MAAM,SAAS,GAAG;IAEtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IAEZ,QAAQ,EAAE,MAAM,CAAC;IAEjB,YAAY,EAAE,MAAM,CAAC;IAErB,YAAY,EAAE,MAAM,CAAC;IAErB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH,CAAC"}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
export class BinaryChunkReader {
|
|
5
|
+
offset;
|
|
6
|
+
arrayBuffers;
|
|
7
|
+
ended;
|
|
8
|
+
maxRewindBytes;
|
|
5
9
|
constructor(options) {
|
|
6
10
|
const { maxRewindBytes = 0 } = options || {};
|
|
7
11
|
/** current global offset into current array buffer*/
|
|
@@ -1,13 +1,34 @@
|
|
|
1
|
-
import type { LoaderOptions
|
|
2
|
-
import {
|
|
1
|
+
import type { LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
+
import { parseShapefile, parseShapefileInBatches } from "./lib/parsers/parse-shapefile.js";
|
|
3
3
|
export type ShapefileLoaderOptions = LoaderOptions & {
|
|
4
4
|
shapefile?: {
|
|
5
5
|
shape?: 'geojson-table' | 'v3';
|
|
6
|
+
/** @deprecated Worker URLs must be specified with .dbf.workerUrl * .shp.workerUrl */
|
|
7
|
+
workerUrl?: never;
|
|
6
8
|
};
|
|
7
9
|
};
|
|
8
10
|
/**
|
|
9
11
|
* Shapefile loader
|
|
10
12
|
* @note Shapefile is multifile format and requires providing additional files
|
|
11
13
|
*/
|
|
12
|
-
export declare const ShapefileLoader:
|
|
14
|
+
export declare const ShapefileLoader: {
|
|
15
|
+
readonly name: "Shapefile";
|
|
16
|
+
readonly id: "shapefile";
|
|
17
|
+
readonly module: "shapefile";
|
|
18
|
+
readonly version: any;
|
|
19
|
+
readonly category: "geometry";
|
|
20
|
+
readonly extensions: ["shp"];
|
|
21
|
+
readonly mimeTypes: ["application/octet-stream"];
|
|
22
|
+
readonly tests: [ArrayBufferLike];
|
|
23
|
+
readonly options: {
|
|
24
|
+
readonly shapefile: {
|
|
25
|
+
readonly shape: "v3";
|
|
26
|
+
};
|
|
27
|
+
readonly shp: {
|
|
28
|
+
readonly _maxDimensions: 4;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
readonly parse: typeof parseShapefile;
|
|
32
|
+
readonly parseInBatches: typeof parseShapefileInBatches;
|
|
33
|
+
};
|
|
13
34
|
//# sourceMappingURL=shapefile-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shapefile-loader.d.ts","sourceRoot":"","sources":["../src/shapefile-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shapefile-loader.d.ts","sourceRoot":"","sources":["../src/shapefile-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAmB,MAAM,0BAA0B,CAAC;AAE9E,OAAO,EAAC,cAAc,EAAE,uBAAuB,EAAC,yCAAsC;AAOtF,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG;IACnD,SAAS,CAAC,EAAE;QACV,KAAK,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;QAC/B,qFAAqF;QACrF,SAAS,CAAC,EAAE,KAAK,CAAC;KACnB,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;CAqBsD,CAAC"}
|
package/dist/shapefile-loader.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { SHP_MAGIC_NUMBER } from "./shp-loader.js";
|
|
2
5
|
import { parseShapefile, parseShapefileInBatches } from "./lib/parsers/parse-shapefile.js";
|
|
3
6
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
4
7
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
5
|
-
const VERSION = typeof "4.2.0-alpha.
|
|
8
|
+
const VERSION = typeof "4.2.0-alpha.6" !== 'undefined' ? "4.2.0-alpha.6" : 'latest';
|
|
6
9
|
/**
|
|
7
10
|
* Shapefile loader
|
|
8
11
|
* @note Shapefile is multifile format and requires providing additional files
|
package/dist/shp-loader.d.ts
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
2
|
export declare const SHP_MAGIC_NUMBER: number[];
|
|
3
|
+
/** SHPLoader */
|
|
4
|
+
export type SHPLoaderOptions = LoaderOptions & {
|
|
5
|
+
dbf?: {
|
|
6
|
+
_maxDimensions?: number;
|
|
7
|
+
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
8
|
+
workerUrl?: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
3
11
|
/**
|
|
4
12
|
* SHP file loader
|
|
5
13
|
*/
|
|
6
|
-
export declare const SHPWorkerLoader:
|
|
14
|
+
export declare const SHPWorkerLoader: {
|
|
15
|
+
readonly dataType: unknown;
|
|
16
|
+
readonly batchType: never;
|
|
17
|
+
readonly name: "SHP";
|
|
18
|
+
readonly id: "shp";
|
|
19
|
+
readonly module: "shapefile";
|
|
20
|
+
readonly version: any;
|
|
21
|
+
readonly worker: true;
|
|
22
|
+
readonly category: "geometry";
|
|
23
|
+
readonly extensions: ["shp"];
|
|
24
|
+
readonly mimeTypes: ["application/octet-stream"];
|
|
25
|
+
readonly tests: [ArrayBufferLike];
|
|
26
|
+
readonly options: {
|
|
27
|
+
readonly shp: {
|
|
28
|
+
readonly _maxDimensions: 4;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
7
32
|
/** SHP file loader */
|
|
8
33
|
export declare const SHPLoader: LoaderWithParser;
|
|
9
34
|
//# sourceMappingURL=shp-loader.d.ts.map
|
package/dist/shp-loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shp-loader.d.ts","sourceRoot":"","sources":["../src/shp-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shp-loader.d.ts","sourceRoot":"","sources":["../src/shp-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAOtF,eAAO,MAAM,gBAAgB,UAA2B,CAAC;AAEzD,gBAAgB;AAChB,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE;QACJ,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,8EAA8E;QAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;CAmB2B,CAAC;AAExD,sBAAsB;AACtB,eAAO,MAAM,SAAS,EAAE,gBAQvB,CAAC"}
|
package/dist/shp-loader.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { parseSHP, parseSHPInBatches } from "./lib/parsers/parse-shp.js";
|
|
2
5
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
3
6
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
4
|
-
const VERSION = typeof "4.2.0-alpha.
|
|
7
|
+
const VERSION = typeof "4.2.0-alpha.6" !== 'undefined' ? "4.2.0-alpha.6" : 'latest';
|
|
5
8
|
export const SHP_MAGIC_NUMBER = [0x00, 0x00, 0x27, 0x0a];
|
|
6
9
|
/**
|
|
7
10
|
* SHP file loader
|
|
8
11
|
*/
|
|
9
12
|
export const SHPWorkerLoader = {
|
|
13
|
+
dataType: null,
|
|
14
|
+
batchType: null,
|
|
10
15
|
name: 'SHP',
|
|
11
16
|
id: 'shp',
|
|
12
17
|
module: 'shapefile',
|
package/dist/shp-worker.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
(() => {
|
|
3
3
|
// src/lib/streaming/binary-chunk-reader.ts
|
|
4
4
|
var BinaryChunkReader = class {
|
|
5
|
+
offset;
|
|
6
|
+
arrayBuffers;
|
|
7
|
+
ended;
|
|
8
|
+
maxRewindBytes;
|
|
5
9
|
constructor(options) {
|
|
6
10
|
const { maxRewindBytes = 0 } = options || {};
|
|
7
11
|
this.offset = 0;
|
|
@@ -359,21 +363,21 @@
|
|
|
359
363
|
ERROR: 3
|
|
360
364
|
};
|
|
361
365
|
var SHPParser = class {
|
|
366
|
+
options = {};
|
|
367
|
+
binaryReader = new BinaryChunkReader({ maxRewindBytes: SHP_RECORD_HEADER_SIZE });
|
|
368
|
+
state = STATE.EXPECTING_HEADER;
|
|
369
|
+
result = {
|
|
370
|
+
geometries: [],
|
|
371
|
+
// Initialize with number values to make TS happy
|
|
372
|
+
// These are initialized for real in STATE.EXPECTING_HEADER
|
|
373
|
+
progress: {
|
|
374
|
+
bytesTotal: NaN,
|
|
375
|
+
bytesUsed: NaN,
|
|
376
|
+
rows: NaN
|
|
377
|
+
},
|
|
378
|
+
currentIndex: NaN
|
|
379
|
+
};
|
|
362
380
|
constructor(options) {
|
|
363
|
-
this.options = {};
|
|
364
|
-
this.binaryReader = new BinaryChunkReader({ maxRewindBytes: SHP_RECORD_HEADER_SIZE });
|
|
365
|
-
this.state = STATE.EXPECTING_HEADER;
|
|
366
|
-
this.result = {
|
|
367
|
-
geometries: [],
|
|
368
|
-
// Initialize with number values to make TS happy
|
|
369
|
-
// These are initialized for real in STATE.EXPECTING_HEADER
|
|
370
|
-
progress: {
|
|
371
|
-
bytesTotal: NaN,
|
|
372
|
-
bytesUsed: NaN,
|
|
373
|
-
rows: NaN
|
|
374
|
-
},
|
|
375
|
-
currentIndex: NaN
|
|
376
|
-
};
|
|
377
381
|
this.options = options;
|
|
378
382
|
}
|
|
379
383
|
write(arrayBuffer) {
|
|
@@ -480,9 +484,11 @@
|
|
|
480
484
|
}
|
|
481
485
|
|
|
482
486
|
// src/shp-loader.ts
|
|
483
|
-
var VERSION = true ? "4.2.0-alpha.
|
|
487
|
+
var VERSION = true ? "4.2.0-alpha.6" : "latest";
|
|
484
488
|
var SHP_MAGIC_NUMBER2 = [0, 0, 39, 10];
|
|
485
489
|
var SHPWorkerLoader = {
|
|
490
|
+
dataType: null,
|
|
491
|
+
batchType: null,
|
|
486
492
|
name: "SHP",
|
|
487
493
|
id: "shp",
|
|
488
494
|
module: "shapefile",
|
|
@@ -565,7 +571,9 @@
|
|
|
565
571
|
}
|
|
566
572
|
getParentPort().then((parentPort2) => {
|
|
567
573
|
if (parentPort2) {
|
|
568
|
-
parentPort2.on("message",
|
|
574
|
+
parentPort2.on("message", (message) => {
|
|
575
|
+
handleMessage(message);
|
|
576
|
+
});
|
|
569
577
|
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
570
578
|
} else {
|
|
571
579
|
globalThis.onmessage = handleMessage;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/shapefile",
|
|
3
3
|
"description": "Loader for the Shapefile Format",
|
|
4
|
-
"version": "4.2.0-
|
|
4
|
+
"version": "4.2.0-beta.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"publishConfig": {
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
"build-worker-dbf": "esbuild src/workers/dbf-worker.ts --bundle --outfile=dist/dbf-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@loaders.gl/gis": "4.2.0-
|
|
49
|
-
"@loaders.gl/loader-utils": "4.2.0-
|
|
50
|
-
"@loaders.gl/schema": "4.2.0-
|
|
48
|
+
"@loaders.gl/gis": "4.2.0-beta.1",
|
|
49
|
+
"@loaders.gl/loader-utils": "4.2.0-beta.1",
|
|
50
|
+
"@loaders.gl/schema": "4.2.0-beta.1",
|
|
51
51
|
"@math.gl/proj4": "^4.0.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@loaders.gl/core": "^4.0.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "c386a9196516fe3ff24847b40e6c77be039cf905"
|
|
57
57
|
}
|
package/src/dbf-loader.ts
CHANGED
|
@@ -1,15 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Loader, LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
2
6
|
import {parseDBF, parseDBFInBatches} from './lib/parsers/parse-dbf';
|
|
3
7
|
|
|
4
8
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
5
9
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
6
10
|
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
7
11
|
|
|
12
|
+
export type DBFLoaderOptions = LoaderOptions & {
|
|
13
|
+
dbf?: {
|
|
14
|
+
encoding?: string;
|
|
15
|
+
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
16
|
+
workerUrl?: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
8
20
|
/**
|
|
9
21
|
* DBFLoader - DBF files are used to contain non-geometry columns in Shapefiles
|
|
10
22
|
*/
|
|
11
|
-
export const DBFWorkerLoader
|
|
23
|
+
export const DBFWorkerLoader = {
|
|
12
24
|
name: 'DBF',
|
|
25
|
+
dataType: null as unknown,
|
|
26
|
+
batchType: null as never,
|
|
27
|
+
|
|
13
28
|
id: 'dbf',
|
|
14
29
|
module: 'shapefile',
|
|
15
30
|
version: VERSION,
|
|
@@ -22,7 +37,7 @@ export const DBFWorkerLoader: Loader = {
|
|
|
22
37
|
encoding: 'latin1'
|
|
23
38
|
}
|
|
24
39
|
}
|
|
25
|
-
}
|
|
40
|
+
} as const satisfies Loader<any, any, DBFLoaderOptions>;
|
|
26
41
|
|
|
27
42
|
/** DBF file loader */
|
|
28
43
|
export const DBFLoader: LoaderWithParser = {
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export type {ShapefileLoaderOptions} from './shapefile-loader';
|
|
1
6
|
export {ShapefileLoader} from './shapefile-loader';
|
|
7
|
+
|
|
8
|
+
export type {DBFLoaderOptions} from './dbf-loader';
|
|
2
9
|
export {DBFLoader, DBFWorkerLoader} from './dbf-loader';
|
|
10
|
+
|
|
11
|
+
export type {SHPLoaderOptions} from './shp-loader';
|
|
3
12
|
export {SHPLoader, SHPWorkerLoader} from './shp-loader';
|
|
4
13
|
|
|
5
14
|
// EXPERIMENTAL
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
// import type {Feature} from '@loaders.gl/gis';
|
|
2
6
|
import {LoaderContext, parseInBatchesFromContext, parseFromContext} from '@loaders.gl/loader-utils';
|
|
3
7
|
import {binaryToGeometry, transformGeoJsonCoords} from '@loaders.gl/gis';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import type {BinaryGeometry} from '@loaders.gl/schema';
|
|
2
6
|
import {BinaryChunkReader} from '../streaming/binary-chunk-reader';
|
|
3
7
|
import {parseSHPHeader, SHPHeader} from './parse-shp-header';
|
package/src/lib/parsers/types.ts
CHANGED
package/src/shapefile-loader.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import type {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
2
6
|
import {SHP_MAGIC_NUMBER} from './shp-loader';
|
|
3
7
|
import {parseShapefile, parseShapefileInBatches} from './lib/parsers/parse-shapefile';
|
|
@@ -10,6 +14,8 @@ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
|
10
14
|
export type ShapefileLoaderOptions = LoaderOptions & {
|
|
11
15
|
shapefile?: {
|
|
12
16
|
shape?: 'geojson-table' | 'v3';
|
|
17
|
+
/** @deprecated Worker URLs must be specified with .dbf.workerUrl * .shp.workerUrl */
|
|
18
|
+
workerUrl?: never;
|
|
13
19
|
};
|
|
14
20
|
};
|
|
15
21
|
|
|
@@ -17,7 +23,7 @@ export type ShapefileLoaderOptions = LoaderOptions & {
|
|
|
17
23
|
* Shapefile loader
|
|
18
24
|
* @note Shapefile is multifile format and requires providing additional files
|
|
19
25
|
*/
|
|
20
|
-
export const ShapefileLoader
|
|
26
|
+
export const ShapefileLoader = {
|
|
21
27
|
name: 'Shapefile',
|
|
22
28
|
id: 'shapefile',
|
|
23
29
|
module: 'shapefile',
|
|
@@ -38,4 +44,4 @@ export const ShapefileLoader: LoaderWithParser<GeoJSONTable, Batch, ShapefileLoa
|
|
|
38
44
|
parse: parseShapefile,
|
|
39
45
|
// @ts-expect-error
|
|
40
46
|
parseInBatches: parseShapefileInBatches
|
|
41
|
-
}
|
|
47
|
+
} as const satisfies LoaderWithParser<GeoJSONTable, Batch, ShapefileLoaderOptions>;
|
package/src/shp-loader.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Loader, LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
2
6
|
import {parseSHP, parseSHPInBatches} from './lib/parsers/parse-shp';
|
|
3
7
|
|
|
4
8
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
@@ -7,10 +11,22 @@ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
|
7
11
|
|
|
8
12
|
export const SHP_MAGIC_NUMBER = [0x00, 0x00, 0x27, 0x0a];
|
|
9
13
|
|
|
14
|
+
/** SHPLoader */
|
|
15
|
+
export type SHPLoaderOptions = LoaderOptions & {
|
|
16
|
+
dbf?: {
|
|
17
|
+
_maxDimensions?: number;
|
|
18
|
+
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
|
|
19
|
+
workerUrl?: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
10
23
|
/**
|
|
11
24
|
* SHP file loader
|
|
12
25
|
*/
|
|
13
|
-
export const SHPWorkerLoader
|
|
26
|
+
export const SHPWorkerLoader = {
|
|
27
|
+
dataType: null as unknown,
|
|
28
|
+
batchType: null as never,
|
|
29
|
+
|
|
14
30
|
name: 'SHP',
|
|
15
31
|
id: 'shp',
|
|
16
32
|
module: 'shapefile',
|
|
@@ -26,7 +42,7 @@ export const SHPWorkerLoader: Loader = {
|
|
|
26
42
|
_maxDimensions: 4
|
|
27
43
|
}
|
|
28
44
|
}
|
|
29
|
-
}
|
|
45
|
+
} as const satisfies Loader<any, any, SHPLoaderOptions>;
|
|
30
46
|
|
|
31
47
|
/** SHP file loader */
|
|
32
48
|
export const SHPLoader: LoaderWithParser = {
|