@loaders.gl/core 5.0.0-alpha.12 → 5.0.0-alpha.13
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 +1 -1
- package/SCHEMA-README.md +9 -0
- package/SCHEMA-UTILS-README.md +11 -0
- package/dist/dist.dev.js +163 -142
- package/dist/dist.min.js +3 -3
- package/dist/index.cjs +87 -91
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/iterators/make-iterator/make-iterator.js +1 -1
- package/dist/iterators/make-iterator/make-iterator.js.map +1 -1
- package/dist/iterators/make-iterator/make-stream-iterator.js +1 -1
- package/dist/iterators/make-iterator/make-stream-iterator.js.map +1 -1
- package/dist/iterators/make-iterator/make-string-iterator.js +1 -1
- package/dist/iterators/make-iterator/make-string-iterator.js.map +1 -1
- package/dist/lib/api/core-api.d.ts +1 -1
- package/dist/lib/api/core-api.d.ts.map +1 -1
- package/dist/lib/api/create-data-source.d.ts +1 -1
- package/dist/lib/api/create-data-source.d.ts.map +1 -1
- package/dist/lib/api/create-data-source.js +1 -1
- package/dist/lib/api/create-data-source.js.map +1 -1
- package/dist/lib/api/encode-table.d.ts +2 -2
- package/dist/lib/api/encode-table.d.ts.map +1 -1
- package/dist/lib/api/encode-table.js +1 -1
- package/dist/lib/api/encode-table.js.map +1 -1
- package/dist/lib/api/encode.d.ts +1 -1
- package/dist/lib/api/encode.d.ts.map +1 -1
- package/dist/lib/api/encode.js +2 -2
- package/dist/lib/api/encode.js.map +1 -1
- package/dist/lib/api/load-in-batches.d.ts +1 -1
- package/dist/lib/api/load-in-batches.d.ts.map +1 -1
- package/dist/lib/api/load-in-batches.js +1 -1
- package/dist/lib/api/load-in-batches.js.map +1 -1
- package/dist/lib/api/load-loader.d.ts +1 -1
- package/dist/lib/api/load-loader.d.ts.map +1 -1
- package/dist/lib/api/load-loader.js +1 -1
- package/dist/lib/api/load-loader.js.map +1 -1
- package/dist/lib/api/load.d.ts +1 -1
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +1 -1
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts +1 -1
- package/dist/lib/api/parse-file.d.ts.map +1 -1
- package/dist/lib/api/parse-file.js +2 -2
- package/dist/lib/api/parse-file.js.map +1 -1
- package/dist/lib/api/parse-in-batches.d.ts +1 -1
- package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
- package/dist/lib/api/parse-in-batches.js +40 -4
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse-sync.d.ts +1 -1
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +1 -1
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.d.ts +1 -1
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +3 -3
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/api/preload.d.ts +1 -1
- package/dist/lib/api/preload.d.ts.map +1 -1
- package/dist/lib/api/preload.js.map +1 -1
- package/dist/lib/api/register-loaders.d.ts +1 -1
- package/dist/lib/api/register-loaders.d.ts.map +1 -1
- package/dist/lib/api/select-loader.d.ts +1 -1
- package/dist/lib/api/select-loader.d.ts.map +1 -1
- package/dist/lib/api/select-loader.js +1 -1
- package/dist/lib/api/select-loader.js.map +1 -1
- package/dist/lib/api/select-source.d.ts +1 -1
- package/dist/lib/api/select-source.d.ts.map +1 -1
- package/dist/lib/common.d.ts +1 -1
- package/dist/lib/common.d.ts.map +1 -1
- package/dist/lib/fetch/fetch-file.js +2 -2
- package/dist/lib/fetch/fetch-file.js.map +1 -1
- package/dist/lib/filesystems/browser-filesystem.d.ts +1 -1
- package/dist/lib/filesystems/browser-filesystem.d.ts.map +1 -1
- package/dist/lib/filesystems/browser-filesystem.js +1 -1
- package/dist/lib/filesystems/browser-filesystem.js.map +1 -1
- package/dist/lib/init.js +2 -2
- package/dist/lib/init.js.map +1 -1
- package/dist/lib/loader-utils/get-data.d.ts +1 -1
- package/dist/lib/loader-utils/get-data.d.ts.map +1 -1
- package/dist/lib/loader-utils/get-data.js +1 -1
- package/dist/lib/loader-utils/get-data.js.map +1 -1
- package/dist/lib/loader-utils/get-fetch-function.d.ts +1 -1
- package/dist/lib/loader-utils/get-fetch-function.d.ts.map +1 -1
- package/dist/lib/loader-utils/get-fetch-function.js +1 -1
- package/dist/lib/loader-utils/get-fetch-function.js.map +1 -1
- package/dist/lib/loader-utils/loader-context.d.ts +1 -1
- package/dist/lib/loader-utils/loader-context.d.ts.map +1 -1
- package/dist/lib/loader-utils/loader-context.js +1 -1
- package/dist/lib/loader-utils/loader-context.js.map +1 -1
- package/dist/lib/loader-utils/loggers.d.ts +1 -1
- package/dist/lib/loader-utils/loggers.d.ts.map +1 -1
- package/dist/lib/loader-utils/loggers.js +1 -1
- package/dist/lib/loader-utils/loggers.js.map +1 -1
- package/dist/lib/loader-utils/normalize-loader.d.ts +1 -1
- package/dist/lib/loader-utils/normalize-loader.d.ts.map +1 -1
- package/dist/lib/loader-utils/normalize-loader.js +1 -1
- package/dist/lib/loader-utils/normalize-loader.js.map +1 -1
- package/dist/lib/loader-utils/option-defaults.d.ts +1 -1
- package/dist/lib/loader-utils/option-defaults.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-defaults.js +1 -1
- package/dist/lib/loader-utils/option-defaults.js.map +1 -1
- package/dist/lib/loader-utils/option-utils.d.ts +1 -1
- package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-utils.js +1 -1
- package/dist/lib/loader-utils/option-utils.js.map +1 -1
- package/dist/lib/utils/resource-utils.js +1 -1
- package/dist/lib/utils/resource-utils.js.map +1 -1
- package/dist/lib/utils/response-utils.js +1 -1
- package/dist/lib/utils/response-utils.js.map +1 -1
- package/dist/loader-utils/format-types.d.ts +32 -0
- package/dist/loader-utils/format-types.d.ts.map +1 -0
- package/dist/loader-utils/format-types.js +5 -0
- package/dist/loader-utils/format-types.js.map +1 -0
- package/dist/loader-utils/index.cjs +12416 -0
- package/dist/loader-utils/index.cjs.map +6 -0
- package/dist/loader-utils/index.d.ts +122 -0
- package/dist/loader-utils/index.d.ts.map +1 -0
- package/dist/loader-utils/index.js +91 -0
- package/dist/loader-utils/index.js.map +1 -0
- package/dist/loader-utils/json-loader.d.ts +27 -0
- package/dist/loader-utils/json-loader.d.ts.map +1 -0
- package/dist/loader-utils/json-loader.js +32 -0
- package/dist/loader-utils/json-loader.js.map +1 -0
- package/dist/loader-utils/lib/binary-utils/array-buffer-utils.d.ts +32 -0
- package/dist/loader-utils/lib/binary-utils/array-buffer-utils.d.ts.map +1 -0
- package/dist/loader-utils/lib/binary-utils/array-buffer-utils.js +88 -0
- package/dist/loader-utils/lib/binary-utils/array-buffer-utils.js.map +1 -0
- package/dist/loader-utils/lib/binary-utils/binary-chunk-reader.d.ts +67 -0
- package/dist/loader-utils/lib/binary-utils/binary-chunk-reader.d.ts.map +1 -0
- package/dist/loader-utils/lib/binary-utils/binary-chunk-reader.js +245 -0
- package/dist/loader-utils/lib/binary-utils/binary-chunk-reader.js.map +1 -0
- package/dist/loader-utils/lib/binary-utils/dataview-copy-utils.d.ts +43 -0
- package/dist/loader-utils/lib/binary-utils/dataview-copy-utils.d.ts.map +1 -0
- package/dist/loader-utils/lib/binary-utils/dataview-copy-utils.js +92 -0
- package/dist/loader-utils/lib/binary-utils/dataview-copy-utils.js.map +1 -0
- package/dist/loader-utils/lib/binary-utils/encode-array-buffer-to-base64.d.ts +3 -0
- package/dist/loader-utils/lib/binary-utils/encode-array-buffer-to-base64.d.ts.map +1 -0
- package/dist/loader-utils/lib/binary-utils/encode-array-buffer-to-base64.js +15 -0
- package/dist/loader-utils/lib/binary-utils/encode-array-buffer-to-base64.js.map +1 -0
- package/dist/loader-utils/lib/binary-utils/get-first-characters.d.ts +17 -0
- package/dist/loader-utils/lib/binary-utils/get-first-characters.d.ts.map +1 -0
- package/dist/loader-utils/lib/binary-utils/get-first-characters.js +43 -0
- package/dist/loader-utils/lib/binary-utils/get-first-characters.js.map +1 -0
- package/dist/loader-utils/lib/binary-utils/hex-transcoder.d.ts +15 -0
- package/dist/loader-utils/lib/binary-utils/hex-transcoder.d.ts.map +1 -0
- package/dist/loader-utils/lib/binary-utils/hex-transcoder.js +51 -0
- package/dist/loader-utils/lib/binary-utils/hex-transcoder.js.map +1 -0
- package/dist/loader-utils/lib/binary-utils/memory-conversion-utils.d.ts +20 -0
- package/dist/loader-utils/lib/binary-utils/memory-conversion-utils.d.ts.map +1 -0
- package/dist/loader-utils/lib/binary-utils/memory-conversion-utils.js +82 -0
- package/dist/loader-utils/lib/binary-utils/memory-conversion-utils.js.map +1 -0
- package/dist/loader-utils/lib/binary-utils/memory-copy-utils.d.ts +25 -0
- package/dist/loader-utils/lib/binary-utils/memory-copy-utils.d.ts.map +1 -0
- package/dist/loader-utils/lib/binary-utils/memory-copy-utils.js +59 -0
- package/dist/loader-utils/lib/binary-utils/memory-copy-utils.js.map +1 -0
- package/dist/loader-utils/lib/crs/crs-reprojection.d.ts +31 -0
- package/dist/loader-utils/lib/crs/crs-reprojection.d.ts.map +1 -0
- package/dist/loader-utils/lib/crs/crs-reprojection.js +20 -0
- package/dist/loader-utils/lib/crs/crs-reprojection.js.map +1 -0
- package/dist/loader-utils/lib/env-utils/assert.d.ts +6 -0
- package/dist/loader-utils/lib/env-utils/assert.d.ts.map +1 -0
- package/dist/loader-utils/lib/env-utils/assert.js +13 -0
- package/dist/loader-utils/lib/env-utils/assert.js.map +1 -0
- package/dist/loader-utils/lib/env-utils/globals.d.ts +15 -0
- package/dist/loader-utils/lib/env-utils/globals.d.ts.map +1 -0
- package/dist/loader-utils/lib/env-utils/globals.js +28 -0
- package/dist/loader-utils/lib/env-utils/globals.js.map +1 -0
- package/dist/loader-utils/lib/file-provider/data-view-file.d.ts +40 -0
- package/dist/loader-utils/lib/file-provider/data-view-file.d.ts.map +1 -0
- package/dist/loader-utils/lib/file-provider/data-view-file.js +68 -0
- package/dist/loader-utils/lib/file-provider/data-view-file.js.map +1 -0
- package/dist/loader-utils/lib/file-provider/file-handle-file.d.ts +54 -0
- package/dist/loader-utils/lib/file-provider/file-handle-file.d.ts.map +1 -0
- package/dist/loader-utils/lib/file-provider/file-handle-file.js +102 -0
- package/dist/loader-utils/lib/file-provider/file-handle-file.js.map +1 -0
- package/dist/loader-utils/lib/file-provider/file-provider-interface.d.ts +45 -0
- package/dist/loader-utils/lib/file-provider/file-provider-interface.d.ts.map +1 -0
- package/dist/loader-utils/lib/file-provider/file-provider-interface.js +13 -0
- package/dist/loader-utils/lib/file-provider/file-provider-interface.js.map +1 -0
- package/dist/loader-utils/lib/file-provider/file-provider.d.ts +57 -0
- package/dist/loader-utils/lib/file-provider/file-provider.d.ts.map +1 -0
- package/dist/loader-utils/lib/file-provider/file-provider.js +114 -0
- package/dist/loader-utils/lib/file-provider/file-provider.js.map +1 -0
- package/dist/loader-utils/lib/files/array-buffer-file.d.ts +21 -0
- package/dist/loader-utils/lib/files/array-buffer-file.d.ts.map +1 -0
- package/dist/loader-utils/lib/files/array-buffer-file.js +36 -0
- package/dist/loader-utils/lib/files/array-buffer-file.js.map +1 -0
- package/dist/loader-utils/lib/files/blob-file.d.ts +19 -0
- package/dist/loader-utils/lib/files/blob-file.d.ts.map +1 -0
- package/dist/loader-utils/lib/files/blob-file.js +39 -0
- package/dist/loader-utils/lib/files/blob-file.js.map +1 -0
- package/dist/loader-utils/lib/files/file.d.ts +33 -0
- package/dist/loader-utils/lib/files/file.d.ts.map +1 -0
- package/dist/loader-utils/lib/files/file.js +5 -0
- package/dist/loader-utils/lib/files/file.js.map +1 -0
- package/dist/loader-utils/lib/files/http-file-transport.d.ts +37 -0
- package/dist/loader-utils/lib/files/http-file-transport.d.ts.map +1 -0
- package/dist/loader-utils/lib/files/http-file-transport.js +290 -0
- package/dist/loader-utils/lib/files/http-file-transport.js.map +1 -0
- package/dist/loader-utils/lib/files/http-file-types.d.ts +49 -0
- package/dist/loader-utils/lib/files/http-file-types.d.ts.map +1 -0
- package/dist/loader-utils/lib/files/http-file-types.js +5 -0
- package/dist/loader-utils/lib/files/http-file-types.js.map +1 -0
- package/dist/loader-utils/lib/files/http-file.d.ts +55 -0
- package/dist/loader-utils/lib/files/http-file.d.ts.map +1 -0
- package/dist/loader-utils/lib/files/http-file.js +213 -0
- package/dist/loader-utils/lib/files/http-file.js.map +1 -0
- package/dist/loader-utils/lib/files/node-file-facade.d.ts +22 -0
- package/dist/loader-utils/lib/files/node-file-facade.d.ts.map +1 -0
- package/dist/loader-utils/lib/files/node-file-facade.js +45 -0
- package/dist/loader-utils/lib/files/node-file-facade.js.map +1 -0
- package/dist/loader-utils/lib/files/sources.d.ts +1 -0
- package/dist/loader-utils/lib/files/sources.d.ts.map +1 -0
- package/dist/loader-utils/lib/files/sources.js +155 -0
- package/dist/loader-utils/lib/files/sources.js.map +1 -0
- package/dist/loader-utils/lib/filesystems/filesystem.d.ts +33 -0
- package/dist/loader-utils/lib/filesystems/filesystem.d.ts.map +1 -0
- package/dist/loader-utils/lib/filesystems/filesystem.js +5 -0
- package/dist/loader-utils/lib/filesystems/filesystem.js.map +1 -0
- package/dist/loader-utils/lib/filesystems/node-filesystem-facade.d.ts +23 -0
- package/dist/loader-utils/lib/filesystems/node-filesystem-facade.d.ts.map +1 -0
- package/dist/loader-utils/lib/filesystems/node-filesystem-facade.js +48 -0
- package/dist/loader-utils/lib/filesystems/node-filesystem-facade.js.map +1 -0
- package/dist/loader-utils/lib/iterators/async-iteration.d.ts +20 -0
- package/dist/loader-utils/lib/iterators/async-iteration.d.ts.map +1 -0
- package/dist/loader-utils/lib/iterators/async-iteration.js +102 -0
- package/dist/loader-utils/lib/iterators/async-iteration.js.map +1 -0
- package/dist/loader-utils/lib/iterators/text-iterators.d.ts +19 -0
- package/dist/loader-utils/lib/iterators/text-iterators.d.ts.map +1 -0
- package/dist/loader-utils/lib/iterators/text-iterators.js +60 -0
- package/dist/loader-utils/lib/iterators/text-iterators.js.map +1 -0
- package/dist/loader-utils/lib/javascript-utils/is-type.d.ts +59 -0
- package/dist/loader-utils/lib/javascript-utils/is-type.d.ts.map +1 -0
- package/dist/loader-utils/lib/javascript-utils/is-type.js +68 -0
- package/dist/loader-utils/lib/javascript-utils/is-type.js.map +1 -0
- package/dist/loader-utils/lib/laz/laz-arithmetic-encoder.d.ts +118 -0
- package/dist/loader-utils/lib/laz/laz-arithmetic-encoder.d.ts.map +1 -0
- package/dist/loader-utils/lib/laz/laz-arithmetic-encoder.js +427 -0
- package/dist/loader-utils/lib/laz/laz-arithmetic-encoder.js.map +1 -0
- package/dist/loader-utils/lib/laz/laz-chunk-decoder.d.ts +204 -0
- package/dist/loader-utils/lib/laz/laz-chunk-decoder.d.ts.map +1 -0
- package/dist/loader-utils/lib/laz/laz-chunk-decoder.js +4226 -0
- package/dist/loader-utils/lib/laz/laz-chunk-decoder.js.map +1 -0
- package/dist/loader-utils/lib/laz/laz-chunk-encoder.d.ts +40 -0
- package/dist/loader-utils/lib/laz/laz-chunk-encoder.d.ts.map +1 -0
- package/dist/loader-utils/lib/laz/laz-chunk-encoder.js +1518 -0
- package/dist/loader-utils/lib/laz/laz-chunk-encoder.js.map +1 -0
- package/dist/loader-utils/lib/log-utils/log.d.ts +4 -0
- package/dist/loader-utils/lib/log-utils/log.d.ts.map +1 -0
- package/dist/loader-utils/lib/log-utils/log.js +21 -0
- package/dist/loader-utils/lib/log-utils/log.js.map +1 -0
- package/dist/loader-utils/lib/module-utils/initialize-wasm-module.d.ts +10 -0
- package/dist/loader-utils/lib/module-utils/initialize-wasm-module.d.ts.map +1 -0
- package/dist/loader-utils/lib/module-utils/initialize-wasm-module.js +44 -0
- package/dist/loader-utils/lib/module-utils/initialize-wasm-module.js.map +1 -0
- package/dist/loader-utils/lib/module-utils/js-module-utils.d.ts +18 -0
- package/dist/loader-utils/lib/module-utils/js-module-utils.d.ts.map +1 -0
- package/dist/loader-utils/lib/module-utils/js-module-utils.js +40 -0
- package/dist/loader-utils/lib/module-utils/js-module-utils.js.map +1 -0
- package/dist/loader-utils/lib/node/buffer.browser.d.ts +11 -0
- package/dist/loader-utils/lib/node/buffer.browser.d.ts.map +1 -0
- package/dist/loader-utils/lib/node/buffer.browser.js +20 -0
- package/dist/loader-utils/lib/node/buffer.browser.js.map +1 -0
- package/dist/loader-utils/lib/node/buffer.d.ts +11 -0
- package/dist/loader-utils/lib/node/buffer.d.ts.map +1 -0
- package/dist/loader-utils/lib/node/buffer.js +35 -0
- package/dist/loader-utils/lib/node/buffer.js.map +1 -0
- package/dist/loader-utils/lib/node/fs.browser.d.ts +2 -0
- package/dist/loader-utils/lib/node/fs.browser.d.ts.map +1 -0
- package/dist/loader-utils/lib/node/fs.browser.js +5 -0
- package/dist/loader-utils/lib/node/fs.browser.js.map +1 -0
- package/dist/loader-utils/lib/node/promisify.d.ts +13 -0
- package/dist/loader-utils/lib/node/promisify.d.ts.map +1 -0
- package/dist/loader-utils/lib/node/promisify.js +19 -0
- package/dist/loader-utils/lib/node/promisify.js.map +1 -0
- package/dist/loader-utils/lib/node/stream.browser.d.ts +2 -0
- package/dist/loader-utils/lib/node/stream.browser.d.ts.map +1 -0
- package/dist/loader-utils/lib/node/stream.browser.js +5 -0
- package/dist/loader-utils/lib/node/stream.browser.js.map +1 -0
- package/dist/loader-utils/lib/node/stream.d.ts +6 -0
- package/dist/loader-utils/lib/node/stream.d.ts.map +1 -0
- package/dist/loader-utils/lib/node/stream.js +8 -0
- package/dist/loader-utils/lib/node/stream.js.map +1 -0
- package/dist/loader-utils/lib/option-utils/merge-options.d.ts +12 -0
- package/dist/loader-utils/lib/option-utils/merge-options.d.ts.map +1 -0
- package/dist/loader-utils/lib/option-utils/merge-options.js +34 -0
- package/dist/loader-utils/lib/option-utils/merge-options.js.map +1 -0
- package/dist/loader-utils/lib/parser-utils/parse-json.d.ts +5 -0
- package/dist/loader-utils/lib/parser-utils/parse-json.d.ts.map +1 -0
- package/dist/loader-utils/lib/parser-utils/parse-json.js +16 -0
- package/dist/loader-utils/lib/parser-utils/parse-json.js.map +1 -0
- package/dist/loader-utils/lib/path-utils/cached-uri-resolver.d.ts +35 -0
- package/dist/loader-utils/lib/path-utils/cached-uri-resolver.d.ts.map +1 -0
- package/dist/loader-utils/lib/path-utils/cached-uri-resolver.js +64 -0
- package/dist/loader-utils/lib/path-utils/cached-uri-resolver.js.map +1 -0
- package/dist/loader-utils/lib/path-utils/file-aliases.d.ts +17 -0
- package/dist/loader-utils/lib/path-utils/file-aliases.d.ts.map +1 -0
- package/dist/loader-utils/lib/path-utils/file-aliases.js +44 -0
- package/dist/loader-utils/lib/path-utils/file-aliases.js.map +1 -0
- package/dist/loader-utils/lib/path-utils/get-cwd.d.ts +3 -0
- package/dist/loader-utils/lib/path-utils/get-cwd.d.ts.map +1 -0
- package/dist/loader-utils/lib/path-utils/get-cwd.js +12 -0
- package/dist/loader-utils/lib/path-utils/get-cwd.js.map +1 -0
- package/dist/loader-utils/lib/path-utils/path.d.ts +24 -0
- package/dist/loader-utils/lib/path-utils/path.d.ts.map +1 -0
- package/dist/loader-utils/lib/path-utils/path.js +173 -0
- package/dist/loader-utils/lib/path-utils/path.js.map +1 -0
- package/dist/loader-utils/lib/request-utils/abort-utils.d.ts +5 -0
- package/dist/loader-utils/lib/request-utils/abort-utils.d.ts.map +1 -0
- package/dist/loader-utils/lib/request-utils/abort-utils.js +59 -0
- package/dist/loader-utils/lib/request-utils/abort-utils.js.map +1 -0
- package/dist/loader-utils/lib/request-utils/authentication.d.ts +56 -0
- package/dist/loader-utils/lib/request-utils/authentication.d.ts.map +1 -0
- package/dist/loader-utils/lib/request-utils/authentication.js +67 -0
- package/dist/loader-utils/lib/request-utils/authentication.js.map +1 -0
- package/dist/loader-utils/lib/request-utils/parse-content-type.d.ts +7 -0
- package/dist/loader-utils/lib/request-utils/parse-content-type.d.ts.map +1 -0
- package/dist/loader-utils/lib/request-utils/parse-content-type.js +20 -0
- package/dist/loader-utils/lib/request-utils/parse-content-type.js.map +1 -0
- package/dist/loader-utils/lib/request-utils/range-request-cache.d.ts +70 -0
- package/dist/loader-utils/lib/request-utils/range-request-cache.d.ts.map +1 -0
- package/dist/loader-utils/lib/request-utils/range-request-cache.js +203 -0
- package/dist/loader-utils/lib/request-utils/range-request-cache.js.map +1 -0
- package/dist/loader-utils/lib/request-utils/range-request-scheduler.d.ts +201 -0
- package/dist/loader-utils/lib/request-utils/range-request-scheduler.d.ts.map +1 -0
- package/dist/loader-utils/lib/request-utils/range-request-scheduler.js +636 -0
- package/dist/loader-utils/lib/request-utils/range-request-scheduler.js.map +1 -0
- package/dist/loader-utils/lib/request-utils/request-cache.d.ts +62 -0
- package/dist/loader-utils/lib/request-utils/request-cache.d.ts.map +1 -0
- package/dist/loader-utils/lib/request-utils/request-cache.js +236 -0
- package/dist/loader-utils/lib/request-utils/request-cache.js.map +1 -0
- package/dist/loader-utils/lib/request-utils/request-credentials.d.ts +137 -0
- package/dist/loader-utils/lib/request-utils/request-credentials.d.ts.map +1 -0
- package/dist/loader-utils/lib/request-utils/request-credentials.js +379 -0
- package/dist/loader-utils/lib/request-utils/request-credentials.js.map +1 -0
- package/dist/loader-utils/lib/request-utils/request-scheduler.d.ts +71 -0
- package/dist/loader-utils/lib/request-utils/request-scheduler.d.ts.map +1 -0
- package/dist/loader-utils/lib/request-utils/request-scheduler.js +174 -0
- package/dist/loader-utils/lib/request-utils/request-scheduler.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.d.ts +56 -0
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.js +261 -0
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/experimental-scan-options.d.ts +42 -0
- package/dist/loader-utils/lib/scan-utils/experimental-scan-options.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/experimental-scan-options.js +5 -0
- package/dist/loader-utils/lib/scan-utils/experimental-scan-options.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/point-cloud-query.d.ts +56 -0
- package/dist/loader-utils/lib/scan-utils/point-cloud-query.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/point-cloud-query.js +86 -0
- package/dist/loader-utils/lib/scan-utils/point-cloud-query.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/raster-query.d.ts +36 -0
- package/dist/loader-utils/lib/scan-utils/raster-query.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/raster-query.js +49 -0
- package/dist/loader-utils/lib/scan-utils/raster-query.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/relational-query.d.ts +75 -0
- package/dist/loader-utils/lib/scan-utils/relational-query.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/relational-query.js +107 -0
- package/dist/loader-utils/lib/scan-utils/relational-query.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-executor.d.ts +20 -0
- package/dist/loader-utils/lib/scan-utils/scan-executor.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-executor.js +183 -0
- package/dist/loader-utils/lib/scan-utils/scan-executor.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-fragments.d.ts +23 -0
- package/dist/loader-utils/lib/scan-utils/scan-fragments.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-fragments.js +5 -0
- package/dist/loader-utils/lib/scan-utils/scan-fragments.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts +272 -0
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js +97 -0
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/table-query-explain.d.ts +39 -0
- package/dist/loader-utils/lib/scan-utils/table-query-explain.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/table-query-explain.js +35 -0
- package/dist/loader-utils/lib/scan-utils/table-query-explain.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts +77 -0
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/table-query.js +56 -0
- package/dist/loader-utils/lib/scan-utils/table-query.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +30 -0
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js +161 -0
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -0
- package/dist/loader-utils/lib/sources/catalog-source.d.ts +36 -0
- package/dist/loader-utils/lib/sources/catalog-source.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/catalog-source.js +5 -0
- package/dist/loader-utils/lib/sources/catalog-source.js.map +1 -0
- package/dist/loader-utils/lib/sources/data-source-manager.d.ts +136 -0
- package/dist/loader-utils/lib/sources/data-source-manager.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/data-source-manager.js +376 -0
- package/dist/loader-utils/lib/sources/data-source-manager.js.map +1 -0
- package/dist/loader-utils/lib/sources/data-source.d.ts +79 -0
- package/dist/loader-utils/lib/sources/data-source.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/data-source.js +145 -0
- package/dist/loader-utils/lib/sources/data-source.js.map +1 -0
- package/dist/loader-utils/lib/sources/image-source.d.ts +55 -0
- package/dist/loader-utils/lib/sources/image-source.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/image-source.js +5 -0
- package/dist/loader-utils/lib/sources/image-source.js.map +1 -0
- package/dist/loader-utils/lib/sources/image-tile-source.d.ts +12 -0
- package/dist/loader-utils/lib/sources/image-tile-source.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/image-tile-source.js +5 -0
- package/dist/loader-utils/lib/sources/image-tile-source.js.map +1 -0
- package/dist/loader-utils/lib/sources/raster-coverage.d.ts +17 -0
- package/dist/loader-utils/lib/sources/raster-coverage.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/raster-coverage.js +62 -0
- package/dist/loader-utils/lib/sources/raster-coverage.js.map +1 -0
- package/dist/loader-utils/lib/sources/raster-region.d.ts +4 -0
- package/dist/loader-utils/lib/sources/raster-region.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/raster-region.js +22 -0
- package/dist/loader-utils/lib/sources/raster-region.js.map +1 -0
- package/dist/loader-utils/lib/sources/raster-sampling.d.ts +35 -0
- package/dist/loader-utils/lib/sources/raster-sampling.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/raster-sampling.js +152 -0
- package/dist/loader-utils/lib/sources/raster-sampling.js.map +1 -0
- package/dist/loader-utils/lib/sources/raster-source.d.ts +302 -0
- package/dist/loader-utils/lib/sources/raster-source.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/raster-source.js +20 -0
- package/dist/loader-utils/lib/sources/raster-source.js.map +1 -0
- package/dist/loader-utils/lib/sources/service-capabilities.d.ts +36 -0
- package/dist/loader-utils/lib/sources/service-capabilities.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/service-capabilities.js +5 -0
- package/dist/loader-utils/lib/sources/service-capabilities.js.map +1 -0
- package/dist/loader-utils/lib/sources/tile-grid.d.ts +46 -0
- package/dist/loader-utils/lib/sources/tile-grid.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/tile-grid.js +128 -0
- package/dist/loader-utils/lib/sources/tile-grid.js.map +1 -0
- package/dist/loader-utils/lib/sources/tile-source-adapter.d.ts +24 -0
- package/dist/loader-utils/lib/sources/tile-source-adapter.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/tile-source-adapter.js +109 -0
- package/dist/loader-utils/lib/sources/tile-source-adapter.js.map +1 -0
- package/dist/loader-utils/lib/sources/tile-source-utils.d.ts +6 -0
- package/dist/loader-utils/lib/sources/tile-source-utils.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/tile-source-utils.js +13 -0
- package/dist/loader-utils/lib/sources/tile-source-utils.js.map +1 -0
- package/dist/loader-utils/lib/sources/tile-source.d.ts +190 -0
- package/dist/loader-utils/lib/sources/tile-source.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/tile-source.js +5 -0
- package/dist/loader-utils/lib/sources/tile-source.js.map +1 -0
- package/dist/loader-utils/lib/sources/utils/image-type.d.ts +10 -0
- package/dist/loader-utils/lib/sources/utils/image-type.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/utils/image-type.js +5 -0
- package/dist/loader-utils/lib/sources/utils/image-type.js.map +1 -0
- package/dist/loader-utils/lib/sources/utils/utils.d.ts +13 -0
- package/dist/loader-utils/lib/sources/utils/utils.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/utils/utils.js +26 -0
- package/dist/loader-utils/lib/sources/utils/utils.js.map +1 -0
- package/dist/loader-utils/lib/sources/vector-source.d.ts +76 -0
- package/dist/loader-utils/lib/sources/vector-source.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/vector-source.js +5 -0
- package/dist/loader-utils/lib/sources/vector-source.js.map +1 -0
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts +15 -0
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/vector-tile-source.js +5 -0
- package/dist/loader-utils/lib/sources/vector-tile-source.js.map +1 -0
- package/dist/loader-utils/lib/sources/xyz-grid.d.ts +9 -0
- package/dist/loader-utils/lib/sources/xyz-grid.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/xyz-grid.js +63 -0
- package/dist/loader-utils/lib/sources/xyz-grid.js.map +1 -0
- package/dist/loader-utils/lib/worker-loader-utils/create-loader-worker.d.ts +22 -0
- package/dist/loader-utils/lib/worker-loader-utils/create-loader-worker.d.ts.map +1 -0
- package/dist/loader-utils/lib/worker-loader-utils/create-loader-worker.js +155 -0
- package/dist/loader-utils/lib/worker-loader-utils/create-loader-worker.js.map +1 -0
- package/dist/loader-utils/lib/worker-loader-utils/encode-with-worker.d.ts +8 -0
- package/dist/loader-utils/lib/worker-loader-utils/encode-with-worker.d.ts.map +1 -0
- package/dist/loader-utils/lib/worker-loader-utils/encode-with-worker.js +23 -0
- package/dist/loader-utils/lib/worker-loader-utils/encode-with-worker.js.map +1 -0
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.d.ts +41 -0
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -0
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js +239 -0
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js.map +1 -0
- package/dist/loader-utils/loader-types.d.ts +322 -0
- package/dist/loader-utils/loader-types.d.ts.map +1 -0
- package/dist/loader-utils/loader-types.js +33 -0
- package/dist/loader-utils/loader-types.js.map +1 -0
- package/dist/loader-utils/source-types.d.ts +42 -0
- package/dist/loader-utils/source-types.d.ts.map +1 -0
- package/dist/loader-utils/source-types.js +8 -0
- package/dist/loader-utils/source-types.js.map +1 -0
- package/dist/loader-utils/types.d.ts +24 -0
- package/dist/loader-utils/types.d.ts.map +1 -0
- package/dist/loader-utils/types.js +6 -0
- package/dist/loader-utils/types.js.map +1 -0
- package/dist/loader-utils/workers/json-worker.d.ts +2 -0
- package/dist/loader-utils/workers/json-worker.d.ts.map +1 -0
- package/dist/loader-utils/workers/json-worker.js +7 -0
- package/dist/loader-utils/workers/json-worker.js.map +1 -0
- package/dist/loader-utils/writer-types.d.ts +74 -0
- package/dist/loader-utils/writer-types.d.ts.map +1 -0
- package/dist/loader-utils/writer-types.js +5 -0
- package/dist/loader-utils/writer-types.js.map +1 -0
- package/dist/null-loader.d.ts +2 -2
- package/dist/null-loader.d.ts.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +7 -7
- package/dist/null-worker.js +7 -7
- package/dist/polyfills/buffer/btoa.node.d.ts +3 -0
- package/dist/polyfills/buffer/btoa.node.d.ts.map +1 -0
- package/dist/polyfills/buffer/btoa.node.js +13 -0
- package/dist/polyfills/buffer/btoa.node.js.map +1 -0
- package/dist/polyfills/buffer/to-array-buffer.node.d.ts +2 -0
- package/dist/polyfills/buffer/to-array-buffer.node.d.ts.map +1 -0
- package/dist/polyfills/buffer/to-array-buffer.node.js +12 -0
- package/dist/polyfills/buffer/to-array-buffer.node.js.map +1 -0
- package/dist/polyfills/crypto/node-hash.d.ts +29 -0
- package/dist/polyfills/crypto/node-hash.d.ts.map +1 -0
- package/dist/polyfills/crypto/node-hash.js +63 -0
- package/dist/polyfills/crypto/node-hash.js.map +1 -0
- package/dist/polyfills/fetch/decode-data-uri.d.ts +11 -0
- package/dist/polyfills/fetch/decode-data-uri.d.ts.map +1 -0
- package/dist/polyfills/fetch/decode-data-uri.js +63 -0
- package/dist/polyfills/fetch/decode-data-uri.js.map +1 -0
- package/dist/polyfills/fetch/fetch-polyfill.d.ts +11 -0
- package/dist/polyfills/fetch/fetch-polyfill.d.ts.map +1 -0
- package/dist/polyfills/fetch/fetch-polyfill.js +141 -0
- package/dist/polyfills/fetch/fetch-polyfill.js.map +1 -0
- package/dist/polyfills/fetch/headers-polyfill.d.ts +34 -0
- package/dist/polyfills/fetch/headers-polyfill.d.ts.map +1 -0
- package/dist/polyfills/fetch/headers-polyfill.js +105 -0
- package/dist/polyfills/fetch/headers-polyfill.js.map +1 -0
- package/dist/polyfills/fetch/response-polyfill.d.ts +22 -0
- package/dist/polyfills/fetch/response-polyfill.d.ts.map +1 -0
- package/dist/polyfills/fetch/response-polyfill.js +81 -0
- package/dist/polyfills/fetch/response-polyfill.js.map +1 -0
- package/dist/polyfills/fetch/utils/decode-data-uri.node.d.ts +11 -0
- package/dist/polyfills/fetch/utils/decode-data-uri.node.d.ts.map +1 -0
- package/dist/polyfills/fetch/utils/decode-data-uri.node.js +32 -0
- package/dist/polyfills/fetch/utils/decode-data-uri.node.js.map +1 -0
- package/dist/polyfills/file/blob-stream-controller.d.ts +29 -0
- package/dist/polyfills/file/blob-stream-controller.d.ts.map +1 -0
- package/dist/polyfills/file/blob-stream-controller.js +64 -0
- package/dist/polyfills/file/blob-stream-controller.js.map +1 -0
- package/dist/polyfills/file/blob-stream.d.ts +25 -0
- package/dist/polyfills/file/blob-stream.d.ts.map +1 -0
- package/dist/polyfills/file/blob-stream.js +38 -0
- package/dist/polyfills/file/blob-stream.js.map +1 -0
- package/dist/polyfills/file/blob.d.ts +58 -0
- package/dist/polyfills/file/blob.d.ts.map +1 -0
- package/dist/polyfills/file/blob.js +166 -0
- package/dist/polyfills/file/blob.js.map +1 -0
- package/dist/polyfills/file/file-reader.d.ts +24 -0
- package/dist/polyfills/file/file-reader.d.ts.map +1 -0
- package/dist/polyfills/file/file-reader.js +51 -0
- package/dist/polyfills/file/file-reader.js.map +1 -0
- package/dist/polyfills/file/file.d.ts +24 -0
- package/dist/polyfills/file/file.d.ts.map +1 -0
- package/dist/polyfills/file/file.js +41 -0
- package/dist/polyfills/file/file.js.map +1 -0
- package/dist/polyfills/file/install-blob-polyfills.d.ts +9 -0
- package/dist/polyfills/file/install-blob-polyfills.d.ts.map +1 -0
- package/dist/polyfills/file/install-blob-polyfills.js +14 -0
- package/dist/polyfills/file/install-blob-polyfills.js.map +1 -0
- package/dist/polyfills/file/install-file-polyfills.d.ts +3 -0
- package/dist/polyfills/file/install-file-polyfills.d.ts.map +1 -0
- package/dist/polyfills/file/install-file-polyfills.js +20 -0
- package/dist/polyfills/file/install-file-polyfills.js.map +1 -0
- package/dist/polyfills/file/readable-stream.d.ts +5 -0
- package/dist/polyfills/file/readable-stream.d.ts.map +1 -0
- package/dist/polyfills/file/readable-stream.js +8 -0
- package/dist/polyfills/file/readable-stream.js.map +1 -0
- package/dist/polyfills/filesystems/fetch-node.d.ts +8 -0
- package/dist/polyfills/filesystems/fetch-node.d.ts.map +1 -0
- package/dist/polyfills/filesystems/fetch-node.js +88 -0
- package/dist/polyfills/filesystems/fetch-node.js.map +1 -0
- package/dist/polyfills/filesystems/node-file.d.ts +15 -0
- package/dist/polyfills/filesystems/node-file.d.ts.map +1 -0
- package/dist/polyfills/filesystems/node-file.js +138 -0
- package/dist/polyfills/filesystems/node-file.js.map +1 -0
- package/dist/polyfills/filesystems/node-filesystem.d.ts +19 -0
- package/dist/polyfills/filesystems/node-filesystem.d.ts.map +1 -0
- package/dist/polyfills/filesystems/node-filesystem.js +44 -0
- package/dist/polyfills/filesystems/node-filesystem.js.map +1 -0
- package/dist/polyfills/filesystems/stream-utils.node.d.ts +18 -0
- package/dist/polyfills/filesystems/stream-utils.node.d.ts.map +1 -0
- package/dist/polyfills/filesystems/stream-utils.node.js +67 -0
- package/dist/polyfills/filesystems/stream-utils.node.js.map +1 -0
- package/dist/polyfills/images/encode-image-node.d.ts +20 -0
- package/dist/polyfills/images/encode-image-node.d.ts.map +1 -0
- package/dist/polyfills/images/encode-image-node.js +37 -0
- package/dist/polyfills/images/encode-image-node.js.map +1 -0
- package/dist/polyfills/images/image-codecs-node.d.ts +8 -0
- package/dist/polyfills/images/image-codecs-node.d.ts.map +1 -0
- package/dist/polyfills/images/image-codecs-node.js +27 -0
- package/dist/polyfills/images/image-codecs-node.js.map +1 -0
- package/dist/polyfills/images/node-image-bitmap.d.ts +38 -0
- package/dist/polyfills/images/node-image-bitmap.d.ts.map +1 -0
- package/dist/polyfills/images/node-image-bitmap.js +64 -0
- package/dist/polyfills/images/node-image-bitmap.js.map +1 -0
- package/dist/polyfills/images/node-image-formats.d.ts +3 -0
- package/dist/polyfills/images/node-image-formats.d.ts.map +1 -0
- package/dist/polyfills/images/node-image-formats.js +6 -0
- package/dist/polyfills/images/node-image-formats.js.map +1 -0
- package/dist/polyfills/images/parse-image-node.d.ts +11 -0
- package/dist/polyfills/images/parse-image-node.d.ts.map +1 -0
- package/dist/polyfills/images/parse-image-node.js +36 -0
- package/dist/polyfills/images/parse-image-node.js.map +1 -0
- package/dist/polyfills/index.browser.d.ts +8 -0
- package/dist/polyfills/index.browser.d.ts.map +1 -0
- package/dist/polyfills/index.browser.js +18 -0
- package/dist/polyfills/index.browser.js.map +1 -0
- package/dist/polyfills/index.cjs +2918 -0
- package/dist/polyfills/index.cjs.map +6 -0
- package/dist/polyfills/index.d.ts +7 -0
- package/dist/polyfills/index.d.ts.map +1 -0
- package/dist/polyfills/index.js +110 -0
- package/dist/polyfills/index.js.map +1 -0
- package/dist/polyfills/libs/encoding-indexes-asian.d.ts +10 -0
- package/dist/polyfills/libs/encoding-indexes-asian.d.ts.map +1 -0
- package/dist/polyfills/libs/encoding-indexes-asian.js +14 -0
- package/dist/polyfills/libs/encoding-indexes-asian.js.map +1 -0
- package/dist/polyfills/load-library/require-utils.node.d.ts +19 -0
- package/dist/polyfills/load-library/require-utils.node.d.ts.map +1 -0
- package/dist/polyfills/load-library/require-utils.node.js +88 -0
- package/dist/polyfills/load-library/require-utils.node.js.map +1 -0
- package/dist/polyfills/streams/make-node-stream.d.ts +10 -0
- package/dist/polyfills/streams/make-node-stream.d.ts.map +1 -0
- package/dist/polyfills/streams/make-node-stream.js +70 -0
- package/dist/polyfills/streams/make-node-stream.js.map +1 -0
- package/dist/polyfills/text-encoder/encoding-indexes.d.ts +31 -0
- package/dist/polyfills/text-encoder/encoding-indexes.d.ts.map +1 -0
- package/dist/polyfills/text-encoder/encoding-indexes.js +35 -0
- package/dist/polyfills/text-encoder/encoding-indexes.js.map +1 -0
- package/dist/polyfills/text-encoder/text-encoder.d.ts +15 -0
- package/dist/polyfills/text-encoder/text-encoder.d.ts.map +1 -0
- package/dist/polyfills/text-encoder/text-encoder.js +2778 -0
- package/dist/polyfills/text-encoder/text-encoder.js.map +1 -0
- package/dist/polyfills/utils/assert.d.ts +2 -0
- package/dist/polyfills/utils/assert.d.ts.map +1 -0
- package/dist/polyfills/utils/assert.js +9 -0
- package/dist/polyfills/utils/assert.js.map +1 -0
- package/dist/polyfills/utils/buffer-utils.d.ts +5 -0
- package/dist/polyfills/utils/buffer-utils.d.ts.map +1 -0
- package/dist/polyfills/utils/buffer-utils.js +34 -0
- package/dist/polyfills/utils/buffer-utils.js.map +1 -0
- package/dist/polyfills/utils/filesystem-types.d.ts +10 -0
- package/dist/polyfills/utils/filesystem-types.d.ts.map +1 -0
- package/dist/polyfills/utils/filesystem-types.js +5 -0
- package/dist/polyfills/utils/filesystem-types.js.map +1 -0
- package/dist/polyfills/utils/is-browser.d.ts +2 -0
- package/dist/polyfills/utils/is-browser.d.ts.map +1 -0
- package/dist/polyfills/utils/is-browser.js +8 -0
- package/dist/polyfills/utils/is-browser.js.map +1 -0
- package/dist/polyfills/utils/path-utils.d.ts +7 -0
- package/dist/polyfills/utils/path-utils.d.ts.map +1 -0
- package/dist/polyfills/utils/path-utils.js +28 -0
- package/dist/polyfills/utils/path-utils.js.map +1 -0
- package/dist/schema/categories/category-gis.d.ts +7 -0
- package/dist/schema/categories/category-gis.d.ts.map +1 -0
- package/dist/schema/categories/category-gis.js +5 -0
- package/dist/schema/categories/category-gis.js.map +1 -0
- package/dist/schema/categories/category-image.d.ts +18 -0
- package/dist/schema/categories/category-image.d.ts.map +1 -0
- package/dist/schema/categories/category-image.js +5 -0
- package/dist/schema/categories/category-image.js.map +1 -0
- package/dist/schema/categories/category-mesh.d.ts +99 -0
- package/dist/schema/categories/category-mesh.d.ts.map +1 -0
- package/dist/schema/categories/category-mesh.js +14 -0
- package/dist/schema/categories/category-mesh.js.map +1 -0
- package/dist/schema/categories/category-table.d.ts +106 -0
- package/dist/schema/categories/category-table.d.ts.map +1 -0
- package/dist/schema/categories/category-table.js +5 -0
- package/dist/schema/categories/category-table.js.map +1 -0
- package/dist/schema/categories/category-texture.d.ts +115 -0
- package/dist/schema/categories/category-texture.d.ts.map +1 -0
- package/dist/schema/categories/category-texture.js +5 -0
- package/dist/schema/categories/category-texture.js.map +1 -0
- package/dist/schema/deprecated/mesh-utils.d.ts +12 -0
- package/dist/schema/deprecated/mesh-utils.d.ts.map +1 -0
- package/dist/schema/deprecated/mesh-utils.js +37 -0
- package/dist/schema/deprecated/mesh-utils.js.map +1 -0
- package/dist/schema/float16.d.ts +19 -0
- package/dist/schema/float16.d.ts.map +1 -0
- package/dist/schema/float16.js +90 -0
- package/dist/schema/float16.js.map +1 -0
- package/dist/schema/geoarrow-metadata.schema.json +117 -0
- package/dist/schema/geometry/arrow-binary-features.d.ts +45 -0
- package/dist/schema/geometry/arrow-binary-features.d.ts.map +1 -0
- package/dist/schema/geometry/arrow-binary-features.js +5 -0
- package/dist/schema/geometry/arrow-binary-features.js.map +1 -0
- package/dist/schema/geometry/binary-features.d.ts +30 -0
- package/dist/schema/geometry/binary-features.d.ts.map +1 -0
- package/dist/schema/geometry/binary-features.js +5 -0
- package/dist/schema/geometry/binary-features.js.map +1 -0
- package/dist/schema/geometry/binary-geometries.d.ts +33 -0
- package/dist/schema/geometry/binary-geometries.d.ts.map +1 -0
- package/dist/schema/geometry/binary-geometries.js +5 -0
- package/dist/schema/geometry/binary-geometries.js.map +1 -0
- package/dist/schema/geometry/flat-geometries.d.ts +61 -0
- package/dist/schema/geometry/flat-geometries.d.ts.map +1 -0
- package/dist/schema/geometry/flat-geometries.js +5 -0
- package/dist/schema/geometry/flat-geometries.js.map +1 -0
- package/dist/schema/geometry/geoarrow.d.ts +69 -0
- package/dist/schema/geometry/geoarrow.d.ts.map +1 -0
- package/dist/schema/geometry/geoarrow.js +5 -0
- package/dist/schema/geometry/geoarrow.js.map +1 -0
- package/dist/schema/geoparquet.schema.json +222 -0
- package/dist/schema/geospatial-metadata-zod-schema.cjs +154 -0
- package/dist/schema/geospatial-metadata-zod-schema.cjs.map +6 -0
- package/dist/schema/geospatial-metadata-zod-schema.d.ts +44 -0
- package/dist/schema/geospatial-metadata-zod-schema.d.ts.map +1 -0
- package/dist/schema/geospatial-metadata-zod-schema.js +151 -0
- package/dist/schema/geospatial-metadata-zod-schema.js.map +1 -0
- package/dist/schema/index.cjs +259 -0
- package/dist/schema/index.cjs.map +6 -0
- package/dist/schema/index.d.ts +21 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +9 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/metadata.d.ts +40 -0
- package/dist/schema/metadata.d.ts.map +1 -0
- package/dist/schema/metadata.js +86 -0
- package/dist/schema/metadata.js.map +1 -0
- package/dist/schema/types/batch.d.ts +37 -0
- package/dist/schema/types/batch.d.ts.map +1 -0
- package/dist/schema/types/batch.js +5 -0
- package/dist/schema/types/batch.js.map +1 -0
- package/dist/schema/types/schema.d.ts +70 -0
- package/dist/schema/types/schema.d.ts.map +1 -0
- package/dist/schema/types/schema.js +5 -0
- package/dist/schema/types/schema.js.map +1 -0
- package/dist/schema/types/types.d.ts +16 -0
- package/dist/schema/types/types.d.ts.map +1 -0
- package/dist/schema/types/types.js +6 -0
- package/dist/schema/types/types.js.map +1 -0
- package/dist/schema-utils/arrow-transport.cjs +665 -0
- package/dist/schema-utils/arrow-transport.cjs.map +6 -0
- package/dist/schema-utils/arrow-transport.d.ts +4 -0
- package/dist/schema-utils/arrow-transport.d.ts.map +1 -0
- package/dist/schema-utils/arrow-transport.js +7 -0
- package/dist/schema-utils/arrow-transport.js.map +1 -0
- package/dist/schema-utils/deprecated.d.ts +24 -0
- package/dist/schema-utils/deprecated.d.ts.map +1 -0
- package/dist/schema-utils/deprecated.js +27 -0
- package/dist/schema-utils/deprecated.js.map +1 -0
- package/dist/schema-utils/index.cjs +3423 -0
- package/dist/schema-utils/index.cjs.map +6 -0
- package/dist/schema-utils/index.d.ts +38 -0
- package/dist/schema-utils/index.d.ts.map +1 -0
- package/dist/schema-utils/index.js +77 -0
- package/dist/schema-utils/index.js.map +1 -0
- package/dist/schema-utils/lib/arrow/arrow-table-transport.d.ts +72 -0
- package/dist/schema-utils/lib/arrow/arrow-table-transport.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow/arrow-table-transport.js +162 -0
- package/dist/schema-utils/lib/arrow/arrow-table-transport.js.map +1 -0
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.d.ts +33 -0
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.js +128 -0
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.js.map +1 -0
- package/dist/schema-utils/lib/arrow-utils/arrow-fixed-size-list-utils.d.ts +11 -0
- package/dist/schema-utils/lib/arrow-utils/arrow-fixed-size-list-utils.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow-utils/arrow-fixed-size-list-utils.js +45 -0
- package/dist/schema-utils/lib/arrow-utils/arrow-fixed-size-list-utils.js.map +1 -0
- package/dist/schema-utils/lib/arrow-utils/arrow-list-of-fixed-size-list-utils.d.ts +11 -0
- package/dist/schema-utils/lib/arrow-utils/arrow-list-of-fixed-size-list-utils.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow-utils/arrow-list-of-fixed-size-list-utils.js +33 -0
- package/dist/schema-utils/lib/arrow-utils/arrow-list-of-fixed-size-list-utils.js.map +1 -0
- package/dist/schema-utils/lib/converters/convert.d.ts +10 -0
- package/dist/schema-utils/lib/converters/convert.d.ts.map +1 -0
- package/dist/schema-utils/lib/converters/convert.js +98 -0
- package/dist/schema-utils/lib/converters/convert.js.map +1 -0
- package/dist/schema-utils/lib/converters/converters.d.ts +3 -0
- package/dist/schema-utils/lib/converters/converters.d.ts.map +1 -0
- package/dist/schema-utils/lib/converters/converters.js +5 -0
- package/dist/schema-utils/lib/converters/converters.js.map +1 -0
- package/dist/schema-utils/lib/converters/types.d.ts +35 -0
- package/dist/schema-utils/lib/converters/types.d.ts.map +1 -0
- package/dist/schema-utils/lib/converters/types.js +5 -0
- package/dist/schema-utils/lib/converters/types.js.map +1 -0
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts +44 -0
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts.map +1 -0
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js +187 -0
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js.map +1 -0
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts +14 -0
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts.map +1 -0
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js +217 -0
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js.map +1 -0
- package/dist/schema-utils/lib/mesh/deduce-mesh-schema.d.ts +23 -0
- package/dist/schema-utils/lib/mesh/deduce-mesh-schema.d.ts.map +1 -0
- package/dist/schema-utils/lib/mesh/deduce-mesh-schema.js +72 -0
- package/dist/schema-utils/lib/mesh/deduce-mesh-schema.js.map +1 -0
- package/dist/schema-utils/lib/mesh/mesh-utils.d.ts +23 -0
- package/dist/schema-utils/lib/mesh/mesh-utils.d.ts.map +1 -0
- package/dist/schema-utils/lib/mesh/mesh-utils.js +54 -0
- package/dist/schema-utils/lib/mesh/mesh-utils.js.map +1 -0
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts +98 -0
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts.map +1 -0
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js +407 -0
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js.map +1 -0
- package/dist/schema-utils/lib/schema/convert-arrow-schema.d.ts +39 -0
- package/dist/schema-utils/lib/schema/convert-arrow-schema.d.ts.map +1 -0
- package/dist/schema-utils/lib/schema/convert-arrow-schema.js +441 -0
- package/dist/schema-utils/lib/schema/convert-arrow-schema.js.map +1 -0
- package/dist/schema-utils/lib/schema/data-type.d.ts +16 -0
- package/dist/schema-utils/lib/schema/data-type.d.ts.map +1 -0
- package/dist/schema-utils/lib/schema/data-type.js +102 -0
- package/dist/schema-utils/lib/schema/data-type.js.map +1 -0
- package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts +14 -0
- package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts.map +1 -0
- package/dist/schema-utils/lib/schema/deduce-table-schema.js +101 -0
- package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-field.d.ts +19 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-field.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-field.js +37 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-field.js.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-interface.d.ts +43 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-interface.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-interface.js +5 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-interface.js.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-schema.d.ts +12 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-schema.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-schema.js +82 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-schema.js.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts +28 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js +64 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-type.d.ts +177 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-type.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-type.js +441 -0
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-type.js.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/enum.d.ts +92 -0
- package/dist/schema-utils/lib/table/arrow-api/enum.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/enum.js +98 -0
- package/dist/schema-utils/lib/table/arrow-api/enum.js.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/get-type-info.d.ts +13 -0
- package/dist/schema-utils/lib/table/arrow-api/get-type-info.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/get-type-info.js +28 -0
- package/dist/schema-utils/lib/table/arrow-api/get-type-info.js.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/index.d.ts +6 -0
- package/dist/schema-utils/lib/table/arrow-api/index.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/arrow-api/index.js +8 -0
- package/dist/schema-utils/lib/table/arrow-api/index.js.map +1 -0
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.d.ts +10 -0
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.js +71 -0
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.js.map +1 -0
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.d.ts +28 -0
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.js +104 -0
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.js.map +1 -0
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.d.ts +19 -0
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.js +64 -0
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.js.map +1 -0
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.d.ts +20 -0
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.js +84 -0
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.js.map +1 -0
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.d.ts +21 -0
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.js +86 -0
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.js.map +1 -0
- package/dist/schema-utils/lib/table/batch-builder/table-batch-aggregator.d.ts +24 -0
- package/dist/schema-utils/lib/table/batch-builder/table-batch-aggregator.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/batch-builder/table-batch-aggregator.js +5 -0
- package/dist/schema-utils/lib/table/batch-builder/table-batch-aggregator.js.map +1 -0
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.d.ts +52 -0
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.js +149 -0
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.js.map +1 -0
- package/dist/schema-utils/lib/table/batches/convert-batches.d.ts +10 -0
- package/dist/schema-utils/lib/table/batches/convert-batches.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/batches/convert-batches.js +46 -0
- package/dist/schema-utils/lib/table/batches/convert-batches.js.map +1 -0
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts +17 -0
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js +61 -0
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js.map +1 -0
- package/dist/schema-utils/lib/table/batches/make-table-batch-iterator.d.ts +15 -0
- package/dist/schema-utils/lib/table/batches/make-table-batch-iterator.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/batches/make-table-batch-iterator.js +22 -0
- package/dist/schema-utils/lib/table/batches/make-table-batch-iterator.js.map +1 -0
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts +9 -0
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js +63 -0
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js.map +1 -0
- package/dist/schema-utils/lib/table/query-arrow-table.d.ts +23 -0
- package/dist/schema-utils/lib/table/query-arrow-table.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/query-arrow-table.js +73 -0
- package/dist/schema-utils/lib/table/query-arrow-table.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts +24 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js +151 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/convert-table.d.ts +43 -0
- package/dist/schema-utils/lib/table/tables/convert-table.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/convert-table.js +122 -0
- package/dist/schema-utils/lib/table/tables/convert-table.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/make-table.d.ts +67 -0
- package/dist/schema-utils/lib/table/tables/make-table.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/make-table.js +102 -0
- package/dist/schema-utils/lib/table/tables/make-table.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/row-utils.d.ts +15 -0
- package/dist/schema-utils/lib/table/tables/row-utils.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/row-utils.js +50 -0
- package/dist/schema-utils/lib/table/tables/row-utils.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/table-accessors.d.ts +68 -0
- package/dist/schema-utils/lib/table/tables/table-accessors.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/table-accessors.js +352 -0
- package/dist/schema-utils/lib/table/tables/table-accessors.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/table-column.d.ts +7 -0
- package/dist/schema-utils/lib/table/tables/table-column.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/table-column.js +40 -0
- package/dist/schema-utils/lib/table/tables/table-column.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.d.ts +9 -0
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.js +19 -0
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts +16 -0
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js +45 -0
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/table-types.d.ts +12 -0
- package/dist/schema-utils/lib/table/tables/table-types.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/table-types.js +24 -0
- package/dist/schema-utils/lib/table/tables/table-types.js.map +1 -0
- package/dist/schema-utils/lib/utils/assert.d.ts +2 -0
- package/dist/schema-utils/lib/utils/assert.d.ts.map +1 -0
- package/dist/schema-utils/lib/utils/assert.js +12 -0
- package/dist/schema-utils/lib/utils/assert.js.map +1 -0
- package/dist/schema-utils/lib/utils/async-queue.d.ts +18 -0
- package/dist/schema-utils/lib/utils/async-queue.d.ts.map +1 -0
- package/dist/schema-utils/lib/utils/async-queue.js +96 -0
- package/dist/schema-utils/lib/utils/async-queue.js.map +1 -0
- package/dist/schema-utils/types/types.d.ts +15 -0
- package/dist/schema-utils/types/types.d.ts.map +1 -0
- package/dist/schema-utils/types/types.js +5 -0
- package/dist/schema-utils/types/types.js.map +1 -0
- package/dist/worker-utils/index.cjs +1448 -0
- package/dist/worker-utils/index.cjs.map +6 -0
- package/dist/worker-utils/index.d.ts +22 -0
- package/dist/worker-utils/index.d.ts.map +1 -0
- package/dist/worker-utils/index.js +40 -0
- package/dist/worker-utils/index.js.map +1 -0
- package/dist/worker-utils/lib/async-queue/async-queue.d.ts +32 -0
- package/dist/worker-utils/lib/async-queue/async-queue.d.ts.map +1 -0
- package/dist/worker-utils/lib/async-queue/async-queue.js +91 -0
- package/dist/worker-utils/lib/async-queue/async-queue.js.map +1 -0
- package/dist/worker-utils/lib/env-utils/assert.d.ts +3 -0
- package/dist/worker-utils/lib/env-utils/assert.d.ts.map +1 -0
- package/dist/worker-utils/lib/env-utils/assert.js +13 -0
- package/dist/worker-utils/lib/env-utils/assert.js.map +1 -0
- package/dist/worker-utils/lib/env-utils/globals.d.ts +22 -0
- package/dist/worker-utils/lib/env-utils/globals.d.ts.map +1 -0
- package/dist/worker-utils/lib/env-utils/globals.js +30 -0
- package/dist/worker-utils/lib/env-utils/globals.js.map +1 -0
- package/dist/worker-utils/lib/env-utils/version.d.ts +2 -0
- package/dist/worker-utils/lib/env-utils/version.d.ts.map +1 -0
- package/dist/worker-utils/lib/env-utils/version.js +20 -0
- package/dist/worker-utils/lib/env-utils/version.js.map +1 -0
- package/dist/worker-utils/lib/library-utils/library-utils.d.ts +42 -0
- package/dist/worker-utils/lib/library-utils/library-utils.d.ts.map +1 -0
- package/dist/worker-utils/lib/library-utils/library-utils.js +248 -0
- package/dist/worker-utils/lib/library-utils/library-utils.js.map +1 -0
- package/dist/worker-utils/lib/node/worker_threads-browser.d.ts +14 -0
- package/dist/worker-utils/lib/node/worker_threads-browser.d.ts.map +1 -0
- package/dist/worker-utils/lib/node/worker_threads-browser.js +22 -0
- package/dist/worker-utils/lib/node/worker_threads-browser.js.map +1 -0
- package/dist/worker-utils/lib/node/worker_threads.d.ts +15 -0
- package/dist/worker-utils/lib/node/worker_threads.d.ts.map +1 -0
- package/dist/worker-utils/lib/node/worker_threads.js +16 -0
- package/dist/worker-utils/lib/node/worker_threads.js.map +1 -0
- package/dist/worker-utils/lib/npm-tag.d.ts +8 -0
- package/dist/worker-utils/lib/npm-tag.d.ts.map +1 -0
- package/dist/worker-utils/lib/npm-tag.js +11 -0
- package/dist/worker-utils/lib/npm-tag.js.map +1 -0
- package/dist/worker-utils/lib/process-utils/child-process-proxy.browser.d.ts +8 -0
- package/dist/worker-utils/lib/process-utils/child-process-proxy.browser.d.ts.map +1 -0
- package/dist/worker-utils/lib/process-utils/child-process-proxy.browser.js +18 -0
- package/dist/worker-utils/lib/process-utils/child-process-proxy.browser.js.map +1 -0
- package/dist/worker-utils/lib/process-utils/child-process-proxy.d.ts +45 -0
- package/dist/worker-utils/lib/process-utils/child-process-proxy.d.ts.map +1 -0
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js +123 -0
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js.map +1 -0
- package/dist/worker-utils/lib/process-utils/process-utils.d.ts +2 -0
- package/dist/worker-utils/lib/process-utils/process-utils.d.ts.map +1 -0
- package/dist/worker-utils/lib/process-utils/process-utils.js +32 -0
- package/dist/worker-utils/lib/process-utils/process-utils.js.map +1 -0
- package/dist/worker-utils/lib/worker-api/create-worker.d.ts +9 -0
- package/dist/worker-utils/lib/worker-api/create-worker.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-api/create-worker.js +123 -0
- package/dist/worker-utils/lib/worker-api/create-worker.js.map +1 -0
- package/dist/worker-utils/lib/worker-api/get-worker-url.d.ts +27 -0
- package/dist/worker-utils/lib/worker-api/get-worker-url.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-api/get-worker-url.js +103 -0
- package/dist/worker-utils/lib/worker-api/get-worker-url.js.map +1 -0
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts +44 -0
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-api/process-on-worker.js +312 -0
- package/dist/worker-utils/lib/worker-api/process-on-worker.js.map +1 -0
- package/dist/worker-utils/lib/worker-api/validate-worker-version.d.ts +9 -0
- package/dist/worker-utils/lib/worker-api/validate-worker-version.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-api/validate-worker-version.js +35 -0
- package/dist/worker-utils/lib/worker-api/validate-worker-version.js.map +1 -0
- package/dist/worker-utils/lib/worker-farm/worker-body.d.ts +20 -0
- package/dist/worker-utils/lib/worker-farm/worker-body.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-farm/worker-body.js +131 -0
- package/dist/worker-utils/lib/worker-farm/worker-body.js.map +1 -0
- package/dist/worker-utils/lib/worker-farm/worker-farm.d.ts +58 -0
- package/dist/worker-utils/lib/worker-farm/worker-farm.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-farm/worker-farm.js +116 -0
- package/dist/worker-utils/lib/worker-farm/worker-farm.js.map +1 -0
- package/dist/worker-utils/lib/worker-farm/worker-job.d.ts +34 -0
- package/dist/worker-utils/lib/worker-farm/worker-job.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-farm/worker-job.js +73 -0
- package/dist/worker-utils/lib/worker-farm/worker-job.js.map +1 -0
- package/dist/worker-utils/lib/worker-farm/worker-pool.d.ts +94 -0
- package/dist/worker-utils/lib/worker-farm/worker-pool.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-farm/worker-pool.js +193 -0
- package/dist/worker-utils/lib/worker-farm/worker-pool.js.map +1 -0
- package/dist/worker-utils/lib/worker-farm/worker-thread.d.ts +67 -0
- package/dist/worker-utils/lib/worker-farm/worker-thread.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-farm/worker-thread.js +175 -0
- package/dist/worker-utils/lib/worker-farm/worker-thread.js.map +1 -0
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.d.ts +14 -0
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js +72 -0
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js.map +1 -0
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.d.ts +15 -0
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.js +86 -0
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.js.map +1 -0
- package/dist/worker-utils/lib/worker-utils/remove-nontransferable-options.d.ts +6 -0
- package/dist/worker-utils/lib/worker-utils/remove-nontransferable-options.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-utils/remove-nontransferable-options.js +27 -0
- package/dist/worker-utils/lib/worker-utils/remove-nontransferable-options.js.map +1 -0
- package/dist/worker-utils/null-worker-node.js +349 -0
- package/dist/worker-utils/null-worker-node.js.map +7 -0
- package/dist/worker-utils/null-worker.js +327 -0
- package/dist/worker-utils/null-worker.js.map +7 -0
- package/dist/worker-utils/types.d.ts +79 -0
- package/dist/worker-utils/types.d.ts.map +1 -0
- package/dist/worker-utils/types.js +5 -0
- package/dist/worker-utils/types.js.map +1 -0
- package/dist/worker-utils/workers/null-worker.d.ts +2 -0
- package/dist/worker-utils/workers/null-worker.d.ts.map +1 -0
- package/dist/worker-utils/workers/null-worker.js +17 -0
- package/dist/worker-utils/workers/null-worker.js.map +1 -0
- package/dist/workers/null-worker-node.js +1 -1
- package/dist/workers/null-worker-node.js.map +1 -1
- package/dist/workers/null-worker.js +1 -1
- package/dist/workers/null-worker.js.map +1 -1
- package/package.json +101 -11
- package/src/index.ts +10 -10
- package/src/iterators/make-iterator/make-iterator.ts +1 -1
- package/src/iterators/make-iterator/make-stream-iterator.ts +1 -1
- package/src/iterators/make-iterator/make-string-iterator.ts +1 -1
- package/src/lib/api/core-api.ts +1 -1
- package/src/lib/api/create-data-source.ts +2 -2
- package/src/lib/api/encode-table.ts +2 -2
- package/src/lib/api/encode.ts +3 -3
- package/src/lib/api/load-in-batches.ts +2 -2
- package/src/lib/api/load-loader.ts +2 -2
- package/src/lib/api/load.ts +2 -2
- package/src/lib/api/parse-file.ts +3 -3
- package/src/lib/api/parse-in-batches.ts +44 -6
- package/src/lib/api/parse-sync.ts +2 -2
- package/src/lib/api/parse.ts +4 -4
- package/src/lib/api/preload.ts +6 -1
- package/src/lib/api/register-loaders.ts +1 -1
- package/src/lib/api/select-loader.ts +3 -3
- package/src/lib/api/select-source.ts +1 -1
- package/src/lib/common.ts +1 -1
- package/src/lib/fetch/fetch-file.ts +2 -2
- package/src/lib/filesystems/browser-filesystem.ts +2 -2
- package/src/lib/init.ts +1 -1
- package/src/lib/loader-utils/get-data.ts +2 -2
- package/src/lib/loader-utils/get-fetch-function.ts +2 -2
- package/src/lib/loader-utils/loader-context.ts +2 -2
- package/src/lib/loader-utils/loggers.ts +1 -1
- package/src/lib/loader-utils/normalize-loader.ts +2 -2
- package/src/lib/loader-utils/option-defaults.ts +2 -2
- package/src/lib/loader-utils/option-utils.ts +1 -1
- package/src/lib/utils/resource-utils.ts +1 -1
- package/src/lib/utils/response-utils.ts +1 -1
- package/src/loader-utils/format-types.ts +49 -0
- package/src/loader-utils/index.ts +522 -0
- package/src/loader-utils/json-loader.ts +39 -0
- package/src/loader-utils/lib/binary-utils/array-buffer-utils.ts +114 -0
- package/src/loader-utils/lib/binary-utils/binary-chunk-reader.ts +297 -0
- package/src/loader-utils/lib/binary-utils/dataview-copy-utils.ts +121 -0
- package/src/loader-utils/lib/binary-utils/encode-array-buffer-to-base64.ts +17 -0
- package/src/loader-utils/lib/binary-utils/get-first-characters.ts +46 -0
- package/src/loader-utils/lib/binary-utils/hex-transcoder.ts +54 -0
- package/src/loader-utils/lib/binary-utils/memory-conversion-utils.ts +105 -0
- package/src/loader-utils/lib/binary-utils/memory-copy-utils.ts +69 -0
- package/src/loader-utils/lib/crs/crs-reprojection.ts +52 -0
- package/src/loader-utils/lib/env-utils/assert.ts +13 -0
- package/src/loader-utils/lib/env-utils/globals.ts +36 -0
- package/src/loader-utils/lib/file-provider/data-view-file.ts +83 -0
- package/src/loader-utils/lib/file-provider/file-handle-file.ts +114 -0
- package/src/loader-utils/lib/file-provider/file-provider-interface.ts +60 -0
- package/src/loader-utils/lib/file-provider/file-provider.ts +130 -0
- package/src/loader-utils/lib/files/array-buffer-file.ts +46 -0
- package/src/loader-utils/lib/files/blob-file.ts +45 -0
- package/src/loader-utils/lib/files/file.ts +39 -0
- package/src/loader-utils/lib/files/http-file-transport.ts +432 -0
- package/src/loader-utils/lib/files/http-file-types.ts +60 -0
- package/src/loader-utils/lib/files/http-file.ts +267 -0
- package/src/loader-utils/lib/files/node-file-facade.ts +57 -0
- package/src/loader-utils/lib/files/sources.ts +154 -0
- package/src/loader-utils/lib/filesystems/filesystem.ts +40 -0
- package/src/loader-utils/lib/filesystems/node-filesystem-facade.ts +65 -0
- package/src/loader-utils/lib/iterators/async-iteration.ts +136 -0
- package/src/loader-utils/lib/iterators/text-iterators.ts +76 -0
- package/src/loader-utils/lib/javascript-utils/is-type.ts +130 -0
- package/src/loader-utils/lib/laz/LASZIP-LICENSE +202 -0
- package/src/loader-utils/lib/laz/LASZIP-NOTICE +6 -0
- package/src/loader-utils/lib/laz/laz-arithmetic-encoder.ts +446 -0
- package/src/loader-utils/lib/laz/laz-chunk-decoder.ts +5251 -0
- package/src/loader-utils/lib/laz/laz-chunk-encoder.ts +1909 -0
- package/src/loader-utils/lib/log-utils/log.ts +28 -0
- package/src/loader-utils/lib/module-utils/initialize-wasm-module.ts +51 -0
- package/src/loader-utils/lib/module-utils/js-module-utils.ts +44 -0
- package/src/loader-utils/lib/node/buffer.browser.ts +22 -0
- package/src/loader-utils/lib/node/buffer.ts +40 -0
- package/src/loader-utils/lib/node/fs.browser.ts +5 -0
- package/src/loader-utils/lib/node/promisify.ts +72 -0
- package/src/loader-utils/lib/node/stream.browser.ts +5 -0
- package/src/loader-utils/lib/node/stream.ts +12 -0
- package/src/loader-utils/lib/option-utils/merge-options.ts +50 -0
- package/src/loader-utils/lib/parser-utils/parse-json.ts +16 -0
- package/src/loader-utils/lib/path-utils/cached-uri-resolver.ts +69 -0
- package/src/loader-utils/lib/path-utils/file-aliases.ts +49 -0
- package/src/loader-utils/lib/path-utils/get-cwd.ts +12 -0
- package/src/loader-utils/lib/path-utils/path.ts +173 -0
- package/src/loader-utils/lib/request-utils/abort-utils.ts +64 -0
- package/src/loader-utils/lib/request-utils/authentication.ts +134 -0
- package/src/loader-utils/lib/request-utils/parse-content-type.ts +22 -0
- package/src/loader-utils/lib/request-utils/range-request-cache.ts +279 -0
- package/src/loader-utils/lib/request-utils/range-request-scheduler.ts +899 -0
- package/src/loader-utils/lib/request-utils/request-cache.ts +296 -0
- package/src/loader-utils/lib/request-utils/request-credentials.ts +576 -0
- package/src/loader-utils/lib/request-utils/request-scheduler.ts +230 -0
- package/src/loader-utils/lib/scan-utils/columnar-predicate.ts +397 -0
- package/src/loader-utils/lib/scan-utils/experimental-scan-options.ts +46 -0
- package/src/loader-utils/lib/scan-utils/point-cloud-query.ts +176 -0
- package/src/loader-utils/lib/scan-utils/raster-query.ts +82 -0
- package/src/loader-utils/lib/scan-utils/relational-query.ts +188 -0
- package/src/loader-utils/lib/scan-utils/scan-executor.ts +208 -0
- package/src/loader-utils/lib/scan-utils/scan-fragments.ts +33 -0
- package/src/loader-utils/lib/scan-utils/scan-query-metadata.ts +439 -0
- package/src/loader-utils/lib/scan-utils/table-query-explain.ts +88 -0
- package/src/loader-utils/lib/scan-utils/table-query.ts +163 -0
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +200 -0
- package/src/loader-utils/lib/sources/catalog-source.ts +42 -0
- package/src/loader-utils/lib/sources/data-source-manager.ts +569 -0
- package/src/loader-utils/lib/sources/data-source.ts +236 -0
- package/src/loader-utils/lib/sources/image-source.ts +66 -0
- package/src/loader-utils/lib/sources/image-tile-source.ts +22 -0
- package/src/loader-utils/lib/sources/raster-coverage.ts +92 -0
- package/src/loader-utils/lib/sources/raster-region.ts +35 -0
- package/src/loader-utils/lib/sources/raster-sampling.ts +213 -0
- package/src/loader-utils/lib/sources/raster-source.ts +344 -0
- package/src/loader-utils/lib/sources/service-capabilities.ts +50 -0
- package/src/loader-utils/lib/sources/tile-grid.ts +162 -0
- package/src/loader-utils/lib/sources/tile-source-adapter.ts +126 -0
- package/src/loader-utils/lib/sources/tile-source-utils.ts +19 -0
- package/src/loader-utils/lib/sources/tile-source.ts +198 -0
- package/src/loader-utils/lib/sources/utils/image-type.ts +14 -0
- package/src/loader-utils/lib/sources/utils/utils.ts +31 -0
- package/src/loader-utils/lib/sources/vector-source.ts +89 -0
- package/src/loader-utils/lib/sources/vector-tile-source.ts +29 -0
- package/src/loader-utils/lib/sources/xyz-grid.ts +82 -0
- package/src/loader-utils/lib/worker-loader-utils/create-loader-worker.ts +233 -0
- package/src/loader-utils/lib/worker-loader-utils/encode-with-worker.ts +28 -0
- package/src/loader-utils/lib/worker-loader-utils/parse-with-worker.ts +347 -0
- package/src/loader-utils/loader-types.ts +531 -0
- package/src/loader-utils/source-types.ts +76 -0
- package/src/loader-utils/types.ts +83 -0
- package/src/loader-utils/workers/json-worker.ts +8 -0
- package/src/loader-utils/writer-types.ts +107 -0
- package/src/null-loader.ts +2 -2
- package/src/polyfills/README.md +16 -0
- package/src/polyfills/buffer/btoa.node.ts +15 -0
- package/src/polyfills/buffer/to-array-buffer.node.ts +12 -0
- package/src/polyfills/crypto/node-hash.ts +78 -0
- package/src/polyfills/fetch/decode-data-uri.ts +71 -0
- package/src/polyfills/fetch/fetch-polyfill.ts +165 -0
- package/src/polyfills/fetch/headers-polyfill.ts +119 -0
- package/src/polyfills/fetch/response-polyfill.ts +101 -0
- package/src/polyfills/fetch/utils/decode-data-uri.node.ts +34 -0
- package/src/polyfills/file/blob-stream-controller.ts +69 -0
- package/src/polyfills/file/blob-stream.ts +40 -0
- package/src/polyfills/file/blob.ts +177 -0
- package/src/polyfills/file/file-reader.ts +59 -0
- package/src/polyfills/file/file.ts +45 -0
- package/src/polyfills/file/install-blob-polyfills.ts +17 -0
- package/src/polyfills/file/install-file-polyfills.ts +24 -0
- package/src/polyfills/file/readable-stream.ts +8 -0
- package/src/polyfills/filesystems/fetch-node.ts +98 -0
- package/src/polyfills/filesystems/node-file.ts +169 -0
- package/src/polyfills/filesystems/node-filesystem.ts +54 -0
- package/src/polyfills/filesystems/stream-utils.node.ts +81 -0
- package/src/polyfills/images/encode-image-node.ts +45 -0
- package/src/polyfills/images/encode-image.node.ts.disabled +41 -0
- package/src/polyfills/images/image-codecs-node.ts +40 -0
- package/src/polyfills/images/node-image-bitmap.ts +81 -0
- package/src/polyfills/images/node-image-formats.ts +6 -0
- package/src/polyfills/images/parse-image-node.ts +54 -0
- package/src/polyfills/images/parse-image.node.ts.disabled +55 -0
- package/src/polyfills/index.browser.ts +23 -0
- package/src/polyfills/index.ts +154 -0
- package/src/polyfills/libs/encoding-indexes-asian.js +15 -0
- package/src/polyfills/load-library/require-utils.node.ts +108 -0
- package/src/polyfills/streams/make-node-stream.ts +83 -0
- package/src/polyfills/text-encoder/encoding-indexes.ts +36 -0
- package/src/polyfills/text-encoder/text-encoder.ts +3085 -0
- package/src/polyfills/utils/assert.ts +9 -0
- package/src/polyfills/utils/buffer-utils.ts +40 -0
- package/src/polyfills/utils/filesystem-types.ts +13 -0
- package/src/polyfills/utils/is-browser.ts +8 -0
- package/src/polyfills/utils/path-utils.ts +31 -0
- package/src/polyfills/wip/fetch-browser/fetch-file.browser.d.ts +34 -0
- package/src/schema/categories/category-gis.ts +63 -0
- package/src/schema/categories/category-image.ts +23 -0
- package/src/schema/categories/category-mesh.ts +138 -0
- package/src/schema/categories/category-table.ts +125 -0
- package/src/schema/categories/category-texture.ts +259 -0
- package/src/schema/deprecated/mesh-utils.ts +46 -0
- package/src/schema/float16.ts +111 -0
- package/src/schema/geometry/arrow-binary-features.ts +54 -0
- package/src/schema/geometry/binary-features.ts +43 -0
- package/src/schema/geometry/binary-geometries.ts +45 -0
- package/src/schema/geometry/flat-geometries.ts +72 -0
- package/src/schema/geometry/geoarrow.ts +116 -0
- package/src/schema/geospatial-metadata-zod-schema.ts +163 -0
- package/src/schema/index.ts +169 -0
- package/src/schema/metadata.ts +115 -0
- package/src/schema/types/batch.ts +47 -0
- package/src/schema/types/schema.ts +86 -0
- package/src/schema/types/types.ts +52 -0
- package/src/schema-utils/arrow-transport.ts +7 -0
- package/src/schema-utils/deprecated.ts +53 -0
- package/src/schema-utils/index.ts +165 -0
- package/src/schema-utils/lib/arrow/arrow-table-transport.ts +260 -0
- package/src/schema-utils/lib/arrow/split-arrow-buffers.ts +235 -0
- package/src/schema-utils/lib/arrow-utils/arrow-fixed-size-list-utils.ts +78 -0
- package/src/schema-utils/lib/arrow-utils/arrow-list-of-fixed-size-list-utils.ts +48 -0
- package/src/schema-utils/lib/converters/convert.ts +142 -0
- package/src/schema-utils/lib/converters/converters.ts +6 -0
- package/src/schema-utils/lib/converters/types.ts +44 -0
- package/src/schema-utils/lib/mesh/convert-mesh-to-table.ts +311 -0
- package/src/schema-utils/lib/mesh/convert-table-to-mesh.ts +257 -0
- package/src/schema-utils/lib/mesh/deduce-mesh-schema.ts +85 -0
- package/src/schema-utils/lib/mesh/mesh-utils.ts +73 -0
- package/src/schema-utils/lib/mesh/point-cloud-tiler.ts +485 -0
- package/src/schema-utils/lib/schema/convert-arrow-schema.ts +552 -0
- package/src/schema-utils/lib/schema/data-type.ts +122 -0
- package/src/schema-utils/lib/schema/deduce-table-schema.ts +119 -0
- package/src/schema-utils/lib/table/arrow-api/arrow-like-field.ts +53 -0
- package/src/schema-utils/lib/table/arrow-api/arrow-like-interface.ts +84 -0
- package/src/schema-utils/lib/table/arrow-api/arrow-like-schema.ts +101 -0
- package/src/schema-utils/lib/table/arrow-api/arrow-like-table.ts +85 -0
- package/src/schema-utils/lib/table/arrow-api/arrow-like-type.ts +500 -0
- package/src/schema-utils/lib/table/arrow-api/enum.ts +99 -0
- package/src/schema-utils/lib/table/arrow-api/get-type-info.ts +38 -0
- package/src/schema-utils/lib/table/arrow-api/index.ts +50 -0
- package/src/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator-builders.ts.disabled +190 -0
- package/src/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.ts +85 -0
- package/src/schema-utils/lib/table/batch-builder/arrow-table-builder.ts +123 -0
- package/src/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.ts +82 -0
- package/src/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.ts +104 -0
- package/src/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.ts +108 -0
- package/src/schema-utils/lib/table/batch-builder/table-batch-aggregator.ts +28 -0
- package/src/schema-utils/lib/table/batch-builder/table-batch-builder.ts +185 -0
- package/src/schema-utils/lib/table/batches/convert-batches.ts +83 -0
- package/src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts +81 -0
- package/src/schema-utils/lib/table/batches/make-table-batch-iterator.ts +25 -0
- package/src/schema-utils/lib/table/batches/make-table-from-batches.ts +84 -0
- package/src/schema-utils/lib/table/query-arrow-table.ts +130 -0
- package/src/schema-utils/lib/table/tables/convert-arrow-table.ts +198 -0
- package/src/schema-utils/lib/table/tables/convert-table.ts +152 -0
- package/src/schema-utils/lib/table/tables/make-table.ts +127 -0
- package/src/schema-utils/lib/table/tables/row-utils.ts +59 -0
- package/src/schema-utils/lib/table/tables/table-accessors.ts +418 -0
- package/src/schema-utils/lib/table/tables/table-column.ts +49 -0
- package/src/schema-utils/lib/table/tables/table-converter/convert-tables.ts +35 -0
- package/src/schema-utils/lib/table/tables/table-converter/table-converter.ts +57 -0
- package/src/schema-utils/lib/table/tables/table-types.ts +37 -0
- package/src/schema-utils/lib/utils/assert.ts +12 -0
- package/src/schema-utils/lib/utils/async-queue.ts +109 -0
- package/src/schema-utils/types/types.ts +45 -0
- package/src/worker-utils/index.ts +80 -0
- package/src/worker-utils/lib/async-queue/async-queue.ts +100 -0
- package/src/worker-utils/lib/env-utils/assert.ts +14 -0
- package/src/worker-utils/lib/env-utils/globals.ts +40 -0
- package/src/worker-utils/lib/env-utils/version.ts +25 -0
- package/src/worker-utils/lib/library-utils/library-utils.ts +303 -0
- package/src/worker-utils/lib/node/worker_threads-browser.ts +34 -0
- package/src/worker-utils/lib/node/worker_threads.ts +58 -0
- package/src/worker-utils/lib/npm-tag.ts +11 -0
- package/src/worker-utils/lib/process-utils/child-process-proxy.browser.ts +23 -0
- package/src/worker-utils/lib/process-utils/child-process-proxy.ts +165 -0
- package/src/worker-utils/lib/process-utils/process-utils.ts +34 -0
- package/src/worker-utils/lib/worker-api/create-worker.ts +166 -0
- package/src/worker-utils/lib/worker-api/get-worker-url.ts +129 -0
- package/src/worker-utils/lib/worker-api/process-on-worker.ts +413 -0
- package/src/worker-utils/lib/worker-api/validate-worker-version.ts +44 -0
- package/src/worker-utils/lib/worker-farm/worker-body.ts +145 -0
- package/src/worker-utils/lib/worker-farm/worker-farm.ts +144 -0
- package/src/worker-utils/lib/worker-farm/worker-job.ts +83 -0
- package/src/worker-utils/lib/worker-farm/worker-pool.ts +263 -0
- package/src/worker-utils/lib/worker-farm/worker-thread.ts +206 -0
- package/src/worker-utils/lib/worker-utils/get-loadable-worker-url.ts +81 -0
- package/src/worker-utils/lib/worker-utils/get-transfer-list.ts +93 -0
- package/src/worker-utils/lib/worker-utils/remove-nontransferable-options.ts +27 -0
- package/src/worker-utils/types.ts +125 -0
- package/src/worker-utils/workers/null-worker.ts +20 -0
- package/src/workers/null-worker-node.ts +1 -1
- package/src/workers/null-worker.ts +1 -1
|
@@ -0,0 +1,4226 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT AND Apache-2.0
|
|
3
|
+
// Legacy item version 1 algorithms adapted from LASzip (c) 2007-2022 rapidlasso GmbH.
|
|
4
|
+
// See LASZIP-LICENSE and LASZIP-NOTICE in this directory.
|
|
5
|
+
// Copyright (c) vis.gl contributors
|
|
6
|
+
/** Error raised when a feedable decoder needs more compressed bytes. */
|
|
7
|
+
export class NeedsMoreData extends Error {
|
|
8
|
+
constructor(message = 'LAZ chunk decoder needs more compressed data') {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'NeedsMoreData';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Feedable TypeScript LAZ chunk decoder. */
|
|
14
|
+
export class FeedableLAZChunkDecoder {
|
|
15
|
+
metadata;
|
|
16
|
+
chunks = [];
|
|
17
|
+
closed = false;
|
|
18
|
+
compressed = null;
|
|
19
|
+
cursor = null;
|
|
20
|
+
fedByteLength = 0;
|
|
21
|
+
requiredByteLength = null;
|
|
22
|
+
progressiveRequiredByteLength = null;
|
|
23
|
+
progressiveSelectionKey = null;
|
|
24
|
+
constructor(metadata) {
|
|
25
|
+
this.metadata = metadata;
|
|
26
|
+
}
|
|
27
|
+
/** Add compressed bytes to the decoder input. */
|
|
28
|
+
feed(chunk) {
|
|
29
|
+
if (this.closed) {
|
|
30
|
+
throw new Error('Cannot feed a closed LAZ chunk decoder');
|
|
31
|
+
}
|
|
32
|
+
const bytes = toUint8Array(chunk);
|
|
33
|
+
this.chunks.push(bytes);
|
|
34
|
+
this.compressed = null;
|
|
35
|
+
this.fedByteLength += bytes.byteLength;
|
|
36
|
+
}
|
|
37
|
+
/** Mark the compressed input as complete. */
|
|
38
|
+
close() {
|
|
39
|
+
this.closed = true;
|
|
40
|
+
}
|
|
41
|
+
/** Number of points that remain available after progressive decoding starts. */
|
|
42
|
+
get remainingPointCount() {
|
|
43
|
+
return this.cursor?.remainingPointCount ?? this.metadata.pointCount;
|
|
44
|
+
}
|
|
45
|
+
/** Decode all fed point data into raw LAS point records. */
|
|
46
|
+
decode() {
|
|
47
|
+
if (!this.closed) {
|
|
48
|
+
throw new NeedsMoreData('LAZ chunk decoder input is not closed');
|
|
49
|
+
}
|
|
50
|
+
return this.decodeAvailable();
|
|
51
|
+
}
|
|
52
|
+
/** Decode and return the next raw LAS point batch if enough bytes are available. */
|
|
53
|
+
readBatch(pointCount) {
|
|
54
|
+
if (!this.cursor) {
|
|
55
|
+
if (!this.hasCompleteChunk()) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const compressed = this.getCompressedAvailable();
|
|
59
|
+
const byteLength = this.requiredByteLength ?? compressed.byteLength;
|
|
60
|
+
this.cursor = createLAZChunkDecoderCursor(compressed.subarray(0, byteLength), this.metadata);
|
|
61
|
+
}
|
|
62
|
+
if (this.cursor.remainingPointCount <= 0) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const pointByteLength = this.metadata.pointDataRecordLength;
|
|
66
|
+
const batchPointCount = Math.min(pointCount, this.cursor.remainingPointCount);
|
|
67
|
+
const batch = new Uint8Array(batchPointCount * pointByteLength);
|
|
68
|
+
this.cursor.decodeInto(batch, 0, batchPointCount);
|
|
69
|
+
return batch;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Decode the next position-only point-data batch as soon as Point14 bytes arrive.
|
|
73
|
+
*
|
|
74
|
+
* This is limited to layered PDRF 6-10 chunks and targets without RGB fields.
|
|
75
|
+
* Later independent layers are represented by a zero-filled skipped tail; no
|
|
76
|
+
* values from those layers are read by the position-only decoder.
|
|
77
|
+
*/
|
|
78
|
+
readPositionDataBatch(target, pointCount) {
|
|
79
|
+
if (target.colors || target.rawColors || target.nir) {
|
|
80
|
+
throw new Error('Position-only LAZ batches cannot request color or NIR output');
|
|
81
|
+
}
|
|
82
|
+
return this.readPointDataBatch(target, pointCount);
|
|
83
|
+
}
|
|
84
|
+
/** Decode the next selectively requested layered PDRF 6-10 point-data batch. */
|
|
85
|
+
readPointDataBatch(target, pointCount) {
|
|
86
|
+
const pointDataRecordFormat = this.metadata.pointDataRecordFormat;
|
|
87
|
+
if (pointDataRecordFormat < 6 || pointDataRecordFormat > 10) {
|
|
88
|
+
throw new Error('Progressive LAZ point-data batches require point formats 6-10');
|
|
89
|
+
}
|
|
90
|
+
const hasColor = pointDataRecordFormat === 7 || pointDataRecordFormat === 8 || pointDataRecordFormat === 10;
|
|
91
|
+
if ((target.colors || target.rawColors) && !hasColor) {
|
|
92
|
+
throw new Error(`Point format ${pointDataRecordFormat} does not contain RGB data`);
|
|
93
|
+
}
|
|
94
|
+
if (target.nir && pointDataRecordFormat !== 8 && pointDataRecordFormat !== 10) {
|
|
95
|
+
throw new Error('NIR output requires point format 8 or 10');
|
|
96
|
+
}
|
|
97
|
+
if (target.waveforms && pointDataRecordFormat !== 9 && pointDataRecordFormat !== 10) {
|
|
98
|
+
throw new Error('Waveform output requires point format 9 or 10');
|
|
99
|
+
}
|
|
100
|
+
if (!this.cursor) {
|
|
101
|
+
const compressed = this.getProgressivePointData(target);
|
|
102
|
+
if (!compressed) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
this.cursor = createLAZChunkDecoderCursor(compressed, this.metadata);
|
|
106
|
+
}
|
|
107
|
+
if (this.cursor.remainingPointCount <= 0) {
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
const batchPointCount = Math.min(pointCount, this.cursor.remainingPointCount);
|
|
111
|
+
return this.cursor.decodeIntoPointData(target, batchPointCount);
|
|
112
|
+
}
|
|
113
|
+
hasCompleteChunk() {
|
|
114
|
+
if (!hasLayeredChunkSizeHeaders(this.metadata.pointDataRecordFormat)) {
|
|
115
|
+
return this.closed;
|
|
116
|
+
}
|
|
117
|
+
if (this.requiredByteLength !== null) {
|
|
118
|
+
return this.fedByteLength >= this.requiredByteLength;
|
|
119
|
+
}
|
|
120
|
+
if (this.fedByteLength < getLAZChunkHeaderByteLength(this.metadata)) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
const compressed = this.getCompressedAvailable();
|
|
125
|
+
this.requiredByteLength = getLAZChunkByteLength(compressed, this.metadata);
|
|
126
|
+
return this.requiredByteLength <= this.fedByteLength;
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
if (error instanceof NeedsMoreData) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
decodeAvailable() {
|
|
136
|
+
const compressed = this.getCompressedAvailable();
|
|
137
|
+
const byteLength = this.requiredByteLength ?? compressed.byteLength;
|
|
138
|
+
return decodeLAZChunk(compressed.subarray(0, byteLength), this.metadata);
|
|
139
|
+
}
|
|
140
|
+
getCompressedAvailable() {
|
|
141
|
+
this.compressed ||= concatenateUint8Arrays(this.chunks);
|
|
142
|
+
return this.compressed;
|
|
143
|
+
}
|
|
144
|
+
getProgressivePointData(target) {
|
|
145
|
+
const selectionKey = getLAZPointDataSelectionKey(getLAZPointDataSelection(target));
|
|
146
|
+
if (this.progressiveSelectionKey !== selectionKey) {
|
|
147
|
+
this.progressiveRequiredByteLength = null;
|
|
148
|
+
this.progressiveSelectionKey = selectionKey;
|
|
149
|
+
}
|
|
150
|
+
if (this.progressiveRequiredByteLength === null) {
|
|
151
|
+
const availableHeader = this.getCompressedAvailable();
|
|
152
|
+
const headerLayout = getLayeredChunkLayout(availableHeader, this.metadata);
|
|
153
|
+
if (!headerLayout) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const requiredLayerCount = getProgressiveLayerCount(this.metadata, target);
|
|
157
|
+
this.progressiveRequiredByteLength = headerLayout.getByteLength(requiredLayerCount);
|
|
158
|
+
}
|
|
159
|
+
if (this.fedByteLength < this.progressiveRequiredByteLength) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
const available = this.getCompressedAvailable();
|
|
163
|
+
const layout = getLayeredChunkLayout(available, this.metadata);
|
|
164
|
+
const compressed = new Uint8Array(layout.byteLength);
|
|
165
|
+
compressed.set(available.subarray(0, Math.min(available.byteLength, layout.byteLength)));
|
|
166
|
+
return compressed;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/** Create a feedable TypeScript LAZ chunk decoder. */
|
|
170
|
+
export function createLAZChunkDecoder(metadata) {
|
|
171
|
+
return new FeedableLAZChunkDecoder(metadata);
|
|
172
|
+
}
|
|
173
|
+
/** Stateful cursor that decodes one compressed LAZ chunk into caller-provided output buffers. */
|
|
174
|
+
export class LAZChunkDecoderCursor {
|
|
175
|
+
metadata;
|
|
176
|
+
stream;
|
|
177
|
+
/** Decoder initialized after the caller selects raw or direct point-data output. */
|
|
178
|
+
decoder = null;
|
|
179
|
+
pointIndex = 0;
|
|
180
|
+
/** Output mode selected by the first decode call. */
|
|
181
|
+
outputMode = null;
|
|
182
|
+
/** Direct-output fields selected by the first point-data decode call. */
|
|
183
|
+
pointDataSelectionKey = null;
|
|
184
|
+
constructor(compressed, metadata) {
|
|
185
|
+
this.metadata = metadata;
|
|
186
|
+
this.stream = new ByteReader(toUint8Array(compressed));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Append compressed input to a legacy PDRF 0-5 cursor without resetting decoder state.
|
|
190
|
+
* Layered PDRF 6-10 cursors use bounded contiguous field ranges and cannot be extended.
|
|
191
|
+
*/
|
|
192
|
+
feed(compressed) {
|
|
193
|
+
if (this.metadata.pointDataRecordFormat > 5) {
|
|
194
|
+
throw new Error('Only legacy PDRF 0-5 LAZ cursors accept additional compressed input');
|
|
195
|
+
}
|
|
196
|
+
this.stream.append(toUint8Array(compressed));
|
|
197
|
+
}
|
|
198
|
+
/** Release consumed legacy bytes while preserving arithmetic and predictor state. */
|
|
199
|
+
discardConsumedInput() {
|
|
200
|
+
if (this.metadata.pointDataRecordFormat > 5) {
|
|
201
|
+
throw new Error('Only legacy PDRF 0-5 LAZ cursors can discard consumed input');
|
|
202
|
+
}
|
|
203
|
+
this.stream.discardConsumedInput();
|
|
204
|
+
}
|
|
205
|
+
/** Number of points still available in this compressed chunk. */
|
|
206
|
+
get remainingPointCount() {
|
|
207
|
+
return this.metadata.pointCount - this.pointIndex;
|
|
208
|
+
}
|
|
209
|
+
/** Number of compressed input bytes consumed by decoded points. */
|
|
210
|
+
get compressedByteOffset() {
|
|
211
|
+
return this.stream.byteOffset;
|
|
212
|
+
}
|
|
213
|
+
/** Absolute legacy chunk prefix length needed before another point decode attempt. */
|
|
214
|
+
get requiredInputByteLength() {
|
|
215
|
+
if (this.metadata.pointDataRecordFormat > 5) {
|
|
216
|
+
return this.stream.byteOffset;
|
|
217
|
+
}
|
|
218
|
+
const lookahead = this.pointIndex === 0
|
|
219
|
+
? this.metadata.pointDataRecordLength + 4
|
|
220
|
+
: getLegacyLAZPointDecodeLookahead(this.metadata);
|
|
221
|
+
return this.stream.byteOffset + lookahead;
|
|
222
|
+
}
|
|
223
|
+
/** Decode up to `pointCount` points into `output` at `outputOffset`. */
|
|
224
|
+
decodeInto(output, outputOffset, pointCount) {
|
|
225
|
+
const pointsToDecode = Math.min(pointCount, this.remainingPointCount);
|
|
226
|
+
const decoder = this.selectOutputMode('raw', pointsToDecode);
|
|
227
|
+
if (!decoder) {
|
|
228
|
+
return 0;
|
|
229
|
+
}
|
|
230
|
+
let targetOffset = outputOffset;
|
|
231
|
+
for (let pointIndex = 0; pointIndex < pointsToDecode; pointIndex++) {
|
|
232
|
+
targetOffset = decoder.decompress(output, targetOffset);
|
|
233
|
+
}
|
|
234
|
+
this.pointIndex += pointsToDecode;
|
|
235
|
+
return pointsToDecode;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Decode complete legacy points that have enough compressed lookahead available.
|
|
239
|
+
*
|
|
240
|
+
* The method returns without mutating a partial point. Set `inputComplete` only after the
|
|
241
|
+
* enclosing input stream ends; incomplete final input then raises {@link NeedsMoreData}.
|
|
242
|
+
*/
|
|
243
|
+
decodeAvailableInto(output, outputOffset, pointCount, inputComplete = false) {
|
|
244
|
+
if (this.metadata.pointDataRecordFormat > 5) {
|
|
245
|
+
throw new Error('Available-point decoding is limited to legacy PDRF 0-5 LAZ chunks');
|
|
246
|
+
}
|
|
247
|
+
const pointsToDecode = Math.min(pointCount, this.remainingPointCount);
|
|
248
|
+
if (pointsToDecode === 0) {
|
|
249
|
+
return 0;
|
|
250
|
+
}
|
|
251
|
+
const decoder = this.selectOutputMode('raw', pointsToDecode);
|
|
252
|
+
let decodedPointCount = 0;
|
|
253
|
+
let targetOffset = outputOffset;
|
|
254
|
+
while (decodedPointCount < pointsToDecode) {
|
|
255
|
+
const requiredLookahead = this.pointIndex === 0
|
|
256
|
+
? this.metadata.pointDataRecordLength + 4
|
|
257
|
+
: getLegacyLAZPointDecodeLookahead(this.metadata);
|
|
258
|
+
if (!inputComplete && this.stream.availableByteLength < requiredLookahead) {
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
try {
|
|
262
|
+
targetOffset = decoder.decompress(output, targetOffset);
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
if (error instanceof NeedsMoreData && !inputComplete) {
|
|
266
|
+
throw new Error(`Legacy LAZ point exceeded the ${requiredLookahead}-byte streaming lookahead`);
|
|
267
|
+
}
|
|
268
|
+
throw error;
|
|
269
|
+
}
|
|
270
|
+
decodedPointCount++;
|
|
271
|
+
this.pointIndex++;
|
|
272
|
+
}
|
|
273
|
+
return decodedPointCount;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Decode complete legacy PDRF 0-5 points directly into typed point-data arrays.
|
|
277
|
+
*
|
|
278
|
+
* The method preserves the point-atomic streaming contract of {@link decodeAvailableInto} but
|
|
279
|
+
* bypasses raw LAS record materialization. It returns when the next point lacks compressed
|
|
280
|
+
* lookahead and raises {@link NeedsMoreData} only after `inputComplete` is set.
|
|
281
|
+
*/
|
|
282
|
+
decodeAvailableIntoPointData(target, pointCount, inputComplete = false) {
|
|
283
|
+
if (this.metadata.pointDataRecordFormat > 5) {
|
|
284
|
+
throw new Error('Available point-data decoding is limited to legacy PDRF 0-5 LAZ chunks');
|
|
285
|
+
}
|
|
286
|
+
const pointsToDecode = Math.min(pointCount, this.remainingPointCount);
|
|
287
|
+
if (pointsToDecode === 0) {
|
|
288
|
+
return 0;
|
|
289
|
+
}
|
|
290
|
+
const selection = getLAZPointDataSelection(target);
|
|
291
|
+
const decoder = this.selectOutputMode('point-data', pointsToDecode, selection);
|
|
292
|
+
let decodedPointCount = 0;
|
|
293
|
+
const targetPointOffset = target.pointOffset;
|
|
294
|
+
while (decodedPointCount < pointsToDecode) {
|
|
295
|
+
const requiredLookahead = this.pointIndex === 0
|
|
296
|
+
? this.metadata.pointDataRecordLength + 4
|
|
297
|
+
: getLegacyLAZPointDecodeLookahead(this.metadata);
|
|
298
|
+
if (!inputComplete && this.stream.availableByteLength < requiredLookahead) {
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
try {
|
|
302
|
+
target.pointOffset = targetPointOffset + decodedPointCount;
|
|
303
|
+
if (decoder.decompressPointData) {
|
|
304
|
+
decoder.decompressPointData(target, target.pointOffset);
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
decoder.decompressPointDataBatch(target, 1);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
target.pointOffset = targetPointOffset;
|
|
312
|
+
if (error instanceof NeedsMoreData && !inputComplete) {
|
|
313
|
+
throw new Error(`Legacy LAZ point exceeded the ${requiredLookahead}-byte streaming lookahead`);
|
|
314
|
+
}
|
|
315
|
+
throw error;
|
|
316
|
+
}
|
|
317
|
+
decodedPointCount++;
|
|
318
|
+
this.pointIndex++;
|
|
319
|
+
}
|
|
320
|
+
target.pointOffset = targetPointOffset;
|
|
321
|
+
return decodedPointCount;
|
|
322
|
+
}
|
|
323
|
+
/** Decode up to `pointCount` points directly into typed point-data arrays. */
|
|
324
|
+
decodeIntoPointData(target, pointCount) {
|
|
325
|
+
const pointsToDecode = Math.min(pointCount, this.remainingPointCount);
|
|
326
|
+
if (pointsToDecode > 0 && !supportsDirectPointDataOutput(this.metadata.pointDataRecordFormat)) {
|
|
327
|
+
throw new Error(`TypeScript LAZ decoder does not support direct point-data output for point format ${this.metadata.pointDataRecordFormat}`);
|
|
328
|
+
}
|
|
329
|
+
const selection = getLAZPointDataSelection(target);
|
|
330
|
+
const decoder = this.selectOutputMode('point-data', pointsToDecode, selection);
|
|
331
|
+
if (!decoder) {
|
|
332
|
+
return 0;
|
|
333
|
+
}
|
|
334
|
+
if (decoder.decompressPointDataBatch) {
|
|
335
|
+
decoder.decompressPointDataBatch(target, pointsToDecode);
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
for (let pointIndex = 0; pointIndex < pointsToDecode; pointIndex++) {
|
|
339
|
+
decoder.decompressPointData(target, target.pointOffset + pointIndex);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
this.pointIndex += pointsToDecode;
|
|
343
|
+
return pointsToDecode;
|
|
344
|
+
}
|
|
345
|
+
/** Lock this cursor to one output mode so skipped layered streams cannot be read later. */
|
|
346
|
+
selectOutputMode(mode, pointCount, selection = null) {
|
|
347
|
+
if (pointCount === 0) {
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
if (this.outputMode && this.outputMode !== mode) {
|
|
351
|
+
throw new Error('Cannot mix raw and point-data decoding in one LAZ chunk cursor');
|
|
352
|
+
}
|
|
353
|
+
if (mode === 'point-data') {
|
|
354
|
+
const selectionKey = getLAZPointDataSelectionKey(selection);
|
|
355
|
+
if (this.pointDataSelectionKey !== null && this.pointDataSelectionKey !== selectionKey) {
|
|
356
|
+
throw new Error('Cannot change selected point-data fields in one LAZ chunk cursor');
|
|
357
|
+
}
|
|
358
|
+
this.pointDataSelectionKey = selectionKey;
|
|
359
|
+
}
|
|
360
|
+
this.outputMode = mode;
|
|
361
|
+
this.decoder ||= createPointDecompressor(this.stream, this.metadata, mode, selection);
|
|
362
|
+
return this.decoder;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
/** Return the independent LAZ 1.4 field layers requested by a direct output target. */
|
|
366
|
+
function getLAZPointDataSelection(target) {
|
|
367
|
+
return {
|
|
368
|
+
intensity: Boolean(target.intensities),
|
|
369
|
+
classification: Boolean(target.classifications),
|
|
370
|
+
color: Boolean(target.colors || target.rawColors),
|
|
371
|
+
gpsTime: Boolean(target.gpsTimes),
|
|
372
|
+
nir: Boolean(target.nir),
|
|
373
|
+
scanAngle: Boolean(target.scanAngles),
|
|
374
|
+
userData: Boolean(target.userData),
|
|
375
|
+
pointSourceId: Boolean(target.pointSourceIds),
|
|
376
|
+
flags: Boolean(target.scannerChannels ||
|
|
377
|
+
target.scanDirectionFlags ||
|
|
378
|
+
target.edgeOfFlightLines ||
|
|
379
|
+
target.syntheticFlags ||
|
|
380
|
+
target.keyPointFlags ||
|
|
381
|
+
target.withheldFlags ||
|
|
382
|
+
target.overlapFlags),
|
|
383
|
+
waveform: Boolean(target.waveforms),
|
|
384
|
+
extraBytes: Boolean(target.extraBytes)
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
/** Encode a direct-output field selection as a compact cursor compatibility key. */
|
|
388
|
+
function getLAZPointDataSelectionKey(selection) {
|
|
389
|
+
return ((selection.intensity ? 1 : 0) |
|
|
390
|
+
(selection.classification ? 2 : 0) |
|
|
391
|
+
(selection.color ? 4 : 0) |
|
|
392
|
+
(selection.gpsTime ? 8 : 0) |
|
|
393
|
+
(selection.nir ? 16 : 0) |
|
|
394
|
+
(selection.scanAngle ? 32 : 0) |
|
|
395
|
+
(selection.userData ? 64 : 0) |
|
|
396
|
+
(selection.pointSourceId ? 128 : 0) |
|
|
397
|
+
(selection.flags ? 256 : 0) |
|
|
398
|
+
(selection.waveform ? 512 : 0) |
|
|
399
|
+
(selection.extraBytes ? 1024 : 0));
|
|
400
|
+
}
|
|
401
|
+
/** Create a stateful TypeScript LAZ chunk decoder cursor. */
|
|
402
|
+
export function createLAZChunkDecoderCursor(compressed, metadata) {
|
|
403
|
+
return new LAZChunkDecoderCursor(compressed, metadata);
|
|
404
|
+
}
|
|
405
|
+
/** Decode a complete compressed LAZ point chunk into raw LAS point records. */
|
|
406
|
+
export function decodeLAZChunk(compressed, metadata) {
|
|
407
|
+
const decoder = createLAZChunkDecoderCursor(compressed, metadata);
|
|
408
|
+
const output = new Uint8Array(metadata.pointCount * metadata.pointDataRecordLength);
|
|
409
|
+
decoder.decodeInto(output, 0, metadata.pointCount);
|
|
410
|
+
return output;
|
|
411
|
+
}
|
|
412
|
+
/** Decode a compressed LAZ point chunk into raw LAS point record batches. */
|
|
413
|
+
export async function* decodeLAZChunkInBatches(chunks, metadata, options = {}) {
|
|
414
|
+
const decoder = createLAZChunkDecoder(metadata);
|
|
415
|
+
const batchSize = options.batchSize || metadata.pointCount;
|
|
416
|
+
for await (const chunk of chunks) {
|
|
417
|
+
decoder.feed(chunk);
|
|
418
|
+
let batch = decoder.readBatch(batchSize);
|
|
419
|
+
while (batch) {
|
|
420
|
+
yield batch;
|
|
421
|
+
batch = decoder.readBatch(batchSize);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
decoder.close();
|
|
425
|
+
let batch = decoder.readBatch(batchSize);
|
|
426
|
+
while (batch) {
|
|
427
|
+
yield batch;
|
|
428
|
+
batch = decoder.readBatch(batchSize);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
/** Return the byte length of a complete LAS 1.4 layered LAZ point chunk. */
|
|
432
|
+
export function getLAZChunkByteLength(compressed, metadata) {
|
|
433
|
+
if (!hasLayeredChunkSizeHeaders(metadata.pointDataRecordFormat)) {
|
|
434
|
+
throw new NeedsMoreData('Legacy LAZ chunk byte length is not self-describing');
|
|
435
|
+
}
|
|
436
|
+
const bytes = toUint8Array(compressed);
|
|
437
|
+
const extraByteCount = getExtraByteCount(metadata);
|
|
438
|
+
const firstPointByteLength = metadata.pointDataRecordLength;
|
|
439
|
+
const sizeHeaderCount = getChunkSizeHeaderCount(metadata.pointDataRecordFormat, extraByteCount);
|
|
440
|
+
const sizeHeaderOffset = firstPointByteLength + 4;
|
|
441
|
+
const sizeHeaderByteLength = sizeHeaderCount * 4;
|
|
442
|
+
if (bytes.byteLength < sizeHeaderOffset + sizeHeaderByteLength) {
|
|
443
|
+
throw new NeedsMoreData();
|
|
444
|
+
}
|
|
445
|
+
const dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
446
|
+
let byteLength = sizeHeaderOffset + sizeHeaderByteLength;
|
|
447
|
+
for (let index = 0; index < sizeHeaderCount; index++) {
|
|
448
|
+
byteLength += dataView.getUint32(sizeHeaderOffset + index * 4, true);
|
|
449
|
+
}
|
|
450
|
+
if (bytes.byteLength < byteLength) {
|
|
451
|
+
throw new NeedsMoreData();
|
|
452
|
+
}
|
|
453
|
+
return byteLength;
|
|
454
|
+
}
|
|
455
|
+
/** Decode a LASzip chunk table payload into chunk point counts and byte lengths. */
|
|
456
|
+
export function decodeLAZChunkTable(compressed, options) {
|
|
457
|
+
const input = new ByteReader(toUint8Array(compressed));
|
|
458
|
+
const decoder = new ArithmeticDecoder(input);
|
|
459
|
+
const decompressor = createIntegerDecompressor(32, 2);
|
|
460
|
+
decoder.readInitBytes();
|
|
461
|
+
const chunks = [];
|
|
462
|
+
let countPredictor = 0;
|
|
463
|
+
let byteLengthPredictor = 0;
|
|
464
|
+
let remainingPointCount = options.pointCount;
|
|
465
|
+
for (let index = 0; index < options.chunkCount; index++) {
|
|
466
|
+
let pointCount;
|
|
467
|
+
if (options.variable) {
|
|
468
|
+
countPredictor = decompressor.decompress(decoder, countPredictor, 0) >>> 0;
|
|
469
|
+
pointCount = countPredictor;
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
pointCount = Math.min(options.chunkSize, remainingPointCount);
|
|
473
|
+
remainingPointCount -= pointCount;
|
|
474
|
+
}
|
|
475
|
+
byteLengthPredictor = decompressor.decompress(decoder, byteLengthPredictor, 1) >>> 0;
|
|
476
|
+
chunks.push({ pointCount, byteLength: byteLengthPredictor });
|
|
477
|
+
}
|
|
478
|
+
return chunks;
|
|
479
|
+
}
|
|
480
|
+
/** Return the bytes needed to read one layered LAZ chunk's size headers. */
|
|
481
|
+
export function getLAZChunkHeaderByteLength(metadata) {
|
|
482
|
+
if (!hasLayeredChunkSizeHeaders(metadata.pointDataRecordFormat)) {
|
|
483
|
+
return metadata.pointDataRecordLength + 4;
|
|
484
|
+
}
|
|
485
|
+
const extraByteCount = getExtraByteCount(metadata);
|
|
486
|
+
return (metadata.pointDataRecordLength +
|
|
487
|
+
4 +
|
|
488
|
+
getChunkSizeHeaderCount(metadata.pointDataRecordFormat, extraByteCount) * 4);
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Return the compressed byte length declared by a layered LAZ chunk header.
|
|
492
|
+
*
|
|
493
|
+
* Unlike {@link getLAZChunkByteLength}, this function does not require the
|
|
494
|
+
* compressed layer payloads to have arrived.
|
|
495
|
+
*/
|
|
496
|
+
export function getLAZChunkDeclaredByteLength(compressedHeader, metadata) {
|
|
497
|
+
if (!hasLayeredChunkSizeHeaders(metadata.pointDataRecordFormat)) {
|
|
498
|
+
throw new NeedsMoreData('Legacy LAZ chunk byte length is not self-describing');
|
|
499
|
+
}
|
|
500
|
+
const layout = getLayeredChunkLayout(toUint8Array(compressedHeader), metadata);
|
|
501
|
+
if (!layout) {
|
|
502
|
+
throw new NeedsMoreData('LAZ chunk decoder needs the complete layered size header');
|
|
503
|
+
}
|
|
504
|
+
return layout.byteLength;
|
|
505
|
+
}
|
|
506
|
+
function getLayeredChunkLayout(bytes, metadata) {
|
|
507
|
+
const extraByteCount = getExtraByteCount(metadata);
|
|
508
|
+
const sizeHeaderOffset = metadata.pointDataRecordLength + 4;
|
|
509
|
+
const sizeHeaderCount = getChunkSizeHeaderCount(metadata.pointDataRecordFormat, extraByteCount);
|
|
510
|
+
const sizeHeaderByteLength = sizeHeaderCount * 4;
|
|
511
|
+
if (bytes.byteLength < sizeHeaderOffset + sizeHeaderByteLength) {
|
|
512
|
+
return null;
|
|
513
|
+
}
|
|
514
|
+
const dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
515
|
+
let byteLength = sizeHeaderOffset + sizeHeaderByteLength;
|
|
516
|
+
const layerByteLengths = [];
|
|
517
|
+
for (let index = 0; index < sizeHeaderCount; index++) {
|
|
518
|
+
const layerByteLength = dataView.getUint32(sizeHeaderOffset + index * 4, true);
|
|
519
|
+
byteLength += layerByteLength;
|
|
520
|
+
layerByteLengths.push(layerByteLength);
|
|
521
|
+
}
|
|
522
|
+
const dataOffset = sizeHeaderOffset + sizeHeaderByteLength;
|
|
523
|
+
return {
|
|
524
|
+
byteLength,
|
|
525
|
+
layerByteLengths,
|
|
526
|
+
getByteLength: layerCount => dataOffset + layerByteLengths.slice(0, layerCount).reduce((sum, value) => sum + value, 0)
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
/** Return the layered-stream prefix needed to satisfy a direct-output selection. */
|
|
530
|
+
function getProgressiveLayerCount(metadata, target) {
|
|
531
|
+
if (target.extraBytes) {
|
|
532
|
+
return getChunkSizeHeaderCount(metadata.pointDataRecordFormat, getExtraByteCount(metadata));
|
|
533
|
+
}
|
|
534
|
+
// The first two streams contain XY and Z. Optional Point14 streams follow
|
|
535
|
+
// in codec order: classification, flags, intensity, scan angle, user data,
|
|
536
|
+
// point source ID, and GPS time.
|
|
537
|
+
let layerCount = 2;
|
|
538
|
+
if (target.classifications) {
|
|
539
|
+
layerCount = 3;
|
|
540
|
+
}
|
|
541
|
+
if (target.scannerChannels ||
|
|
542
|
+
target.scanDirectionFlags ||
|
|
543
|
+
target.edgeOfFlightLines ||
|
|
544
|
+
target.syntheticFlags ||
|
|
545
|
+
target.keyPointFlags ||
|
|
546
|
+
target.withheldFlags ||
|
|
547
|
+
target.overlapFlags) {
|
|
548
|
+
layerCount = 4;
|
|
549
|
+
}
|
|
550
|
+
if (target.intensities) {
|
|
551
|
+
layerCount = 5;
|
|
552
|
+
}
|
|
553
|
+
if (target.scanAngles) {
|
|
554
|
+
layerCount = 6;
|
|
555
|
+
}
|
|
556
|
+
if (target.userData) {
|
|
557
|
+
layerCount = 7;
|
|
558
|
+
}
|
|
559
|
+
if (target.pointSourceIds) {
|
|
560
|
+
layerCount = 8;
|
|
561
|
+
}
|
|
562
|
+
if (target.gpsTimes) {
|
|
563
|
+
layerCount = 9;
|
|
564
|
+
}
|
|
565
|
+
if (target.colors || target.rawColors) {
|
|
566
|
+
layerCount = 10;
|
|
567
|
+
}
|
|
568
|
+
if (target.nir) {
|
|
569
|
+
layerCount = 11;
|
|
570
|
+
}
|
|
571
|
+
if (target.waveforms) {
|
|
572
|
+
layerCount = metadata.pointDataRecordFormat === 9 ? 10 : 12;
|
|
573
|
+
}
|
|
574
|
+
return Math.min(layerCount, getChunkSizeHeaderCount(metadata.pointDataRecordFormat, getExtraByteCount(metadata)));
|
|
575
|
+
}
|
|
576
|
+
const AC_MIN_LENGTH = 0x01000000;
|
|
577
|
+
const AC_MAX_LENGTH = 0xffffffff;
|
|
578
|
+
const BM_LENGTH_SHIFT = 13;
|
|
579
|
+
const BM_MAX_COUNT = 1 << BM_LENGTH_SHIFT;
|
|
580
|
+
const BM_DISTRIBUTION_DIVISOR = 2 ** (31 - BM_LENGTH_SHIFT);
|
|
581
|
+
const DM_LENGTH_SHIFT = 15;
|
|
582
|
+
const DM_MAX_COUNT = 1 << DM_LENGTH_SHIFT;
|
|
583
|
+
const DM_DISTRIBUTION_DIVISOR = 2 ** (31 - DM_LENGTH_SHIFT);
|
|
584
|
+
const NUMBER_RETURN_MAP_6_CONTEXT = [
|
|
585
|
+
[0, 1, 2, 3, 4, 5, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5],
|
|
586
|
+
[1, 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],
|
|
587
|
+
[2, 1, 2, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3],
|
|
588
|
+
[3, 3, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
|
|
589
|
+
[4, 3, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
|
|
590
|
+
[5, 3, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
|
|
591
|
+
[3, 3, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4],
|
|
592
|
+
[4, 3, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4],
|
|
593
|
+
[4, 3, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4],
|
|
594
|
+
[5, 3, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4],
|
|
595
|
+
[5, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4],
|
|
596
|
+
[5, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 4, 4, 4],
|
|
597
|
+
[5, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 4, 4],
|
|
598
|
+
[5, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 4],
|
|
599
|
+
[5, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5],
|
|
600
|
+
[5, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5]
|
|
601
|
+
];
|
|
602
|
+
const NUMBER_RETURN_LEVEL_8_CONTEXT = [
|
|
603
|
+
[0, 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
604
|
+
[1, 0, 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
605
|
+
[2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7],
|
|
606
|
+
[3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7],
|
|
607
|
+
[4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7],
|
|
608
|
+
[5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 7, 7, 7],
|
|
609
|
+
[6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 7, 7],
|
|
610
|
+
[7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 7],
|
|
611
|
+
[7, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7],
|
|
612
|
+
[7, 7, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],
|
|
613
|
+
[7, 7, 7, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],
|
|
614
|
+
[7, 7, 7, 7, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4],
|
|
615
|
+
[7, 7, 7, 7, 7, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3],
|
|
616
|
+
[7, 7, 7, 7, 7, 7, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2],
|
|
617
|
+
[7, 7, 7, 7, 7, 7, 7, 7, 6, 5, 4, 3, 2, 1, 0, 1],
|
|
618
|
+
[7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 5, 4, 3, 2, 1, 0]
|
|
619
|
+
];
|
|
620
|
+
const GPS_TIME_MULTI = 500;
|
|
621
|
+
const GPS_TIME_MULTI_MINUS = -10;
|
|
622
|
+
const GPS_TIME_MULTI_CODE_FULL = 511;
|
|
623
|
+
const GPS_TIME10_MULTI_UNCHANGED = GPS_TIME_MULTI - GPS_TIME_MULTI_MINUS + 1;
|
|
624
|
+
const GPS_TIME10_MULTI_CODE_FULL = GPS_TIME_MULTI - GPS_TIME_MULTI_MINUS + 2;
|
|
625
|
+
const FLOAT64_SCRATCH = new ArrayBuffer(8);
|
|
626
|
+
const FLOAT64_SCRATCH_BYTES = new Uint8Array(FLOAT64_SCRATCH);
|
|
627
|
+
const FLOAT64_SCRATCH_VIEW = new DataView(FLOAT64_SCRATCH);
|
|
628
|
+
const LEGACY_LAZ_POINT_DECODE_LOOKAHEAD = 16 * 1024;
|
|
629
|
+
/**
|
|
630
|
+
* Return enough compressed lookahead to decode one interleaved legacy point atomically.
|
|
631
|
+
* Arithmetic symbols renormalize by at most two bytes; the scaled term covers every Extra Bytes
|
|
632
|
+
* symbol (four for version 1 integer-coded bytes) while the fixed floor covers the bounded core, GPS, RGB, and waveform operations.
|
|
633
|
+
*/
|
|
634
|
+
function getLegacyLAZPointDecodeLookahead(metadata) {
|
|
635
|
+
const byteCorrectionBound = metadata.byteItemVersion === 1 ? 4 : 2;
|
|
636
|
+
return Math.max(LEGACY_LAZ_POINT_DECODE_LOOKAHEAD, metadata.pointDataRecordLength * byteCorrectionBound + 512);
|
|
637
|
+
}
|
|
638
|
+
const NUMBER_RETURN_MAP_10_CONTEXT = [
|
|
639
|
+
[15, 14, 13, 12, 11, 10, 9, 8],
|
|
640
|
+
[14, 0, 1, 3, 6, 10, 10, 9],
|
|
641
|
+
[13, 1, 2, 4, 7, 11, 11, 10],
|
|
642
|
+
[12, 3, 4, 5, 8, 12, 12, 11],
|
|
643
|
+
[11, 6, 7, 8, 9, 13, 13, 12],
|
|
644
|
+
[10, 10, 11, 12, 13, 14, 14, 13],
|
|
645
|
+
[9, 10, 11, 12, 13, 14, 15, 14],
|
|
646
|
+
[8, 9, 10, 11, 12, 13, 14, 15]
|
|
647
|
+
];
|
|
648
|
+
const NUMBER_RETURN_LEVEL_10_CONTEXT = [
|
|
649
|
+
[0, 1, 2, 3, 4, 5, 6, 7],
|
|
650
|
+
[1, 0, 1, 2, 3, 4, 5, 6],
|
|
651
|
+
[2, 1, 0, 1, 2, 3, 4, 5],
|
|
652
|
+
[3, 2, 1, 0, 1, 2, 3, 4],
|
|
653
|
+
[4, 3, 2, 1, 0, 1, 2, 3],
|
|
654
|
+
[5, 4, 3, 2, 1, 0, 1, 2],
|
|
655
|
+
[6, 5, 4, 3, 2, 1, 0, 1],
|
|
656
|
+
[7, 6, 5, 4, 3, 2, 1, 0]
|
|
657
|
+
];
|
|
658
|
+
class ByteReader {
|
|
659
|
+
bytes;
|
|
660
|
+
length;
|
|
661
|
+
offset = 0;
|
|
662
|
+
/** Absolute position of the retained byte range. */
|
|
663
|
+
discardedByteLength = 0;
|
|
664
|
+
constructor(bytes) {
|
|
665
|
+
this.bytes = bytes;
|
|
666
|
+
this.length = bytes.byteLength;
|
|
667
|
+
}
|
|
668
|
+
get byteOffset() {
|
|
669
|
+
return this.discardedByteLength + this.offset;
|
|
670
|
+
}
|
|
671
|
+
/** Number of unread bytes currently available. */
|
|
672
|
+
get availableByteLength() {
|
|
673
|
+
return this.length - this.offset;
|
|
674
|
+
}
|
|
675
|
+
/** Underlying contiguous bytes used by bounded arithmetic layers. */
|
|
676
|
+
get data() {
|
|
677
|
+
return this.length === this.bytes.byteLength ? this.bytes : this.bytes.subarray(0, this.length);
|
|
678
|
+
}
|
|
679
|
+
/** Append bytes while preserving the current read offset and decoder state. */
|
|
680
|
+
append(input) {
|
|
681
|
+
if (input.byteLength === 0) {
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
const requiredLength = this.length + input.byteLength;
|
|
685
|
+
if (requiredLength > this.bytes.byteLength) {
|
|
686
|
+
const capacity = Math.max(requiredLength, Math.max(64, this.bytes.byteLength * 2));
|
|
687
|
+
const bytes = new Uint8Array(capacity);
|
|
688
|
+
bytes.set(this.bytes.subarray(0, this.length));
|
|
689
|
+
this.bytes = bytes;
|
|
690
|
+
}
|
|
691
|
+
this.bytes.set(input, this.length);
|
|
692
|
+
this.length = requiredLength;
|
|
693
|
+
}
|
|
694
|
+
/** Drop the consumed prefix while keeping absolute byte offsets stable. */
|
|
695
|
+
discardConsumedInput() {
|
|
696
|
+
if (this.offset === 0)
|
|
697
|
+
return;
|
|
698
|
+
this.bytes = this.bytes.slice(this.offset, this.length);
|
|
699
|
+
this.discardedByteLength += this.offset;
|
|
700
|
+
this.length -= this.offset;
|
|
701
|
+
this.offset = 0;
|
|
702
|
+
}
|
|
703
|
+
getByte() {
|
|
704
|
+
if (this.offset >= this.length) {
|
|
705
|
+
throw new NeedsMoreData();
|
|
706
|
+
}
|
|
707
|
+
return this.bytes[this.offset++];
|
|
708
|
+
}
|
|
709
|
+
getBytes(target, targetOffset, length) {
|
|
710
|
+
if (this.offset + length > this.length) {
|
|
711
|
+
throw new NeedsMoreData();
|
|
712
|
+
}
|
|
713
|
+
target.set(this.bytes.subarray(this.offset, this.offset + length), targetOffset);
|
|
714
|
+
this.offset += length;
|
|
715
|
+
}
|
|
716
|
+
/** Consume a bounded byte range without constructing a subreader. */
|
|
717
|
+
consume(length) {
|
|
718
|
+
if (this.offset + length > this.length) {
|
|
719
|
+
throw new NeedsMoreData();
|
|
720
|
+
}
|
|
721
|
+
const startOffset = this.offset;
|
|
722
|
+
this.offset += length;
|
|
723
|
+
return startOffset;
|
|
724
|
+
}
|
|
725
|
+
getUint32() {
|
|
726
|
+
const b0 = this.getByte();
|
|
727
|
+
const b1 = this.getByte();
|
|
728
|
+
const b2 = this.getByte();
|
|
729
|
+
const b3 = this.getByte();
|
|
730
|
+
return (b0 | (b1 << 8) | (b2 << 16) | ((b3 << 24) >>> 0)) >>> 0;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
class ArithmeticModel {
|
|
734
|
+
symbols;
|
|
735
|
+
distribution;
|
|
736
|
+
symbolCount;
|
|
737
|
+
decoderTable;
|
|
738
|
+
totalCount = 0;
|
|
739
|
+
updateCycle;
|
|
740
|
+
symbolsUntilUpdate;
|
|
741
|
+
lastSymbol;
|
|
742
|
+
tableSize = 0;
|
|
743
|
+
tableShift = 0;
|
|
744
|
+
constructor(symbols) {
|
|
745
|
+
if (symbols < 2 || symbols > 1 << 11) {
|
|
746
|
+
throw new Error(`Invalid arithmetic model symbol count ${symbols}`);
|
|
747
|
+
}
|
|
748
|
+
this.symbols = symbols;
|
|
749
|
+
this.lastSymbol = symbols - 1;
|
|
750
|
+
if (symbols > 16) {
|
|
751
|
+
let tableBits = 3;
|
|
752
|
+
while (symbols > 1 << (tableBits + 2)) {
|
|
753
|
+
tableBits++;
|
|
754
|
+
}
|
|
755
|
+
this.tableSize = 1 << tableBits;
|
|
756
|
+
this.tableShift = DM_LENGTH_SHIFT - tableBits;
|
|
757
|
+
this.decoderTable = new Uint32Array(this.tableSize + 2);
|
|
758
|
+
}
|
|
759
|
+
else {
|
|
760
|
+
this.decoderTable = null;
|
|
761
|
+
}
|
|
762
|
+
this.distribution = new Uint32Array(symbols);
|
|
763
|
+
this.symbolCount = new Uint32Array(symbols);
|
|
764
|
+
this.symbolCount.fill(1);
|
|
765
|
+
this.updateCycle = symbols;
|
|
766
|
+
this.symbolsUntilUpdate = symbols;
|
|
767
|
+
this.update();
|
|
768
|
+
this.symbolsUntilUpdate = this.updateCycle = (symbols + 6) >> 1;
|
|
769
|
+
}
|
|
770
|
+
update() {
|
|
771
|
+
this.totalCount += this.updateCycle;
|
|
772
|
+
if (this.totalCount > DM_MAX_COUNT) {
|
|
773
|
+
this.totalCount = 0;
|
|
774
|
+
for (let symbol = 0; symbol < this.symbols; symbol++) {
|
|
775
|
+
this.symbolCount[symbol] = (this.symbolCount[symbol] + 1) >> 1;
|
|
776
|
+
this.totalCount += this.symbolCount[symbol];
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
let sum = 0;
|
|
780
|
+
let tableIndex = 0;
|
|
781
|
+
const scale = (0x80000000 / this.totalCount) | 0;
|
|
782
|
+
if (!this.decoderTable) {
|
|
783
|
+
for (let symbol = 0; symbol < this.symbols; symbol++) {
|
|
784
|
+
this.distribution[symbol] = ((scale * sum) / DM_DISTRIBUTION_DIVISOR) | 0;
|
|
785
|
+
sum += this.symbolCount[symbol];
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
else {
|
|
789
|
+
for (let symbol = 0; symbol < this.symbols; symbol++) {
|
|
790
|
+
this.distribution[symbol] = ((scale * sum) / DM_DISTRIBUTION_DIVISOR) | 0;
|
|
791
|
+
sum += this.symbolCount[symbol];
|
|
792
|
+
const width = this.distribution[symbol] >> this.tableShift;
|
|
793
|
+
while (tableIndex < width) {
|
|
794
|
+
this.decoderTable[++tableIndex] = symbol - 1;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
this.decoderTable[0] = 0;
|
|
798
|
+
while (tableIndex <= this.tableSize) {
|
|
799
|
+
this.decoderTable[++tableIndex] = this.symbols - 1;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
this.updateCycle = (5 * this.updateCycle) >> 2;
|
|
803
|
+
const maxCycle = (this.symbols + 6) << 3;
|
|
804
|
+
if (this.updateCycle > maxCycle) {
|
|
805
|
+
this.updateCycle = maxCycle;
|
|
806
|
+
}
|
|
807
|
+
this.symbolsUntilUpdate = this.updateCycle;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
class ArithmeticBitModel {
|
|
811
|
+
updateCycle = 4;
|
|
812
|
+
bitsUntilUpdate = 4;
|
|
813
|
+
bit0Prob = 1 << (BM_LENGTH_SHIFT - 1);
|
|
814
|
+
bit0Count = 1;
|
|
815
|
+
bitCount = 2;
|
|
816
|
+
update() {
|
|
817
|
+
this.bitCount += this.updateCycle;
|
|
818
|
+
if (this.bitCount > BM_MAX_COUNT) {
|
|
819
|
+
this.bitCount = (this.bitCount + 1) >> 1;
|
|
820
|
+
this.bit0Count = (this.bit0Count + 1) >> 1;
|
|
821
|
+
if (this.bit0Count === this.bitCount) {
|
|
822
|
+
this.bitCount++;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
const scale = (0x80000000 / this.bitCount) | 0;
|
|
826
|
+
this.bit0Prob = ((this.bit0Count * scale) / BM_DISTRIBUTION_DIVISOR) | 0;
|
|
827
|
+
this.updateCycle = (5 * this.updateCycle) >> 2;
|
|
828
|
+
if (this.updateCycle > 64) {
|
|
829
|
+
this.updateCycle = 64;
|
|
830
|
+
}
|
|
831
|
+
this.bitsUntilUpdate = this.updateCycle;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
class ArithmeticDecoder {
|
|
835
|
+
input;
|
|
836
|
+
/** Contiguous layered input used by the LAZ 1.4 hot path. */
|
|
837
|
+
inputBytes = null;
|
|
838
|
+
/** Current absolute position in {@link inputBytes}. */
|
|
839
|
+
inputOffset = 0;
|
|
840
|
+
/** Exclusive end of the bounded range in {@link inputBytes}. */
|
|
841
|
+
inputEnd = 0;
|
|
842
|
+
value = 0;
|
|
843
|
+
length = AC_MAX_LENGTH;
|
|
844
|
+
valid = false;
|
|
845
|
+
constructor(input = null) {
|
|
846
|
+
this.input = input;
|
|
847
|
+
}
|
|
848
|
+
initStream(source, count) {
|
|
849
|
+
if (count) {
|
|
850
|
+
this.inputBytes = source.data;
|
|
851
|
+
this.inputOffset = source.consume(count);
|
|
852
|
+
this.inputEnd = this.inputOffset + count;
|
|
853
|
+
this.input = null;
|
|
854
|
+
this.readInitBytes();
|
|
855
|
+
this.valid = true;
|
|
856
|
+
}
|
|
857
|
+
else {
|
|
858
|
+
this.valid = false;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
readInitBytes() {
|
|
862
|
+
if (this.inputBytes) {
|
|
863
|
+
const offset = this.inputOffset;
|
|
864
|
+
if (offset + 4 > this.inputEnd) {
|
|
865
|
+
throw new NeedsMoreData();
|
|
866
|
+
}
|
|
867
|
+
this.value =
|
|
868
|
+
(((this.inputBytes[offset] << 24) >>> 0) |
|
|
869
|
+
(this.inputBytes[offset + 1] << 16) |
|
|
870
|
+
(this.inputBytes[offset + 2] << 8) |
|
|
871
|
+
this.inputBytes[offset + 3]) >>>
|
|
872
|
+
0;
|
|
873
|
+
this.inputOffset = offset + 4;
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
const input = this.input;
|
|
877
|
+
this.value =
|
|
878
|
+
(((input.getByte() << 24) >>> 0) |
|
|
879
|
+
(input.getByte() << 16) |
|
|
880
|
+
(input.getByte() << 8) |
|
|
881
|
+
input.getByte()) >>>
|
|
882
|
+
0;
|
|
883
|
+
}
|
|
884
|
+
decodeBit(model) {
|
|
885
|
+
const value = this.value;
|
|
886
|
+
const length = this.length;
|
|
887
|
+
const x = model.bit0Prob * (length >>> BM_LENGTH_SHIFT);
|
|
888
|
+
const symbol = value >= x ? 1 : 0;
|
|
889
|
+
if (symbol === 0) {
|
|
890
|
+
this.length = x >>> 0;
|
|
891
|
+
model.bit0Count++;
|
|
892
|
+
}
|
|
893
|
+
else {
|
|
894
|
+
this.value = (value - x) >>> 0;
|
|
895
|
+
this.length = (length - x) >>> 0;
|
|
896
|
+
}
|
|
897
|
+
if (this.length < AC_MIN_LENGTH) {
|
|
898
|
+
this.renormalize();
|
|
899
|
+
}
|
|
900
|
+
if (--model.bitsUntilUpdate === 0) {
|
|
901
|
+
model.update();
|
|
902
|
+
}
|
|
903
|
+
return symbol;
|
|
904
|
+
}
|
|
905
|
+
decodeSymbol(model) {
|
|
906
|
+
let symbol;
|
|
907
|
+
let lower;
|
|
908
|
+
let length = this.length;
|
|
909
|
+
let upper = length;
|
|
910
|
+
const value = this.value;
|
|
911
|
+
const distribution = model.distribution;
|
|
912
|
+
const decoderTable = model.decoderTable;
|
|
913
|
+
if (decoderTable) {
|
|
914
|
+
length >>>= DM_LENGTH_SHIFT;
|
|
915
|
+
const dv = (value / length) | 0;
|
|
916
|
+
const tableIndex = dv >> model.tableShift;
|
|
917
|
+
symbol = decoderTable[tableIndex];
|
|
918
|
+
let next = decoderTable[tableIndex + 1] + 1;
|
|
919
|
+
while (next > symbol + 1) {
|
|
920
|
+
const middle = (symbol + next) >> 1;
|
|
921
|
+
if (distribution[middle] > dv) {
|
|
922
|
+
next = middle;
|
|
923
|
+
}
|
|
924
|
+
else {
|
|
925
|
+
symbol = middle;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
lower = distribution[symbol] * length;
|
|
929
|
+
if (symbol !== model.lastSymbol) {
|
|
930
|
+
upper = distribution[symbol + 1] * length;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
else {
|
|
934
|
+
lower = 0;
|
|
935
|
+
symbol = 0;
|
|
936
|
+
length >>>= DM_LENGTH_SHIFT;
|
|
937
|
+
let next = model.symbols;
|
|
938
|
+
let middle = next >> 1;
|
|
939
|
+
do {
|
|
940
|
+
const z = length * distribution[middle];
|
|
941
|
+
if (z > value) {
|
|
942
|
+
next = middle;
|
|
943
|
+
upper = z;
|
|
944
|
+
}
|
|
945
|
+
else {
|
|
946
|
+
symbol = middle;
|
|
947
|
+
lower = z;
|
|
948
|
+
}
|
|
949
|
+
middle = (symbol + next) >> 1;
|
|
950
|
+
} while (middle !== symbol);
|
|
951
|
+
}
|
|
952
|
+
this.value = (value - lower) >>> 0;
|
|
953
|
+
this.length = (upper - lower) >>> 0;
|
|
954
|
+
if (this.length < AC_MIN_LENGTH) {
|
|
955
|
+
this.renormalize();
|
|
956
|
+
}
|
|
957
|
+
model.symbolCount[symbol]++;
|
|
958
|
+
if (--model.symbolsUntilUpdate === 0) {
|
|
959
|
+
model.update();
|
|
960
|
+
}
|
|
961
|
+
return symbol;
|
|
962
|
+
}
|
|
963
|
+
readBits(bits) {
|
|
964
|
+
if (bits > 19) {
|
|
965
|
+
const lower = this.readShort();
|
|
966
|
+
const upper = this.readBits(bits - 16) << 16;
|
|
967
|
+
return (upper | lower) >>> 0;
|
|
968
|
+
}
|
|
969
|
+
const length = this.length >>> bits;
|
|
970
|
+
const value = this.value;
|
|
971
|
+
const symbol = (value / length) | 0;
|
|
972
|
+
this.value = (value - length * symbol) >>> 0;
|
|
973
|
+
this.length = length >>> 0;
|
|
974
|
+
if (length < AC_MIN_LENGTH) {
|
|
975
|
+
this.renormalize();
|
|
976
|
+
}
|
|
977
|
+
return symbol >>> 0;
|
|
978
|
+
}
|
|
979
|
+
readShort() {
|
|
980
|
+
const length = this.length >>> 16;
|
|
981
|
+
const value = this.value;
|
|
982
|
+
const symbol = (value / length) | 0;
|
|
983
|
+
this.value = (value - length * symbol) >>> 0;
|
|
984
|
+
this.length = length >>> 0;
|
|
985
|
+
if (length < AC_MIN_LENGTH) {
|
|
986
|
+
this.renormalize();
|
|
987
|
+
}
|
|
988
|
+
return symbol & 0xffff;
|
|
989
|
+
}
|
|
990
|
+
readInt() {
|
|
991
|
+
const lower = this.readShort();
|
|
992
|
+
const upper = this.readShort();
|
|
993
|
+
return ((upper << 16) | lower) >>> 0;
|
|
994
|
+
}
|
|
995
|
+
/** Read one lossless 64-bit unsigned integer from the arithmetic stream. */
|
|
996
|
+
readUint64() {
|
|
997
|
+
const lower = this.readInt();
|
|
998
|
+
const upper = this.readInt();
|
|
999
|
+
return (BigInt(upper) << 32n) | BigInt(lower);
|
|
1000
|
+
}
|
|
1001
|
+
renormalize() {
|
|
1002
|
+
let value = this.value;
|
|
1003
|
+
let length = this.length;
|
|
1004
|
+
if (this.inputBytes) {
|
|
1005
|
+
const inputBytes = this.inputBytes;
|
|
1006
|
+
const inputEnd = this.inputEnd;
|
|
1007
|
+
let inputOffset = this.inputOffset;
|
|
1008
|
+
do {
|
|
1009
|
+
if (inputOffset >= inputEnd) {
|
|
1010
|
+
throw new NeedsMoreData();
|
|
1011
|
+
}
|
|
1012
|
+
value = ((value << 8) | inputBytes[inputOffset++]) >>> 0;
|
|
1013
|
+
length = (length << 8) >>> 0;
|
|
1014
|
+
} while (length < AC_MIN_LENGTH);
|
|
1015
|
+
this.inputOffset = inputOffset;
|
|
1016
|
+
}
|
|
1017
|
+
else {
|
|
1018
|
+
const input = this.input;
|
|
1019
|
+
do {
|
|
1020
|
+
value = ((value << 8) | input.getByte()) >>> 0;
|
|
1021
|
+
length = (length << 8) >>> 0;
|
|
1022
|
+
} while (length < AC_MIN_LENGTH);
|
|
1023
|
+
}
|
|
1024
|
+
this.value = value;
|
|
1025
|
+
this.length = length;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
class IntegerDecompressor {
|
|
1029
|
+
contexts;
|
|
1030
|
+
bitsHigh;
|
|
1031
|
+
corrBits;
|
|
1032
|
+
corrRange;
|
|
1033
|
+
corrMin;
|
|
1034
|
+
mBits = [];
|
|
1035
|
+
mCorrector0 = new ArithmeticBitModel();
|
|
1036
|
+
mCorrector = [];
|
|
1037
|
+
k = 0;
|
|
1038
|
+
constructor(bits = 16, contexts = 1, bitsHigh = 8, range = 0) {
|
|
1039
|
+
this.contexts = contexts;
|
|
1040
|
+
this.bitsHigh = bitsHigh;
|
|
1041
|
+
if (range) {
|
|
1042
|
+
this.corrBits = 0;
|
|
1043
|
+
this.corrRange = range;
|
|
1044
|
+
while (range) {
|
|
1045
|
+
range >>= 1;
|
|
1046
|
+
this.corrBits++;
|
|
1047
|
+
}
|
|
1048
|
+
if (this.corrRange === 1 << (this.corrBits - 1)) {
|
|
1049
|
+
this.corrBits--;
|
|
1050
|
+
}
|
|
1051
|
+
this.corrMin = -(this.corrRange / 2);
|
|
1052
|
+
}
|
|
1053
|
+
else if (bits && bits < 32) {
|
|
1054
|
+
this.corrBits = bits;
|
|
1055
|
+
this.corrRange = 1 << bits;
|
|
1056
|
+
this.corrMin = -(this.corrRange / 2);
|
|
1057
|
+
}
|
|
1058
|
+
else {
|
|
1059
|
+
this.corrBits = 32;
|
|
1060
|
+
this.corrRange = 0;
|
|
1061
|
+
this.corrMin = -2147483648;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
init() {
|
|
1065
|
+
if (!this.mBits.length) {
|
|
1066
|
+
for (let context = 0; context < this.contexts; context++) {
|
|
1067
|
+
this.mBits.push(new ArithmeticModel(this.corrBits + 1));
|
|
1068
|
+
}
|
|
1069
|
+
for (let bit = 1; bit <= this.corrBits; bit++) {
|
|
1070
|
+
const value = bit <= this.bitsHigh ? 1 << bit : 1 << this.bitsHigh;
|
|
1071
|
+
this.mCorrector.push(new ArithmeticModel(value));
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
decompress(decoder, prediction, context) {
|
|
1076
|
+
// Keep corrector decoding in this hot method. Splitting it into a helper prevents
|
|
1077
|
+
// V8 from optimizing the predictor and corrector as one stable operation.
|
|
1078
|
+
const k = decoder.decodeSymbol(this.mBits[context]);
|
|
1079
|
+
this.k = k;
|
|
1080
|
+
let corrector;
|
|
1081
|
+
if (k) {
|
|
1082
|
+
if (k < 32) {
|
|
1083
|
+
const bitsHigh = this.bitsHigh;
|
|
1084
|
+
const correctorModel = this.mCorrector[k - 1];
|
|
1085
|
+
if (k <= bitsHigh) {
|
|
1086
|
+
corrector = decoder.decodeSymbol(correctorModel);
|
|
1087
|
+
}
|
|
1088
|
+
else {
|
|
1089
|
+
const lowerBitCount = k - bitsHigh;
|
|
1090
|
+
corrector = decoder.decodeSymbol(correctorModel);
|
|
1091
|
+
corrector = (corrector << lowerBitCount) | decoder.readBits(lowerBitCount);
|
|
1092
|
+
}
|
|
1093
|
+
if (corrector >= 1 << (k - 1)) {
|
|
1094
|
+
corrector += 1;
|
|
1095
|
+
}
|
|
1096
|
+
else {
|
|
1097
|
+
corrector -= (1 << k) - 1;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
else {
|
|
1101
|
+
corrector = this.corrMin;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
else {
|
|
1105
|
+
corrector = decoder.decodeBit(this.mCorrector0);
|
|
1106
|
+
}
|
|
1107
|
+
let real = toInt32(prediction + corrector);
|
|
1108
|
+
if (this.corrRange === 0) {
|
|
1109
|
+
return real;
|
|
1110
|
+
}
|
|
1111
|
+
if (real < 0) {
|
|
1112
|
+
real = toInt32(real + this.corrRange);
|
|
1113
|
+
}
|
|
1114
|
+
else if (real >= this.corrRange) {
|
|
1115
|
+
real = toInt32(real - this.corrRange);
|
|
1116
|
+
}
|
|
1117
|
+
return real;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
class StreamingMedian {
|
|
1121
|
+
/** Smallest retained value. */
|
|
1122
|
+
value0 = 0;
|
|
1123
|
+
/** Second-smallest retained value. */
|
|
1124
|
+
value1 = 0;
|
|
1125
|
+
/** Current median. */
|
|
1126
|
+
value2 = 0;
|
|
1127
|
+
/** Second-largest retained value. */
|
|
1128
|
+
value3 = 0;
|
|
1129
|
+
/** Largest retained value. */
|
|
1130
|
+
value4 = 0;
|
|
1131
|
+
/** Whether the next update shifts values toward the upper half. */
|
|
1132
|
+
high = true;
|
|
1133
|
+
add(value) {
|
|
1134
|
+
if (this.high) {
|
|
1135
|
+
if (value < this.value2) {
|
|
1136
|
+
this.value4 = this.value3;
|
|
1137
|
+
this.value3 = this.value2;
|
|
1138
|
+
if (value < this.value0) {
|
|
1139
|
+
this.value2 = this.value1;
|
|
1140
|
+
this.value1 = this.value0;
|
|
1141
|
+
this.value0 = value;
|
|
1142
|
+
}
|
|
1143
|
+
else if (value < this.value1) {
|
|
1144
|
+
this.value2 = this.value1;
|
|
1145
|
+
this.value1 = value;
|
|
1146
|
+
}
|
|
1147
|
+
else {
|
|
1148
|
+
this.value2 = value;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
else {
|
|
1152
|
+
if (value < this.value3) {
|
|
1153
|
+
this.value4 = this.value3;
|
|
1154
|
+
this.value3 = value;
|
|
1155
|
+
}
|
|
1156
|
+
else {
|
|
1157
|
+
this.value4 = value;
|
|
1158
|
+
}
|
|
1159
|
+
this.high = false;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
else if (this.value2 < value) {
|
|
1163
|
+
this.value0 = this.value1;
|
|
1164
|
+
this.value1 = this.value2;
|
|
1165
|
+
if (this.value4 < value) {
|
|
1166
|
+
this.value2 = this.value3;
|
|
1167
|
+
this.value3 = this.value4;
|
|
1168
|
+
this.value4 = value;
|
|
1169
|
+
}
|
|
1170
|
+
else if (this.value3 < value) {
|
|
1171
|
+
this.value2 = this.value3;
|
|
1172
|
+
this.value3 = value;
|
|
1173
|
+
}
|
|
1174
|
+
else {
|
|
1175
|
+
this.value2 = value;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
else {
|
|
1179
|
+
if (this.value1 < value) {
|
|
1180
|
+
this.value0 = this.value1;
|
|
1181
|
+
this.value1 = value;
|
|
1182
|
+
}
|
|
1183
|
+
else {
|
|
1184
|
+
this.value0 = value;
|
|
1185
|
+
}
|
|
1186
|
+
this.high = true;
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
get() {
|
|
1190
|
+
return this.value2;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
/** Return the middle of three retained coordinate differences without allocating. */
|
|
1194
|
+
function getMedianOfThree(values) {
|
|
1195
|
+
return values[0] < values[1]
|
|
1196
|
+
? values[1] < values[2]
|
|
1197
|
+
? values[1]
|
|
1198
|
+
: Math.max(values[0], values[2])
|
|
1199
|
+
: values[0] < values[2]
|
|
1200
|
+
? values[0]
|
|
1201
|
+
: Math.max(values[1], values[2]);
|
|
1202
|
+
}
|
|
1203
|
+
class Point10Decompressor {
|
|
1204
|
+
itemVersion;
|
|
1205
|
+
stream;
|
|
1206
|
+
decoder;
|
|
1207
|
+
changedValuesModel = new ArithmeticModel(64);
|
|
1208
|
+
bitByteModel = createModels(256, 256);
|
|
1209
|
+
classificationModel = createModels(256, 256);
|
|
1210
|
+
scanAngleRankModel = createModels(2, 256);
|
|
1211
|
+
userDataModel = createModels(256, 256);
|
|
1212
|
+
intensity = createIntegerDecompressor(16, 4);
|
|
1213
|
+
pointSourceId = createIntegerDecompressor(16, 1);
|
|
1214
|
+
dx = createIntegerDecompressor(32, 2);
|
|
1215
|
+
dy = createIntegerDecompressor(32, 22);
|
|
1216
|
+
z = createIntegerDecompressor(32, 20);
|
|
1217
|
+
lastIntensity = new Array(16).fill(0);
|
|
1218
|
+
lastHeight = new Array(8).fill(0);
|
|
1219
|
+
lastXDiffMedian = Array.from({ length: 16 }, () => new StreamingMedian());
|
|
1220
|
+
lastYDiffMedian = Array.from({ length: 16 }, () => new StreamingMedian());
|
|
1221
|
+
haveLast = false;
|
|
1222
|
+
last = createPoint10();
|
|
1223
|
+
/** Stable first-point value returned before `last` becomes mutable predictor state. */
|
|
1224
|
+
firstPoint = createPoint10();
|
|
1225
|
+
/** Three preceding X differences for the version 1 predictor. */
|
|
1226
|
+
legacyXDiffs = [0, 0, 0];
|
|
1227
|
+
/** Three preceding Y differences for the version 1 predictor. */
|
|
1228
|
+
legacyYDiffs = [0, 0, 0];
|
|
1229
|
+
/** Ring position in the version 1 difference history. */
|
|
1230
|
+
legacyDifferenceIndex = 0;
|
|
1231
|
+
/** Version 1 scan-angle integer codec. */
|
|
1232
|
+
legacyScanAngle = null;
|
|
1233
|
+
constructor(stream,
|
|
1234
|
+
/** LASzip item codec version selected by the VLR. */ itemVersion = 2) {
|
|
1235
|
+
this.itemVersion = itemVersion;
|
|
1236
|
+
this.stream = stream;
|
|
1237
|
+
this.decoder = new ArithmeticDecoder(stream);
|
|
1238
|
+
if (itemVersion === 1) {
|
|
1239
|
+
this.legacyScanAngle = createIntegerDecompressor(8, 2);
|
|
1240
|
+
this.dx = createIntegerDecompressor(32, 1);
|
|
1241
|
+
this.dy = createIntegerDecompressor(32, 20);
|
|
1242
|
+
this.intensity = createIntegerDecompressor(16, 1);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
getDecoder() {
|
|
1246
|
+
return this.decoder;
|
|
1247
|
+
}
|
|
1248
|
+
decompress(output, outputOffset) {
|
|
1249
|
+
const point = this.decompressPoint();
|
|
1250
|
+
writePoint10(point, output, outputOffset);
|
|
1251
|
+
return outputOffset + 20;
|
|
1252
|
+
}
|
|
1253
|
+
/** Decode one legacy core point without materializing a raw LAS record. */
|
|
1254
|
+
decompressPoint() {
|
|
1255
|
+
if (!this.haveLast) {
|
|
1256
|
+
this.haveLast = true;
|
|
1257
|
+
readPoint10FromStreamInto(this.last, this.stream);
|
|
1258
|
+
copyPoint10(this.firstPoint, this.last);
|
|
1259
|
+
if (this.itemVersion === 2) {
|
|
1260
|
+
this.last.intensity = 0;
|
|
1261
|
+
}
|
|
1262
|
+
return this.firstPoint;
|
|
1263
|
+
}
|
|
1264
|
+
if (this.itemVersion === 1) {
|
|
1265
|
+
return this.decompressLegacyPoint();
|
|
1266
|
+
}
|
|
1267
|
+
const changedValues = this.decoder.decodeSymbol(this.changedValuesModel);
|
|
1268
|
+
if (changedValues) {
|
|
1269
|
+
if (changedValues & (1 << 5)) {
|
|
1270
|
+
this.last.bitByte = this.decoder.decodeSymbol(this.bitByteModel[this.last.bitByte]);
|
|
1271
|
+
}
|
|
1272
|
+
const returnNumber = getPoint10ReturnNumber(this.last);
|
|
1273
|
+
const numberOfReturns = getPoint10NumberOfReturns(this.last);
|
|
1274
|
+
const context = NUMBER_RETURN_MAP_10_CONTEXT[numberOfReturns][returnNumber];
|
|
1275
|
+
if (changedValues & (1 << 4)) {
|
|
1276
|
+
this.last.intensity =
|
|
1277
|
+
this.intensity.decompress(this.decoder, this.lastIntensity[context], context < 3 ? context : 3) & 0xffff;
|
|
1278
|
+
this.lastIntensity[context] = this.last.intensity;
|
|
1279
|
+
}
|
|
1280
|
+
else {
|
|
1281
|
+
this.last.intensity = this.lastIntensity[context];
|
|
1282
|
+
}
|
|
1283
|
+
if (changedValues & (1 << 3)) {
|
|
1284
|
+
this.last.classification = this.decoder.decodeSymbol(this.classificationModel[this.last.classification]);
|
|
1285
|
+
}
|
|
1286
|
+
if (changedValues & (1 << 2)) {
|
|
1287
|
+
const value = this.decoder.decodeSymbol(this.scanAngleRankModel[getPoint10ScanDirectionFlag(this.last)]);
|
|
1288
|
+
this.last.scanAngleRank = toInt8(this.last.scanAngleRank + value);
|
|
1289
|
+
}
|
|
1290
|
+
if (changedValues & (1 << 1)) {
|
|
1291
|
+
this.last.userData = this.decoder.decodeSymbol(this.userDataModel[this.last.userData]);
|
|
1292
|
+
}
|
|
1293
|
+
if (changedValues & 1) {
|
|
1294
|
+
this.last.pointSourceId =
|
|
1295
|
+
this.pointSourceId.decompress(this.decoder, this.last.pointSourceId, 0) & 0xffff;
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
const returnNumber = getPoint10ReturnNumber(this.last);
|
|
1299
|
+
const numberOfReturns = getPoint10NumberOfReturns(this.last);
|
|
1300
|
+
const mapContext = NUMBER_RETURN_MAP_10_CONTEXT[numberOfReturns][returnNumber];
|
|
1301
|
+
const levelContext = NUMBER_RETURN_LEVEL_10_CONTEXT[numberOfReturns][returnNumber];
|
|
1302
|
+
const xMedian = this.lastXDiffMedian[mapContext].get();
|
|
1303
|
+
const xDiff = this.dx.decompress(this.decoder, xMedian, numberOfReturns === 1 ? 1 : 0);
|
|
1304
|
+
this.last.x = toInt32(this.last.x + xDiff);
|
|
1305
|
+
this.lastXDiffMedian[mapContext].add(xDiff);
|
|
1306
|
+
const yMedian = this.lastYDiffMedian[mapContext].get();
|
|
1307
|
+
const xKbits = Math.min(this.dx.k, 20) & ~1;
|
|
1308
|
+
const yDiff = this.dy.decompress(this.decoder, yMedian, (numberOfReturns === 1 ? 1 : 0) + xKbits);
|
|
1309
|
+
this.last.y = toInt32(this.last.y + yDiff);
|
|
1310
|
+
this.lastYDiffMedian[mapContext].add(yDiff);
|
|
1311
|
+
const zKbits = Math.min((this.dx.k + this.dy.k) >> 1, 18) & ~1;
|
|
1312
|
+
this.last.z = this.z.decompress(this.decoder, this.lastHeight[levelContext], (numberOfReturns === 1 ? 1 : 0) + zKbits);
|
|
1313
|
+
this.lastHeight[levelContext] = this.last.z;
|
|
1314
|
+
return this.last;
|
|
1315
|
+
}
|
|
1316
|
+
/** Decode Point10 version 1 using the LASzip median-of-three predictors. */
|
|
1317
|
+
decompressLegacyPoint() {
|
|
1318
|
+
const xDifference = this.dx.decompress(this.decoder, getMedianOfThree(this.legacyXDiffs), 0);
|
|
1319
|
+
this.last.x = toInt32(this.last.x + xDifference);
|
|
1320
|
+
let correctionBits = this.dx.k;
|
|
1321
|
+
const yDifference = this.dy.decompress(this.decoder, getMedianOfThree(this.legacyYDiffs), Math.min(correctionBits, 19));
|
|
1322
|
+
this.last.y = toInt32(this.last.y + yDifference);
|
|
1323
|
+
correctionBits = (correctionBits + this.dy.k) >> 1;
|
|
1324
|
+
this.last.z = this.z.decompress(this.decoder, this.last.z, Math.min(correctionBits, 19));
|
|
1325
|
+
const changedValues = this.decoder.decodeSymbol(this.changedValuesModel);
|
|
1326
|
+
if (changedValues & 32)
|
|
1327
|
+
this.last.intensity =
|
|
1328
|
+
this.intensity.decompress(this.decoder, this.last.intensity, 0) & 0xffff;
|
|
1329
|
+
if (changedValues & 16)
|
|
1330
|
+
this.last.bitByte = this.decoder.decodeSymbol(this.bitByteModel[this.last.bitByte]);
|
|
1331
|
+
if (changedValues & 8)
|
|
1332
|
+
this.last.classification = this.decoder.decodeSymbol(this.classificationModel[this.last.classification]);
|
|
1333
|
+
if (changedValues & 4)
|
|
1334
|
+
this.last.scanAngleRank = toInt8(this.legacyScanAngle.decompress(this.decoder, this.last.scanAngleRank & 0xff, correctionBits < 3 ? 1 : 0));
|
|
1335
|
+
if (changedValues & 2)
|
|
1336
|
+
this.last.userData = this.decoder.decodeSymbol(this.userDataModel[this.last.userData]);
|
|
1337
|
+
if (changedValues & 1)
|
|
1338
|
+
this.last.pointSourceId =
|
|
1339
|
+
this.pointSourceId.decompress(this.decoder, this.last.pointSourceId, 0) & 0xffff;
|
|
1340
|
+
this.legacyXDiffs[this.legacyDifferenceIndex] = xDifference;
|
|
1341
|
+
this.legacyYDiffs[this.legacyDifferenceIndex] = yDifference;
|
|
1342
|
+
this.legacyDifferenceIndex = (this.legacyDifferenceIndex + 1) % 3;
|
|
1343
|
+
return this.last;
|
|
1344
|
+
}
|
|
1345
|
+
readFirstMetadata() {
|
|
1346
|
+
this.decoder.readInitBytes();
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
class RGB10Decompressor {
|
|
1350
|
+
itemVersion;
|
|
1351
|
+
stream;
|
|
1352
|
+
decoder;
|
|
1353
|
+
haveLast = false;
|
|
1354
|
+
lastRed = 0;
|
|
1355
|
+
lastGreen = 0;
|
|
1356
|
+
lastBlue = 0;
|
|
1357
|
+
usedModel = new ArithmeticModel(128);
|
|
1358
|
+
diffModel = createModels(6, 256);
|
|
1359
|
+
/** Version 1 per-channel byte correctors. */
|
|
1360
|
+
legacyRgb = null;
|
|
1361
|
+
constructor(stream, decoder,
|
|
1362
|
+
/** LASzip item codec version selected by the VLR. */ itemVersion = 2) {
|
|
1363
|
+
this.itemVersion = itemVersion;
|
|
1364
|
+
this.stream = stream;
|
|
1365
|
+
this.decoder = decoder;
|
|
1366
|
+
if (itemVersion === 1) {
|
|
1367
|
+
this.usedModel = new ArithmeticModel(64);
|
|
1368
|
+
this.legacyRgb = createIntegerDecompressor(8, 6);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
decompress(output, outputOffset) {
|
|
1372
|
+
this.decompressRgb();
|
|
1373
|
+
writeUint16(this.lastRed, output, outputOffset);
|
|
1374
|
+
writeUint16(this.lastGreen, output, outputOffset + 2);
|
|
1375
|
+
writeUint16(this.lastBlue, output, outputOffset + 4);
|
|
1376
|
+
return outputOffset + 6;
|
|
1377
|
+
}
|
|
1378
|
+
/** Decode one legacy RGB item without materializing raw point bytes. */
|
|
1379
|
+
decompressRgb() {
|
|
1380
|
+
if (!this.haveLast) {
|
|
1381
|
+
this.haveLast = true;
|
|
1382
|
+
this.lastRed = readUint16FromStream(this.stream);
|
|
1383
|
+
this.lastGreen = readUint16FromStream(this.stream);
|
|
1384
|
+
this.lastBlue = readUint16FromStream(this.stream);
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
const symbol = this.decoder.decodeSymbol(this.usedModel);
|
|
1388
|
+
if (this.itemVersion === 1) {
|
|
1389
|
+
this.lastRed = this.decodeLegacyColor(this.lastRed, 0, symbol);
|
|
1390
|
+
this.lastGreen = this.decodeLegacyColor(this.lastGreen, 1, symbol);
|
|
1391
|
+
this.lastBlue = this.decodeLegacyColor(this.lastBlue, 2, symbol);
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
let red = 0;
|
|
1395
|
+
let green = 0;
|
|
1396
|
+
let blue = 0;
|
|
1397
|
+
if (symbol & 1) {
|
|
1398
|
+
red = (this.decoder.decodeSymbol(this.diffModel[0]) + (this.lastRed & 0xff)) & 0xff;
|
|
1399
|
+
}
|
|
1400
|
+
else {
|
|
1401
|
+
red = this.lastRed & 0xff;
|
|
1402
|
+
}
|
|
1403
|
+
if (symbol & 2) {
|
|
1404
|
+
red |= ((this.decoder.decodeSymbol(this.diffModel[1]) + (this.lastRed >> 8)) & 0xff) << 8;
|
|
1405
|
+
}
|
|
1406
|
+
else {
|
|
1407
|
+
red |= this.lastRed & 0xff00;
|
|
1408
|
+
}
|
|
1409
|
+
if (symbol & 64) {
|
|
1410
|
+
let diff = (red & 0xff) - (this.lastRed & 0xff);
|
|
1411
|
+
if (symbol & 4) {
|
|
1412
|
+
green =
|
|
1413
|
+
(this.decoder.decodeSymbol(this.diffModel[2]) +
|
|
1414
|
+
clampUint8(diff + (this.lastGreen & 0xff))) &
|
|
1415
|
+
0xff;
|
|
1416
|
+
}
|
|
1417
|
+
else {
|
|
1418
|
+
green = this.lastGreen & 0xff;
|
|
1419
|
+
}
|
|
1420
|
+
if (symbol & 16) {
|
|
1421
|
+
diff = ((diff + ((green & 0xff) - (this.lastGreen & 0xff))) / 2) | 0;
|
|
1422
|
+
blue =
|
|
1423
|
+
(this.decoder.decodeSymbol(this.diffModel[4]) +
|
|
1424
|
+
clampUint8(diff + (this.lastBlue & 0xff))) &
|
|
1425
|
+
0xff;
|
|
1426
|
+
}
|
|
1427
|
+
else {
|
|
1428
|
+
blue = this.lastBlue & 0xff;
|
|
1429
|
+
}
|
|
1430
|
+
diff = (red >> 8) - (this.lastRed >> 8);
|
|
1431
|
+
if (symbol & 8) {
|
|
1432
|
+
green |=
|
|
1433
|
+
((this.decoder.decodeSymbol(this.diffModel[3]) +
|
|
1434
|
+
clampUint8(diff + (this.lastGreen >> 8))) &
|
|
1435
|
+
0xff) <<
|
|
1436
|
+
8;
|
|
1437
|
+
}
|
|
1438
|
+
else {
|
|
1439
|
+
green |= this.lastGreen & 0xff00;
|
|
1440
|
+
}
|
|
1441
|
+
if (symbol & 32) {
|
|
1442
|
+
diff = ((diff + (green >> 8) - (this.lastGreen >> 8)) / 2) | 0;
|
|
1443
|
+
blue |=
|
|
1444
|
+
((this.decoder.decodeSymbol(this.diffModel[5]) +
|
|
1445
|
+
clampUint8(diff + (this.lastBlue >> 8))) &
|
|
1446
|
+
0xff) <<
|
|
1447
|
+
8;
|
|
1448
|
+
}
|
|
1449
|
+
else {
|
|
1450
|
+
blue |= this.lastBlue & 0xff00;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
else {
|
|
1454
|
+
green = red;
|
|
1455
|
+
blue = red;
|
|
1456
|
+
}
|
|
1457
|
+
this.lastRed = red;
|
|
1458
|
+
this.lastGreen = green;
|
|
1459
|
+
this.lastBlue = blue;
|
|
1460
|
+
}
|
|
1461
|
+
/** Decode both independent integer-coded bytes of one version 1 color channel. */
|
|
1462
|
+
decodeLegacyColor(previousColor, channelIndex, changedBytes) {
|
|
1463
|
+
let color = 0;
|
|
1464
|
+
for (let byteIndex = 0; byteIndex < 2; byteIndex++) {
|
|
1465
|
+
const context = channelIndex * 2 + byteIndex;
|
|
1466
|
+
const previousByte = (previousColor >> (byteIndex * 8)) & 0xff;
|
|
1467
|
+
const decodedByte = changedBytes & (1 << context)
|
|
1468
|
+
? this.legacyRgb.decompress(this.decoder, previousByte, context)
|
|
1469
|
+
: previousByte;
|
|
1470
|
+
color |= decodedByte << (byteIndex * 8);
|
|
1471
|
+
}
|
|
1472
|
+
return color;
|
|
1473
|
+
}
|
|
1474
|
+
/** Most recently decoded red channel. */
|
|
1475
|
+
get decodedRed() {
|
|
1476
|
+
return this.lastRed;
|
|
1477
|
+
}
|
|
1478
|
+
/** Most recently decoded green channel. */
|
|
1479
|
+
get decodedGreen() {
|
|
1480
|
+
return this.lastGreen;
|
|
1481
|
+
}
|
|
1482
|
+
/** Most recently decoded blue channel. */
|
|
1483
|
+
get decodedBlue() {
|
|
1484
|
+
return this.lastBlue;
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
class Byte10Decompressor {
|
|
1488
|
+
itemVersion;
|
|
1489
|
+
stream;
|
|
1490
|
+
decoder;
|
|
1491
|
+
count;
|
|
1492
|
+
haveLast = false;
|
|
1493
|
+
last;
|
|
1494
|
+
models;
|
|
1495
|
+
/** Version 1 independent byte correctors, one context per Extra Byte. */
|
|
1496
|
+
legacyBytes;
|
|
1497
|
+
constructor(stream, decoder, count,
|
|
1498
|
+
/** LASzip item codec version selected by the VLR. */ itemVersion = 2) {
|
|
1499
|
+
this.itemVersion = itemVersion;
|
|
1500
|
+
this.stream = stream;
|
|
1501
|
+
this.decoder = decoder;
|
|
1502
|
+
this.count = count;
|
|
1503
|
+
this.last = new Uint8Array(count);
|
|
1504
|
+
this.models = createModels(count, 256);
|
|
1505
|
+
this.legacyBytes = itemVersion === 1 ? createIntegerDecompressor(8, count) : null;
|
|
1506
|
+
}
|
|
1507
|
+
/** Number of Extra Bytes stored for each point. */
|
|
1508
|
+
get byteCount() {
|
|
1509
|
+
return this.count;
|
|
1510
|
+
}
|
|
1511
|
+
decompress(output, outputOffset) {
|
|
1512
|
+
this.decompressToTarget(output, outputOffset);
|
|
1513
|
+
return outputOffset + this.count;
|
|
1514
|
+
}
|
|
1515
|
+
/** Decode legacy Extra Bytes directly into an optional caller-owned target. */
|
|
1516
|
+
decompressToTarget(output, outputOffset = 0) {
|
|
1517
|
+
if (this.count === 0) {
|
|
1518
|
+
return;
|
|
1519
|
+
}
|
|
1520
|
+
if (!this.haveLast) {
|
|
1521
|
+
this.stream.getBytes(this.last, 0, this.count);
|
|
1522
|
+
output?.set(this.last, outputOffset);
|
|
1523
|
+
this.haveLast = true;
|
|
1524
|
+
return;
|
|
1525
|
+
}
|
|
1526
|
+
for (let index = 0; index < this.count; index++) {
|
|
1527
|
+
const value = this.itemVersion === 1
|
|
1528
|
+
? this.legacyBytes.decompress(this.decoder, this.last[index], index)
|
|
1529
|
+
: (this.last[index] + this.decoder.decodeSymbol(this.models[index])) & 0xff;
|
|
1530
|
+
if (output) {
|
|
1531
|
+
output[outputOffset + index] = value;
|
|
1532
|
+
}
|
|
1533
|
+
this.last[index] = value;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
/** Determines whether Point14 decoding preserves every field or only returned point data. */
|
|
1538
|
+
var Point14DecompressionMode;
|
|
1539
|
+
(function (Point14DecompressionMode) {
|
|
1540
|
+
/** Preserve every field in the raw LAS point record. */
|
|
1541
|
+
Point14DecompressionMode[Point14DecompressionMode["Full"] = 0] = "Full";
|
|
1542
|
+
/** Decode only fields represented by {@link LAZPointDataTarget}. */
|
|
1543
|
+
Point14DecompressionMode[Point14DecompressionMode["PointData"] = 1] = "PointData";
|
|
1544
|
+
})(Point14DecompressionMode || (Point14DecompressionMode = {}));
|
|
1545
|
+
class Point14Context {
|
|
1546
|
+
changedValuesModel = createModels(8, 128);
|
|
1547
|
+
scannerChannelModel = new ArithmeticModel(3);
|
|
1548
|
+
returnNumberGpsSameModel = new ArithmeticModel(13);
|
|
1549
|
+
numberReturnsModel = createModels(16, 16);
|
|
1550
|
+
returnNumberModel = createModels(16, 16);
|
|
1551
|
+
classModel = [];
|
|
1552
|
+
flagModel = [];
|
|
1553
|
+
userDataModel = [];
|
|
1554
|
+
gpsTimeMultiModel;
|
|
1555
|
+
gpsTime0DiffModel;
|
|
1556
|
+
dx = createIntegerDecompressor(32, 2);
|
|
1557
|
+
dy = createIntegerDecompressor(32, 22);
|
|
1558
|
+
z = createIntegerDecompressor(32, 20);
|
|
1559
|
+
intensity = null;
|
|
1560
|
+
scanAngle;
|
|
1561
|
+
pointSourceId;
|
|
1562
|
+
gpsTime;
|
|
1563
|
+
haveLast = false;
|
|
1564
|
+
last = createPoint14();
|
|
1565
|
+
lastIntensity = [];
|
|
1566
|
+
lastZ = new Array(8).fill(0);
|
|
1567
|
+
lastXDiffMedian = Array.from({ length: 12 }, () => new StreamingMedian());
|
|
1568
|
+
lastYDiffMedian = Array.from({ length: 12 }, () => new StreamingMedian());
|
|
1569
|
+
lastGpsSequence = 0;
|
|
1570
|
+
nextGpsSequence = 0;
|
|
1571
|
+
lastGpsTime = [];
|
|
1572
|
+
lastGpsTimeDiff = [];
|
|
1573
|
+
multiExtremeCounter = [];
|
|
1574
|
+
gpsTimeChange = false;
|
|
1575
|
+
/** Construct context models required by the selected output mode. */
|
|
1576
|
+
constructor(mode, selection) {
|
|
1577
|
+
if (mode === Point14DecompressionMode.Full || selection?.classification) {
|
|
1578
|
+
this.classModel = createModels(64, 256);
|
|
1579
|
+
}
|
|
1580
|
+
if (mode === Point14DecompressionMode.Full || selection?.intensity) {
|
|
1581
|
+
this.intensity = createIntegerDecompressor(16, 4);
|
|
1582
|
+
this.lastIntensity = new Array(8).fill(0);
|
|
1583
|
+
}
|
|
1584
|
+
if (mode === Point14DecompressionMode.Full || selection?.userData) {
|
|
1585
|
+
this.userDataModel = createModels(64, 256);
|
|
1586
|
+
}
|
|
1587
|
+
if (mode === Point14DecompressionMode.Full || selection?.scanAngle) {
|
|
1588
|
+
this.scanAngle = createIntegerDecompressor(16, 2);
|
|
1589
|
+
}
|
|
1590
|
+
if (mode === Point14DecompressionMode.Full || selection?.pointSourceId) {
|
|
1591
|
+
this.pointSourceId = createIntegerDecompressor(16, 1);
|
|
1592
|
+
}
|
|
1593
|
+
if (mode === Point14DecompressionMode.Full || selection?.flags) {
|
|
1594
|
+
this.flagModel = createModels(64, 64);
|
|
1595
|
+
}
|
|
1596
|
+
if (mode === Point14DecompressionMode.Full || selection?.gpsTime) {
|
|
1597
|
+
this.gpsTimeMultiModel = new ArithmeticModel(515);
|
|
1598
|
+
this.gpsTime0DiffModel = new ArithmeticModel(5);
|
|
1599
|
+
this.gpsTime = createIntegerDecompressor(32, 9);
|
|
1600
|
+
this.lastGpsTime = new Array(4).fill(0);
|
|
1601
|
+
this.lastGpsTimeDiff = new Array(4).fill(0);
|
|
1602
|
+
this.multiExtremeCounter = new Array(4).fill(0);
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
class Point14Decompressor {
|
|
1607
|
+
stream;
|
|
1608
|
+
contexts;
|
|
1609
|
+
/** Current scanner-channel context, cached because channel switches are uncommon. */
|
|
1610
|
+
activeContext = null;
|
|
1611
|
+
/** Whether fields omitted from direct point-data output must be decoded. */
|
|
1612
|
+
decompressOptionalFields;
|
|
1613
|
+
xy = new ArithmeticDecoder();
|
|
1614
|
+
z = new ArithmeticDecoder();
|
|
1615
|
+
classification;
|
|
1616
|
+
flags;
|
|
1617
|
+
intensity;
|
|
1618
|
+
scanAngle;
|
|
1619
|
+
userData;
|
|
1620
|
+
pointSourceId;
|
|
1621
|
+
gpsTime;
|
|
1622
|
+
sizes = [];
|
|
1623
|
+
/** Actual scanner channel used by Point14 context state. */
|
|
1624
|
+
currentScannerChannel = 0;
|
|
1625
|
+
/** LASzip v3 item context emitted to fields following Point14. */
|
|
1626
|
+
itemContextChannel = 0;
|
|
1627
|
+
/** Point14 item version controlling downstream scanner-channel propagation. */
|
|
1628
|
+
itemVersion;
|
|
1629
|
+
constructor(stream, mode = Point14DecompressionMode.Full, itemVersion = 3, selection = null) {
|
|
1630
|
+
this.stream = stream;
|
|
1631
|
+
this.itemVersion = itemVersion;
|
|
1632
|
+
this.contexts = Array.from({ length: 4 }, () => new Point14Context(mode, selection));
|
|
1633
|
+
this.decompressOptionalFields = mode === Point14DecompressionMode.Full;
|
|
1634
|
+
this.classification =
|
|
1635
|
+
this.decompressOptionalFields || selection?.classification ? new ArithmeticDecoder() : null;
|
|
1636
|
+
this.flags = this.decompressOptionalFields || selection?.flags ? new ArithmeticDecoder() : null;
|
|
1637
|
+
this.intensity =
|
|
1638
|
+
this.decompressOptionalFields || selection?.intensity ? new ArithmeticDecoder() : null;
|
|
1639
|
+
this.scanAngle =
|
|
1640
|
+
this.decompressOptionalFields || selection?.scanAngle ? new ArithmeticDecoder() : null;
|
|
1641
|
+
this.userData =
|
|
1642
|
+
this.decompressOptionalFields || selection?.userData ? new ArithmeticDecoder() : null;
|
|
1643
|
+
this.pointSourceId =
|
|
1644
|
+
this.decompressOptionalFields || selection?.pointSourceId ? new ArithmeticDecoder() : null;
|
|
1645
|
+
this.gpsTime =
|
|
1646
|
+
this.decompressOptionalFields || selection?.gpsTime ? new ArithmeticDecoder() : null;
|
|
1647
|
+
}
|
|
1648
|
+
readSizes() {
|
|
1649
|
+
this.sizes = [];
|
|
1650
|
+
for (let index = 0; index < 9; index++) {
|
|
1651
|
+
this.sizes.push(this.stream.getUint32());
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
readData() {
|
|
1655
|
+
let index = 0;
|
|
1656
|
+
this.xy.initStream(this.stream, this.sizes[index++]);
|
|
1657
|
+
this.z.initStream(this.stream, this.sizes[index++]);
|
|
1658
|
+
this.initializeOptionalStream(this.classification, this.sizes[index++]);
|
|
1659
|
+
this.initializeOptionalStream(this.flags, this.sizes[index++]);
|
|
1660
|
+
this.initializeOptionalStream(this.intensity, this.sizes[index++]);
|
|
1661
|
+
this.initializeOptionalStream(this.scanAngle, this.sizes[index++]);
|
|
1662
|
+
this.initializeOptionalStream(this.userData, this.sizes[index++]);
|
|
1663
|
+
this.initializeOptionalStream(this.pointSourceId, this.sizes[index++]);
|
|
1664
|
+
this.initializeOptionalStream(this.gpsTime, this.sizes[index++]);
|
|
1665
|
+
}
|
|
1666
|
+
/** Initialize a retained field layer or consume its compressed range. */
|
|
1667
|
+
initializeOptionalStream(decoder, byteLength) {
|
|
1668
|
+
if (decoder) {
|
|
1669
|
+
decoder.initStream(this.stream, byteLength);
|
|
1670
|
+
}
|
|
1671
|
+
else {
|
|
1672
|
+
this.stream.consume(byteLength);
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
decompress(output, outputOffset) {
|
|
1676
|
+
const point = this.decompressPoint(output, outputOffset);
|
|
1677
|
+
writePoint14(point, output, outputOffset);
|
|
1678
|
+
return outputOffset + 30;
|
|
1679
|
+
}
|
|
1680
|
+
decompressPoint(output, outputOffset = 0) {
|
|
1681
|
+
const decompressGpsTime = this.gpsTime !== null;
|
|
1682
|
+
if (!this.activeContext) {
|
|
1683
|
+
const point = this.contexts[0].last;
|
|
1684
|
+
if (output) {
|
|
1685
|
+
this.stream.getBytes(output, outputOffset, 30);
|
|
1686
|
+
readPoint14Into(point, output, outputOffset);
|
|
1687
|
+
}
|
|
1688
|
+
else {
|
|
1689
|
+
readPoint14FromStreamInto(point, this.stream);
|
|
1690
|
+
}
|
|
1691
|
+
this.currentScannerChannel = getScannerChannel(point);
|
|
1692
|
+
this.itemContextChannel = this.currentScannerChannel;
|
|
1693
|
+
const context = this.contexts[this.currentScannerChannel];
|
|
1694
|
+
if (context.last !== point) {
|
|
1695
|
+
copyPoint14(context.last, point);
|
|
1696
|
+
}
|
|
1697
|
+
context.haveLast = true;
|
|
1698
|
+
if (decompressGpsTime) {
|
|
1699
|
+
context.lastGpsTime[0] = context.last.gpsTime;
|
|
1700
|
+
}
|
|
1701
|
+
this.activeContext = context;
|
|
1702
|
+
context.lastZ.fill(context.last.z);
|
|
1703
|
+
if (context.lastIntensity.length) {
|
|
1704
|
+
context.lastIntensity.fill(context.last.intensity);
|
|
1705
|
+
}
|
|
1706
|
+
return context.last;
|
|
1707
|
+
}
|
|
1708
|
+
const previous = this.activeContext;
|
|
1709
|
+
const previousReturns = previous.last.returns;
|
|
1710
|
+
const previousReturnNumber = previousReturns & 0x0f;
|
|
1711
|
+
const changeStream = (previousReturnNumber === 1 ? 1 : 0) |
|
|
1712
|
+
((previousReturnNumber >= previousReturns >> 4 ? 1 : 0) << 1) |
|
|
1713
|
+
((previous.gpsTimeChange ? 1 : 0) << 2);
|
|
1714
|
+
const changedValues = this.xy.decodeSymbol(previous.changedValuesModel[changeStream]);
|
|
1715
|
+
const scannerChannelChanged = Boolean((changedValues >> 6) & 1);
|
|
1716
|
+
const pointSourceChanged = Boolean((changedValues >> 5) & 1);
|
|
1717
|
+
const gpsTimeChanged = Boolean((changedValues >> 4) & 1);
|
|
1718
|
+
const scanAngleChanged = Boolean((changedValues >> 3) & 1);
|
|
1719
|
+
const numberReturnsChanged = Boolean((changedValues >> 2) & 1);
|
|
1720
|
+
const returnNumberMinus = Boolean((changedValues >> 1) & 1);
|
|
1721
|
+
const returnNumberPlus = Boolean(changedValues & 1);
|
|
1722
|
+
const returnNumberIncrements = returnNumberPlus && !returnNumberMinus;
|
|
1723
|
+
const returnNumberDecrements = returnNumberMinus && !returnNumberPlus;
|
|
1724
|
+
const returnNumberMiscChange = returnNumberPlus && returnNumberMinus;
|
|
1725
|
+
this.itemContextChannel = 0;
|
|
1726
|
+
let scannerChannel = this.currentScannerChannel;
|
|
1727
|
+
let context = previous;
|
|
1728
|
+
if (scannerChannelChanged) {
|
|
1729
|
+
const diff = this.xy.decodeSymbol(previous.scannerChannelModel);
|
|
1730
|
+
scannerChannel = (scannerChannel + diff + 1) % 4;
|
|
1731
|
+
context = this.contexts[scannerChannel];
|
|
1732
|
+
this.activeContext = context;
|
|
1733
|
+
this.itemContextChannel = scannerChannel;
|
|
1734
|
+
}
|
|
1735
|
+
this.currentScannerChannel = scannerChannel;
|
|
1736
|
+
if (this.itemVersion >= 4) {
|
|
1737
|
+
this.itemContextChannel = scannerChannel;
|
|
1738
|
+
}
|
|
1739
|
+
if (!context.haveLast) {
|
|
1740
|
+
context.haveLast = true;
|
|
1741
|
+
copyPoint14(context.last, previous.last);
|
|
1742
|
+
context.lastZ.fill(previous.last.z);
|
|
1743
|
+
if (context.lastIntensity.length) {
|
|
1744
|
+
context.lastIntensity.fill(previous.last.intensity);
|
|
1745
|
+
}
|
|
1746
|
+
if (decompressGpsTime) {
|
|
1747
|
+
context.lastGpsTime[0] = previous.last.gpsTime;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
setScannerChannel(context.last, scannerChannel);
|
|
1751
|
+
let numberOfReturns = context.last.returns >> 4;
|
|
1752
|
+
let returnNumber = context.last.returns & 0x0f;
|
|
1753
|
+
if (numberReturnsChanged) {
|
|
1754
|
+
numberOfReturns = this.xy.decodeSymbol(context.numberReturnsModel[numberOfReturns]);
|
|
1755
|
+
}
|
|
1756
|
+
if (returnNumberIncrements) {
|
|
1757
|
+
returnNumber = (returnNumber + 1) % 16;
|
|
1758
|
+
}
|
|
1759
|
+
else if (returnNumberDecrements) {
|
|
1760
|
+
returnNumber = (returnNumber + 15) % 16;
|
|
1761
|
+
}
|
|
1762
|
+
else if (returnNumberMiscChange) {
|
|
1763
|
+
returnNumber = gpsTimeChanged
|
|
1764
|
+
? this.xy.decodeSymbol(context.returnNumberModel[returnNumber])
|
|
1765
|
+
: (returnNumber + this.xy.decodeSymbol(context.returnNumberGpsSameModel) + 2) % 16;
|
|
1766
|
+
}
|
|
1767
|
+
context.last.returns = (numberOfReturns << 4) | returnNumber;
|
|
1768
|
+
const xyContext = (NUMBER_RETURN_MAP_6_CONTEXT[numberOfReturns][returnNumber] << 1) | (gpsTimeChanged ? 1 : 0);
|
|
1769
|
+
const xMedian = context.lastXDiffMedian[xyContext].get();
|
|
1770
|
+
const xDiff = context.dx.decompress(this.xy, xMedian, numberOfReturns === 1 ? 1 : 0);
|
|
1771
|
+
context.last.x = toInt32(context.last.x + xDiff);
|
|
1772
|
+
context.lastXDiffMedian[xyContext].add(xDiff);
|
|
1773
|
+
const yKbits = Math.min(context.dx.k, 20) & ~1;
|
|
1774
|
+
const yMedian = context.lastYDiffMedian[xyContext].get();
|
|
1775
|
+
const yDiff = context.dy.decompress(this.xy, yMedian, (numberOfReturns === 1 ? 1 : 0) | yKbits);
|
|
1776
|
+
context.last.y = toInt32(context.last.y + yDiff);
|
|
1777
|
+
context.lastYDiffMedian[xyContext].add(yDiff);
|
|
1778
|
+
if (this.z.valid) {
|
|
1779
|
+
const kbits = Math.min((context.dx.k + context.dy.k) >> 1, 18) & ~1;
|
|
1780
|
+
const zContext = NUMBER_RETURN_LEVEL_8_CONTEXT[numberOfReturns][returnNumber];
|
|
1781
|
+
const z = context.z.decompress(this.z, context.lastZ[zContext], (numberOfReturns === 1 ? 1 : 0) | kbits);
|
|
1782
|
+
context.last.z = z;
|
|
1783
|
+
context.lastZ[zContext] = z;
|
|
1784
|
+
}
|
|
1785
|
+
if (this.classification?.valid) {
|
|
1786
|
+
const classContext = (returnNumber === 1 && returnNumber >= numberOfReturns ? 1 : 0) |
|
|
1787
|
+
((context.last.classification & 0x1f) << 1);
|
|
1788
|
+
context.last.classification = this.classification.decodeSymbol(context.classModel[classContext]);
|
|
1789
|
+
}
|
|
1790
|
+
if (this.flags?.valid) {
|
|
1791
|
+
const mergedFlags = mergeFlags(context.last);
|
|
1792
|
+
const flags = this.flags.decodeSymbol(context.flagModel[mergedFlags]);
|
|
1793
|
+
setEdgeOfFlightLine(context.last, (flags >> 5) & 1);
|
|
1794
|
+
setScanDirectionFlag(context.last, (flags >> 4) & 1);
|
|
1795
|
+
setClassFlags(context.last, flags & 0x0f);
|
|
1796
|
+
}
|
|
1797
|
+
if (this.intensity?.valid) {
|
|
1798
|
+
const intensityContext = (gpsTimeChanged ? 1 : 0) |
|
|
1799
|
+
((returnNumber >= numberOfReturns ? 1 : 0) << 1) |
|
|
1800
|
+
((returnNumber === 1 ? 1 : 0) << 2);
|
|
1801
|
+
const intensity = context.intensity.decompress(this.intensity, context.lastIntensity[intensityContext], intensityContext >> 1);
|
|
1802
|
+
context.lastIntensity[intensityContext] = intensity & 0xffff;
|
|
1803
|
+
context.last.intensity = intensity & 0xffff;
|
|
1804
|
+
}
|
|
1805
|
+
if (scanAngleChanged && this.scanAngle) {
|
|
1806
|
+
context.last.scanAngle = toInt16(context.scanAngle.decompress(this.scanAngle, context.last.scanAngle, gpsTimeChanged ? 1 : 0));
|
|
1807
|
+
}
|
|
1808
|
+
if (this.userData?.valid) {
|
|
1809
|
+
const userDataContext = context.last.userData >> 2;
|
|
1810
|
+
context.last.userData = this.userData.decodeSymbol(context.userDataModel[userDataContext]);
|
|
1811
|
+
}
|
|
1812
|
+
if (pointSourceChanged && this.pointSourceId) {
|
|
1813
|
+
context.last.pointSourceId =
|
|
1814
|
+
context.pointSourceId.decompress(this.pointSourceId, context.last.pointSourceId, 0) &
|
|
1815
|
+
0xffff;
|
|
1816
|
+
}
|
|
1817
|
+
if (gpsTimeChanged && this.gpsTime) {
|
|
1818
|
+
this.decodeGpsTime(context);
|
|
1819
|
+
}
|
|
1820
|
+
context.gpsTimeChange = gpsTimeChanged;
|
|
1821
|
+
return context.last;
|
|
1822
|
+
}
|
|
1823
|
+
decodeGpsTime(context) {
|
|
1824
|
+
const gpsTime = this.gpsTime;
|
|
1825
|
+
while (true) {
|
|
1826
|
+
if (context.lastGpsTimeDiff[context.lastGpsSequence] === 0) {
|
|
1827
|
+
const multi = gpsTime.decodeSymbol(context.gpsTime0DiffModel);
|
|
1828
|
+
if (multi === 0) {
|
|
1829
|
+
const symbol = context.gpsTime.decompress(gpsTime, 0, 0);
|
|
1830
|
+
context.lastGpsTimeDiff[context.lastGpsSequence] = symbol;
|
|
1831
|
+
context.lastGpsTime[context.lastGpsSequence] = addInt32ToFloat64Bits(context.lastGpsTime[context.lastGpsSequence], symbol);
|
|
1832
|
+
context.multiExtremeCounter[context.lastGpsSequence] = 0;
|
|
1833
|
+
}
|
|
1834
|
+
else if (multi === 1) {
|
|
1835
|
+
context.nextGpsSequence = (context.nextGpsSequence + 1) & 3;
|
|
1836
|
+
const lastTimeBits = float64ToBigUint64(context.lastGpsTime[context.lastGpsSequence]);
|
|
1837
|
+
const upper = context.gpsTime.decompress(gpsTime, Number(lastTimeBits >> 32n) | 0, 8);
|
|
1838
|
+
const lower = gpsTime.readInt();
|
|
1839
|
+
context.lastGpsTime[context.nextGpsSequence] = bigUint64ToFloat64((BigInt(upper >>> 0) << 32n) | BigInt(lower));
|
|
1840
|
+
context.lastGpsSequence = context.nextGpsSequence;
|
|
1841
|
+
context.lastGpsTimeDiff[context.lastGpsSequence] = 0;
|
|
1842
|
+
context.multiExtremeCounter[context.lastGpsSequence] = 0;
|
|
1843
|
+
}
|
|
1844
|
+
else {
|
|
1845
|
+
context.lastGpsSequence = (context.lastGpsSequence + multi - 1) & 3;
|
|
1846
|
+
continue;
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
else {
|
|
1850
|
+
let multi = gpsTime.decodeSymbol(context.gpsTimeMultiModel);
|
|
1851
|
+
let gpsTimeDiff = 0;
|
|
1852
|
+
if (multi === 1) {
|
|
1853
|
+
const symbol = context.gpsTime.decompress(gpsTime, context.lastGpsTimeDiff[context.lastGpsSequence], 1);
|
|
1854
|
+
context.lastGpsTime[context.lastGpsSequence] = addInt32ToFloat64Bits(context.lastGpsTime[context.lastGpsSequence], symbol);
|
|
1855
|
+
context.multiExtremeCounter[context.lastGpsSequence] = 0;
|
|
1856
|
+
}
|
|
1857
|
+
else if (multi < GPS_TIME_MULTI_CODE_FULL) {
|
|
1858
|
+
if (multi === 0) {
|
|
1859
|
+
gpsTimeDiff = context.gpsTime.decompress(gpsTime, 0, 7);
|
|
1860
|
+
context.multiExtremeCounter[context.lastGpsSequence]++;
|
|
1861
|
+
if (context.multiExtremeCounter[context.lastGpsSequence] > 3) {
|
|
1862
|
+
context.multiExtremeCounter[context.lastGpsSequence] = 0;
|
|
1863
|
+
context.lastGpsTimeDiff[context.lastGpsSequence] = gpsTimeDiff;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
else if (multi < GPS_TIME_MULTI) {
|
|
1867
|
+
const tag = multi < 10 ? 2 : 3;
|
|
1868
|
+
gpsTimeDiff = context.gpsTime.decompress(gpsTime, multi * context.lastGpsTimeDiff[context.lastGpsSequence], tag);
|
|
1869
|
+
}
|
|
1870
|
+
else if (multi === GPS_TIME_MULTI) {
|
|
1871
|
+
gpsTimeDiff = context.gpsTime.decompress(gpsTime, GPS_TIME_MULTI * context.lastGpsTimeDiff[context.lastGpsSequence], 4);
|
|
1872
|
+
context.multiExtremeCounter[context.lastGpsSequence]++;
|
|
1873
|
+
if (context.multiExtremeCounter[context.lastGpsSequence] > 3) {
|
|
1874
|
+
context.multiExtremeCounter[context.lastGpsSequence] = 0;
|
|
1875
|
+
context.lastGpsTimeDiff[context.lastGpsSequence] = gpsTimeDiff;
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
else {
|
|
1879
|
+
multi = GPS_TIME_MULTI - multi;
|
|
1880
|
+
if (multi > GPS_TIME_MULTI_MINUS) {
|
|
1881
|
+
gpsTimeDiff = context.gpsTime.decompress(gpsTime, multi * context.lastGpsTimeDiff[context.lastGpsSequence], 5);
|
|
1882
|
+
}
|
|
1883
|
+
else {
|
|
1884
|
+
gpsTimeDiff = context.gpsTime.decompress(gpsTime, GPS_TIME_MULTI_MINUS * context.lastGpsTimeDiff[context.lastGpsSequence], 6);
|
|
1885
|
+
context.multiExtremeCounter[context.lastGpsSequence]++;
|
|
1886
|
+
if (context.multiExtremeCounter[context.lastGpsSequence] > 3) {
|
|
1887
|
+
context.multiExtremeCounter[context.lastGpsSequence] = 0;
|
|
1888
|
+
context.lastGpsTimeDiff[context.lastGpsSequence] = gpsTimeDiff;
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
context.lastGpsTime[context.lastGpsSequence] = addInt32ToFloat64Bits(context.lastGpsTime[context.lastGpsSequence], gpsTimeDiff);
|
|
1893
|
+
}
|
|
1894
|
+
else if (multi === GPS_TIME_MULTI_CODE_FULL) {
|
|
1895
|
+
context.nextGpsSequence = (context.nextGpsSequence + 1) & 3;
|
|
1896
|
+
const lastTimeBits = float64ToBigUint64(context.lastGpsTime[context.lastGpsSequence]);
|
|
1897
|
+
const upper = context.gpsTime.decompress(gpsTime, Number(lastTimeBits >> 32n) | 0, 8);
|
|
1898
|
+
const lower = gpsTime.readInt();
|
|
1899
|
+
context.lastGpsTime[context.nextGpsSequence] = bigUint64ToFloat64((BigInt(upper >>> 0) << 32n) | BigInt(lower));
|
|
1900
|
+
context.lastGpsSequence = context.nextGpsSequence;
|
|
1901
|
+
context.lastGpsTimeDiff[context.lastGpsSequence] = 0;
|
|
1902
|
+
context.multiExtremeCounter[context.lastGpsSequence] = 0;
|
|
1903
|
+
}
|
|
1904
|
+
else if (multi >= GPS_TIME_MULTI_CODE_FULL) {
|
|
1905
|
+
context.lastGpsSequence =
|
|
1906
|
+
(context.lastGpsSequence + multi - GPS_TIME_MULTI_CODE_FULL) & 3;
|
|
1907
|
+
continue;
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
context.last.gpsTime = context.lastGpsTime[context.lastGpsSequence];
|
|
1911
|
+
break;
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
class RGB14Context {
|
|
1916
|
+
haveLast = false;
|
|
1917
|
+
lastRed = 0;
|
|
1918
|
+
lastGreen = 0;
|
|
1919
|
+
lastBlue = 0;
|
|
1920
|
+
usedModel = new ArithmeticModel(128);
|
|
1921
|
+
diffModel = createModels(6, 256);
|
|
1922
|
+
}
|
|
1923
|
+
class RGB14Decompressor {
|
|
1924
|
+
stream;
|
|
1925
|
+
contexts = Array.from({ length: 4 }, () => new RGB14Context());
|
|
1926
|
+
/** Current scanner-channel context, cached because channel switches are uncommon. */
|
|
1927
|
+
activeContext = null;
|
|
1928
|
+
lastChannel = -1;
|
|
1929
|
+
rgbCount = 0;
|
|
1930
|
+
rgb = new ArithmeticDecoder();
|
|
1931
|
+
decodedRed = 0;
|
|
1932
|
+
decodedGreen = 0;
|
|
1933
|
+
decodedBlue = 0;
|
|
1934
|
+
/** RGB item version controlling scanner-channel predictor selection. */
|
|
1935
|
+
itemVersion;
|
|
1936
|
+
constructor(stream, itemVersion = 3) {
|
|
1937
|
+
this.stream = stream;
|
|
1938
|
+
this.itemVersion = itemVersion;
|
|
1939
|
+
}
|
|
1940
|
+
readSizes() {
|
|
1941
|
+
this.rgbCount = this.stream.getUint32();
|
|
1942
|
+
}
|
|
1943
|
+
readData() {
|
|
1944
|
+
this.rgb.initStream(this.stream, this.rgbCount);
|
|
1945
|
+
}
|
|
1946
|
+
decompress(output, outputOffset, scannerChannel) {
|
|
1947
|
+
this.decompressRgb(scannerChannel);
|
|
1948
|
+
writeUint16(this.decodedRed, output, outputOffset);
|
|
1949
|
+
writeUint16(this.decodedGreen, output, outputOffset + 2);
|
|
1950
|
+
writeUint16(this.decodedBlue, output, outputOffset + 4);
|
|
1951
|
+
return outputOffset + 6;
|
|
1952
|
+
}
|
|
1953
|
+
decompressRgb(scannerChannel) {
|
|
1954
|
+
if (this.lastChannel === -1) {
|
|
1955
|
+
this.decodedRed = this.stream.getByte() | (this.stream.getByte() << 8);
|
|
1956
|
+
this.decodedGreen = this.stream.getByte() | (this.stream.getByte() << 8);
|
|
1957
|
+
this.decodedBlue = this.stream.getByte() | (this.stream.getByte() << 8);
|
|
1958
|
+
const context = this.contexts[scannerChannel];
|
|
1959
|
+
context.lastRed = this.decodedRed;
|
|
1960
|
+
context.lastGreen = this.decodedGreen;
|
|
1961
|
+
context.lastBlue = this.decodedBlue;
|
|
1962
|
+
context.haveLast = true;
|
|
1963
|
+
this.lastChannel = scannerChannel;
|
|
1964
|
+
this.activeContext = context;
|
|
1965
|
+
return;
|
|
1966
|
+
}
|
|
1967
|
+
if (this.rgbCount === 0) {
|
|
1968
|
+
const context = this.activeContext;
|
|
1969
|
+
this.decodedRed = context.lastRed;
|
|
1970
|
+
this.decodedGreen = context.lastGreen;
|
|
1971
|
+
this.decodedBlue = context.lastBlue;
|
|
1972
|
+
return;
|
|
1973
|
+
}
|
|
1974
|
+
let context = this.activeContext;
|
|
1975
|
+
let lastContext = context;
|
|
1976
|
+
if (scannerChannel !== this.lastChannel) {
|
|
1977
|
+
const previous = context;
|
|
1978
|
+
context = this.contexts[scannerChannel];
|
|
1979
|
+
lastContext = previous;
|
|
1980
|
+
this.lastChannel = scannerChannel;
|
|
1981
|
+
if (!context.haveLast) {
|
|
1982
|
+
context.haveLast = true;
|
|
1983
|
+
context.lastRed = previous.lastRed;
|
|
1984
|
+
context.lastGreen = previous.lastGreen;
|
|
1985
|
+
context.lastBlue = previous.lastBlue;
|
|
1986
|
+
lastContext = context;
|
|
1987
|
+
}
|
|
1988
|
+
if (this.itemVersion >= 4) {
|
|
1989
|
+
lastContext = context;
|
|
1990
|
+
}
|
|
1991
|
+
this.activeContext = context;
|
|
1992
|
+
}
|
|
1993
|
+
const symbol = this.rgb.decodeSymbol(context.usedModel);
|
|
1994
|
+
let red = 0;
|
|
1995
|
+
let green = 0;
|
|
1996
|
+
let blue = 0;
|
|
1997
|
+
if (symbol & 1) {
|
|
1998
|
+
const correction = this.rgb.decodeSymbol(context.diffModel[0]);
|
|
1999
|
+
red = (correction + (lastContext.lastRed & 0xff)) & 0xff;
|
|
2000
|
+
}
|
|
2001
|
+
else {
|
|
2002
|
+
red = lastContext.lastRed & 0xff;
|
|
2003
|
+
}
|
|
2004
|
+
if (symbol & 2) {
|
|
2005
|
+
const correction = this.rgb.decodeSymbol(context.diffModel[1]);
|
|
2006
|
+
red |= ((correction + (lastContext.lastRed >> 8)) & 0xff) << 8;
|
|
2007
|
+
}
|
|
2008
|
+
else {
|
|
2009
|
+
red |= lastContext.lastRed & 0xff00;
|
|
2010
|
+
}
|
|
2011
|
+
if (symbol & 64) {
|
|
2012
|
+
let diff = (red & 0xff) - (lastContext.lastRed & 0xff);
|
|
2013
|
+
if (symbol & 4) {
|
|
2014
|
+
const correction = this.rgb.decodeSymbol(context.diffModel[2]);
|
|
2015
|
+
green = (correction + clampUint8(diff + (lastContext.lastGreen & 0xff))) & 0xff;
|
|
2016
|
+
}
|
|
2017
|
+
else {
|
|
2018
|
+
green = lastContext.lastGreen & 0xff;
|
|
2019
|
+
}
|
|
2020
|
+
if (symbol & 16) {
|
|
2021
|
+
const correction = this.rgb.decodeSymbol(context.diffModel[4]);
|
|
2022
|
+
diff = ((diff + ((green & 0xff) - (lastContext.lastGreen & 0xff))) / 2) | 0;
|
|
2023
|
+
blue = (correction + clampUint8(diff + (lastContext.lastBlue & 0xff))) & 0xff;
|
|
2024
|
+
}
|
|
2025
|
+
else {
|
|
2026
|
+
blue = lastContext.lastBlue & 0xff;
|
|
2027
|
+
}
|
|
2028
|
+
diff = (red >> 8) - (lastContext.lastRed >> 8);
|
|
2029
|
+
if (symbol & 8) {
|
|
2030
|
+
const correction = this.rgb.decodeSymbol(context.diffModel[3]);
|
|
2031
|
+
green |= ((correction + clampUint8(diff + (lastContext.lastGreen >> 8))) & 0xff) << 8;
|
|
2032
|
+
}
|
|
2033
|
+
else {
|
|
2034
|
+
green |= lastContext.lastGreen & 0xff00;
|
|
2035
|
+
}
|
|
2036
|
+
if (symbol & 32) {
|
|
2037
|
+
const correction = this.rgb.decodeSymbol(context.diffModel[5]);
|
|
2038
|
+
diff = ((diff + (green >> 8) - (lastContext.lastGreen >> 8)) / 2) | 0;
|
|
2039
|
+
blue |= ((correction + clampUint8(diff + (lastContext.lastBlue >> 8))) & 0xff) << 8;
|
|
2040
|
+
}
|
|
2041
|
+
else {
|
|
2042
|
+
blue |= lastContext.lastBlue & 0xff00;
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
else {
|
|
2046
|
+
green = red;
|
|
2047
|
+
blue = red;
|
|
2048
|
+
}
|
|
2049
|
+
lastContext.lastRed = red;
|
|
2050
|
+
lastContext.lastGreen = green;
|
|
2051
|
+
lastContext.lastBlue = blue;
|
|
2052
|
+
this.decodedRed = red;
|
|
2053
|
+
this.decodedGreen = green;
|
|
2054
|
+
this.decodedBlue = blue;
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
class NIR14Context {
|
|
2058
|
+
haveLast = false;
|
|
2059
|
+
lastValue = 0;
|
|
2060
|
+
usedModel = new ArithmeticModel(4);
|
|
2061
|
+
diffModel = createModels(2, 256);
|
|
2062
|
+
}
|
|
2063
|
+
class NIR14Decompressor {
|
|
2064
|
+
stream;
|
|
2065
|
+
contexts = Array.from({ length: 4 }, () => new NIR14Context());
|
|
2066
|
+
lastChannel = -1;
|
|
2067
|
+
nirCount = 0;
|
|
2068
|
+
nir = new ArithmeticDecoder();
|
|
2069
|
+
scratch = new Uint8Array(2);
|
|
2070
|
+
/** Most recently decoded NIR value for direct point-data output. */
|
|
2071
|
+
decodedNir = 0;
|
|
2072
|
+
/** RGBNIR item version controlling scanner-channel predictor selection. */
|
|
2073
|
+
itemVersion;
|
|
2074
|
+
constructor(stream, itemVersion = 3) {
|
|
2075
|
+
this.stream = stream;
|
|
2076
|
+
this.itemVersion = itemVersion;
|
|
2077
|
+
}
|
|
2078
|
+
readSizes() {
|
|
2079
|
+
this.nirCount = this.stream.getUint32();
|
|
2080
|
+
}
|
|
2081
|
+
readData() {
|
|
2082
|
+
this.nir.initStream(this.stream, this.nirCount);
|
|
2083
|
+
}
|
|
2084
|
+
decompress(output, outputOffset, scannerChannel) {
|
|
2085
|
+
if (this.lastChannel === -1) {
|
|
2086
|
+
this.stream.getBytes(output, outputOffset, 2);
|
|
2087
|
+
const context = this.contexts[scannerChannel];
|
|
2088
|
+
context.lastValue = readUint16(output, outputOffset);
|
|
2089
|
+
context.haveLast = true;
|
|
2090
|
+
this.lastChannel = scannerChannel;
|
|
2091
|
+
this.decodedNir = context.lastValue;
|
|
2092
|
+
return outputOffset + 2;
|
|
2093
|
+
}
|
|
2094
|
+
if (this.nirCount === 0) {
|
|
2095
|
+
writeUint16(this.contexts[this.lastChannel].lastValue, output, outputOffset);
|
|
2096
|
+
this.decodedNir = this.contexts[this.lastChannel].lastValue;
|
|
2097
|
+
return outputOffset + 2;
|
|
2098
|
+
}
|
|
2099
|
+
const context = this.contexts[scannerChannel];
|
|
2100
|
+
let lastContext = this.contexts[this.lastChannel];
|
|
2101
|
+
if (scannerChannel !== this.lastChannel) {
|
|
2102
|
+
this.lastChannel = scannerChannel;
|
|
2103
|
+
if (!context.haveLast) {
|
|
2104
|
+
context.haveLast = true;
|
|
2105
|
+
context.lastValue = lastContext.lastValue;
|
|
2106
|
+
lastContext = context;
|
|
2107
|
+
}
|
|
2108
|
+
if (this.itemVersion >= 4) {
|
|
2109
|
+
lastContext = context;
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
const symbol = this.nir.decodeSymbol(context.usedModel);
|
|
2113
|
+
let value = symbol & 1
|
|
2114
|
+
? (this.nir.decodeSymbol(context.diffModel[0]) + (lastContext.lastValue & 0xff)) & 0xff
|
|
2115
|
+
: lastContext.lastValue & 0xff;
|
|
2116
|
+
value |=
|
|
2117
|
+
symbol & 2
|
|
2118
|
+
? ((this.nir.decodeSymbol(context.diffModel[1]) + (lastContext.lastValue >> 8)) & 0xff) << 8
|
|
2119
|
+
: lastContext.lastValue & 0xff00;
|
|
2120
|
+
lastContext.lastValue = value;
|
|
2121
|
+
this.decodedNir = value;
|
|
2122
|
+
writeUint16(value, output, outputOffset);
|
|
2123
|
+
return outputOffset + 2;
|
|
2124
|
+
}
|
|
2125
|
+
/** Decode one NIR value without allocating a temporary point record. */
|
|
2126
|
+
decompressNir(scannerChannel) {
|
|
2127
|
+
this.decompress(this.scratch, 0, scannerChannel);
|
|
2128
|
+
return this.decodedNir;
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
/** Arithmetic state and last waveform packet reference for one scanner channel. */
|
|
2132
|
+
class WavePacketDecompressionContext {
|
|
2133
|
+
/** Whether this scanner channel has inherited or decoded a waveform reference. */
|
|
2134
|
+
haveLast = false;
|
|
2135
|
+
/** Last waveform packet descriptor index. */
|
|
2136
|
+
descriptorIndex = 0;
|
|
2137
|
+
/** Last waveform packet byte offset, kept losslessly as an unsigned 64-bit integer. */
|
|
2138
|
+
offset = 0n;
|
|
2139
|
+
/** Last waveform packet byte size. */
|
|
2140
|
+
packetSize = 0;
|
|
2141
|
+
/** Raw IEEE-754 bits for the last return-point location. */
|
|
2142
|
+
returnPointBits = 0;
|
|
2143
|
+
/** Raw IEEE-754 bits for the last waveform X vector component. */
|
|
2144
|
+
xBits = 0;
|
|
2145
|
+
/** Raw IEEE-754 bits for the last waveform Y vector component. */
|
|
2146
|
+
yBits = 0;
|
|
2147
|
+
/** Raw IEEE-754 bits for the last waveform Z vector component. */
|
|
2148
|
+
zBits = 0;
|
|
2149
|
+
/** Last signed 32-bit offset difference used by the integer predictor. */
|
|
2150
|
+
lastOffsetDifference = 0;
|
|
2151
|
+
/** Last offset coding symbol, which selects the next four-symbol model. */
|
|
2152
|
+
lastOffsetDifferenceSymbol = 0;
|
|
2153
|
+
/** Waveform descriptor arithmetic model. */
|
|
2154
|
+
descriptorModel = new ArithmeticModel(256);
|
|
2155
|
+
/** Context-dependent waveform offset coding models. */
|
|
2156
|
+
offsetDifferenceModels = createModels(4, 4);
|
|
2157
|
+
/** Integer decompressor for signed waveform offset differences. */
|
|
2158
|
+
offsetDifferenceDecompressor = createIntegerDecompressor(32, 1);
|
|
2159
|
+
/** Integer decompressor for waveform packet sizes. */
|
|
2160
|
+
packetSizeDecompressor = createIntegerDecompressor(32, 1);
|
|
2161
|
+
/** Integer decompressor for raw return-point float bits. */
|
|
2162
|
+
returnPointDecompressor = createIntegerDecompressor(32, 1);
|
|
2163
|
+
/** Shared three-context decompressor for raw X, Y, and Z float bits. */
|
|
2164
|
+
vectorDecompressor = createIntegerDecompressor(32, 3);
|
|
2165
|
+
}
|
|
2166
|
+
/** Decoder for the independent LASzip 1.4 waveform packet reference layer. */
|
|
2167
|
+
class WavePacket14Decompressor {
|
|
2168
|
+
/** Compressed chunk source. */
|
|
2169
|
+
stream;
|
|
2170
|
+
/** Per-scanner-channel arithmetic and prediction state. */
|
|
2171
|
+
contexts = Array.from({ length: 4 }, () => new WavePacketDecompressionContext());
|
|
2172
|
+
/** Scanner channel used by the previous point. */
|
|
2173
|
+
lastChannel = -1;
|
|
2174
|
+
/** Compressed waveform layer byte length. */
|
|
2175
|
+
wavePacketByteCount = 0;
|
|
2176
|
+
/** Arithmetic decoder bounded to the waveform layer. */
|
|
2177
|
+
decoder = new ArithmeticDecoder();
|
|
2178
|
+
/** WavePacket14 item version selected by the LASzip VLR. */
|
|
2179
|
+
itemVersion;
|
|
2180
|
+
constructor(stream, itemVersion) {
|
|
2181
|
+
this.stream = stream;
|
|
2182
|
+
this.itemVersion = itemVersion;
|
|
2183
|
+
}
|
|
2184
|
+
/** Read the compressed waveform layer byte length. */
|
|
2185
|
+
readSizes() {
|
|
2186
|
+
this.wavePacketByteCount = this.stream.getUint32();
|
|
2187
|
+
}
|
|
2188
|
+
/** Bind the arithmetic decoder to the compressed waveform layer. */
|
|
2189
|
+
readData() {
|
|
2190
|
+
this.decoder.initStream(this.stream, this.wavePacketByteCount);
|
|
2191
|
+
}
|
|
2192
|
+
/** Decode one 29-byte LAS waveform packet reference. */
|
|
2193
|
+
decompress(output, outputOffset, scannerChannel) {
|
|
2194
|
+
if (this.lastChannel === -1) {
|
|
2195
|
+
this.stream.getBytes(output, outputOffset, 29);
|
|
2196
|
+
const context = this.contexts[scannerChannel];
|
|
2197
|
+
this.readContext(context, output, outputOffset);
|
|
2198
|
+
context.haveLast = true;
|
|
2199
|
+
this.lastChannel = scannerChannel;
|
|
2200
|
+
return outputOffset + 29;
|
|
2201
|
+
}
|
|
2202
|
+
const previousContext = this.contexts[this.lastChannel];
|
|
2203
|
+
const context = this.contexts[scannerChannel];
|
|
2204
|
+
let lastWavePacketContext = context;
|
|
2205
|
+
if (scannerChannel !== this.lastChannel) {
|
|
2206
|
+
lastWavePacketContext = previousContext;
|
|
2207
|
+
if (!context.haveLast) {
|
|
2208
|
+
this.copyLastWavePacket(context, previousContext);
|
|
2209
|
+
context.haveLast = true;
|
|
2210
|
+
lastWavePacketContext = context;
|
|
2211
|
+
}
|
|
2212
|
+
else if (this.itemVersion >= 4) {
|
|
2213
|
+
lastWavePacketContext = context;
|
|
2214
|
+
}
|
|
2215
|
+
this.lastChannel = scannerChannel;
|
|
2216
|
+
}
|
|
2217
|
+
if (this.wavePacketByteCount) {
|
|
2218
|
+
this.decodeContext(context, lastWavePacketContext);
|
|
2219
|
+
}
|
|
2220
|
+
this.writeContext(lastWavePacketContext, output, outputOffset);
|
|
2221
|
+
return outputOffset + 29;
|
|
2222
|
+
}
|
|
2223
|
+
/** Decode one waveform packet reference into a caller-owned 29-byte buffer. */
|
|
2224
|
+
decompressToTarget(target, targetOffset, scannerChannel) {
|
|
2225
|
+
this.decompress(target, targetOffset, scannerChannel);
|
|
2226
|
+
}
|
|
2227
|
+
/** Decode changed waveform fields into one scanner-channel context. */
|
|
2228
|
+
decodeContext(codingContext, lastWavePacketContext) {
|
|
2229
|
+
lastWavePacketContext.descriptorIndex = this.decoder.decodeSymbol(codingContext.descriptorModel);
|
|
2230
|
+
const offsetDifferenceSymbol = this.decoder.decodeSymbol(codingContext.offsetDifferenceModels[codingContext.lastOffsetDifferenceSymbol]);
|
|
2231
|
+
codingContext.lastOffsetDifferenceSymbol = offsetDifferenceSymbol;
|
|
2232
|
+
switch (offsetDifferenceSymbol) {
|
|
2233
|
+
case 0:
|
|
2234
|
+
break;
|
|
2235
|
+
case 1:
|
|
2236
|
+
lastWavePacketContext.offset = BigInt.asUintN(64, lastWavePacketContext.offset + BigInt(lastWavePacketContext.packetSize));
|
|
2237
|
+
break;
|
|
2238
|
+
case 2:
|
|
2239
|
+
codingContext.lastOffsetDifference = codingContext.offsetDifferenceDecompressor.decompress(this.decoder, codingContext.lastOffsetDifference, 0);
|
|
2240
|
+
lastWavePacketContext.offset = BigInt.asUintN(64, lastWavePacketContext.offset + BigInt(codingContext.lastOffsetDifference));
|
|
2241
|
+
break;
|
|
2242
|
+
default:
|
|
2243
|
+
lastWavePacketContext.offset = this.decoder.readUint64();
|
|
2244
|
+
break;
|
|
2245
|
+
}
|
|
2246
|
+
lastWavePacketContext.packetSize =
|
|
2247
|
+
codingContext.packetSizeDecompressor.decompress(this.decoder, lastWavePacketContext.packetSize | 0, 0) >>> 0;
|
|
2248
|
+
lastWavePacketContext.returnPointBits = codingContext.returnPointDecompressor.decompress(this.decoder, lastWavePacketContext.returnPointBits, 0);
|
|
2249
|
+
lastWavePacketContext.xBits = codingContext.vectorDecompressor.decompress(this.decoder, lastWavePacketContext.xBits, 0);
|
|
2250
|
+
lastWavePacketContext.yBits = codingContext.vectorDecompressor.decompress(this.decoder, lastWavePacketContext.yBits, 1);
|
|
2251
|
+
lastWavePacketContext.zBits = codingContext.vectorDecompressor.decompress(this.decoder, lastWavePacketContext.zBits, 2);
|
|
2252
|
+
}
|
|
2253
|
+
/** Initialize one context from the previous scanner channel's last reference. */
|
|
2254
|
+
copyLastWavePacket(target, source) {
|
|
2255
|
+
target.descriptorIndex = source.descriptorIndex;
|
|
2256
|
+
target.offset = source.offset;
|
|
2257
|
+
target.packetSize = source.packetSize;
|
|
2258
|
+
target.returnPointBits = source.returnPointBits;
|
|
2259
|
+
target.xBits = source.xBits;
|
|
2260
|
+
target.yBits = source.yBits;
|
|
2261
|
+
target.zBits = source.zBits;
|
|
2262
|
+
}
|
|
2263
|
+
/** Read one uncompressed waveform reference into a decoder context. */
|
|
2264
|
+
readContext(context, input, inputOffset) {
|
|
2265
|
+
context.descriptorIndex = input[inputOffset];
|
|
2266
|
+
context.offset = readBigUint64(input, inputOffset + 1);
|
|
2267
|
+
context.packetSize = readUint32(input, inputOffset + 9);
|
|
2268
|
+
context.returnPointBits = readInt32(input, inputOffset + 13);
|
|
2269
|
+
context.xBits = readInt32(input, inputOffset + 17);
|
|
2270
|
+
context.yBits = readInt32(input, inputOffset + 21);
|
|
2271
|
+
context.zBits = readInt32(input, inputOffset + 25);
|
|
2272
|
+
}
|
|
2273
|
+
/** Write one decoder context as an uncompressed 29-byte waveform reference. */
|
|
2274
|
+
writeContext(context, output, outputOffset) {
|
|
2275
|
+
output[outputOffset] = context.descriptorIndex;
|
|
2276
|
+
writeBigUint64(context.offset, output, outputOffset + 1);
|
|
2277
|
+
writeUint32(context.packetSize, output, outputOffset + 9);
|
|
2278
|
+
writeInt32(context.returnPointBits, output, outputOffset + 13);
|
|
2279
|
+
writeInt32(context.xBits, output, outputOffset + 17);
|
|
2280
|
+
writeInt32(context.yBits, output, outputOffset + 21);
|
|
2281
|
+
writeInt32(context.zBits, output, outputOffset + 25);
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
class Byte14Context {
|
|
2285
|
+
haveLast = false;
|
|
2286
|
+
last;
|
|
2287
|
+
byteModel;
|
|
2288
|
+
constructor(count) {
|
|
2289
|
+
this.last = new Uint8Array(count);
|
|
2290
|
+
this.byteModel = createModels(count, 256);
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
class Byte14Decompressor {
|
|
2294
|
+
stream;
|
|
2295
|
+
count;
|
|
2296
|
+
contexts;
|
|
2297
|
+
lastChannel = -1;
|
|
2298
|
+
byteCount;
|
|
2299
|
+
byteDecoder;
|
|
2300
|
+
/** Byte14 item version controlling scanner-channel predictor selection. */
|
|
2301
|
+
itemVersion;
|
|
2302
|
+
constructor(stream, count, itemVersion = 3) {
|
|
2303
|
+
this.stream = stream;
|
|
2304
|
+
this.count = count;
|
|
2305
|
+
this.itemVersion = itemVersion;
|
|
2306
|
+
this.contexts = Array.from({ length: 4 }, () => new Byte14Context(count));
|
|
2307
|
+
this.byteCount = new Array(count).fill(0);
|
|
2308
|
+
this.byteDecoder = Array.from({ length: count }, () => new ArithmeticDecoder());
|
|
2309
|
+
}
|
|
2310
|
+
readSizes() {
|
|
2311
|
+
for (let index = 0; index < this.count; index++) {
|
|
2312
|
+
this.byteCount[index] = this.stream.getUint32();
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
readData() {
|
|
2316
|
+
for (let index = 0; index < this.count; index++) {
|
|
2317
|
+
this.byteDecoder[index].initStream(this.stream, this.byteCount[index]);
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
decompress(output, outputOffset, scannerChannel) {
|
|
2321
|
+
if (this.lastChannel === -1) {
|
|
2322
|
+
this.stream.getBytes(output, outputOffset, this.count);
|
|
2323
|
+
const context = this.contexts[scannerChannel];
|
|
2324
|
+
context.last.set(output.subarray(outputOffset, outputOffset + this.count));
|
|
2325
|
+
context.haveLast = true;
|
|
2326
|
+
this.lastChannel = scannerChannel;
|
|
2327
|
+
return outputOffset + this.count;
|
|
2328
|
+
}
|
|
2329
|
+
const context = this.contexts[scannerChannel];
|
|
2330
|
+
let lastByte = this.contexts[this.lastChannel].last;
|
|
2331
|
+
if (scannerChannel !== this.lastChannel) {
|
|
2332
|
+
this.lastChannel = scannerChannel;
|
|
2333
|
+
if (!context.haveLast) {
|
|
2334
|
+
context.haveLast = true;
|
|
2335
|
+
context.last.set(lastByte);
|
|
2336
|
+
lastByte = this.contexts[this.lastChannel].last;
|
|
2337
|
+
}
|
|
2338
|
+
if (this.itemVersion >= 4) {
|
|
2339
|
+
lastByte = context.last;
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
for (let index = 0; index < this.count; index++) {
|
|
2343
|
+
if (this.byteCount[index]) {
|
|
2344
|
+
const value = (lastByte[index] + this.byteDecoder[index].decodeSymbol(context.byteModel[index])) & 0xff;
|
|
2345
|
+
output[outputOffset + index] = value;
|
|
2346
|
+
lastByte[index] = value;
|
|
2347
|
+
}
|
|
2348
|
+
else {
|
|
2349
|
+
output[outputOffset + index] = lastByte[index];
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
return outputOffset + this.count;
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
function createPointDecompressor(stream, metadata, outputMode, selection) {
|
|
2356
|
+
const extraByteCount = getExtraByteCount(metadata);
|
|
2357
|
+
for (const version of [
|
|
2358
|
+
metadata.point10ItemVersion,
|
|
2359
|
+
metadata.gpsTime11ItemVersion,
|
|
2360
|
+
metadata.rgb12ItemVersion,
|
|
2361
|
+
metadata.byteItemVersion
|
|
2362
|
+
]) {
|
|
2363
|
+
if (version !== undefined && version !== 1 && version !== 2) {
|
|
2364
|
+
throw new Error(`Unsupported legacy LASzip item version ${version}`);
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
switch (metadata.pointDataRecordFormat) {
|
|
2368
|
+
case 0:
|
|
2369
|
+
return new PointFormat0Decompressor(stream, extraByteCount, metadata);
|
|
2370
|
+
case 1:
|
|
2371
|
+
return new PointFormat1Decompressor(stream, extraByteCount, metadata);
|
|
2372
|
+
case 2:
|
|
2373
|
+
return new PointFormat2Decompressor(stream, extraByteCount, metadata);
|
|
2374
|
+
case 3:
|
|
2375
|
+
return new PointFormat3Decompressor(stream, extraByteCount, metadata, outputMode === 'point-data' ? selection : null);
|
|
2376
|
+
case 4:
|
|
2377
|
+
return new PointFormat4Decompressor(stream, extraByteCount, metadata);
|
|
2378
|
+
case 5:
|
|
2379
|
+
return new PointFormat5Decompressor(stream, extraByteCount, metadata);
|
|
2380
|
+
case 6:
|
|
2381
|
+
return new PointFormat6Decompressor(stream, extraByteCount, outputMode, metadata, selection);
|
|
2382
|
+
case 7:
|
|
2383
|
+
return new PointFormat7Decompressor(stream, extraByteCount, outputMode, metadata, selection);
|
|
2384
|
+
case 8:
|
|
2385
|
+
return new PointFormat8Decompressor(stream, extraByteCount, outputMode, metadata, selection);
|
|
2386
|
+
case 9:
|
|
2387
|
+
return new PointFormat9Decompressor(stream, extraByteCount, outputMode, metadata, selection);
|
|
2388
|
+
case 10:
|
|
2389
|
+
return new PointFormat10Decompressor(stream, extraByteCount, outputMode, metadata, selection);
|
|
2390
|
+
default:
|
|
2391
|
+
throw new Error(`TypeScript LAZ decoder does not support point format ${metadata.pointDataRecordFormat}`);
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
/** Return whether a point format has a direct typed-array output path. */
|
|
2395
|
+
function supportsDirectPointDataOutput(pointDataRecordFormat) {
|
|
2396
|
+
return pointDataRecordFormat <= 5 || (pointDataRecordFormat >= 6 && pointDataRecordFormat <= 10);
|
|
2397
|
+
}
|
|
2398
|
+
class PointFormat0Decompressor {
|
|
2399
|
+
point;
|
|
2400
|
+
bytes;
|
|
2401
|
+
first = true;
|
|
2402
|
+
constructor(stream, extraByteCount, metadata) {
|
|
2403
|
+
this.point = new Point10Decompressor(stream, metadata.point10ItemVersion ?? 2);
|
|
2404
|
+
this.bytes = new Byte10Decompressor(stream, this.point.getDecoder(), extraByteCount, metadata.byteItemVersion ?? 2);
|
|
2405
|
+
}
|
|
2406
|
+
decompress(output, outputOffset) {
|
|
2407
|
+
outputOffset = this.point.decompress(output, outputOffset);
|
|
2408
|
+
outputOffset = this.bytes.decompress(output, outputOffset);
|
|
2409
|
+
this.readFirstMetadata();
|
|
2410
|
+
return outputOffset;
|
|
2411
|
+
}
|
|
2412
|
+
/** Decode PDRF 0 points directly into represented Arrow columns. */
|
|
2413
|
+
decompressPointData(target, targetPointIndex) {
|
|
2414
|
+
const point = this.point.decompressPoint();
|
|
2415
|
+
this.bytes.decompressToTarget(target.extraBytes, targetPointIndex * this.bytes.byteCount);
|
|
2416
|
+
this.readFirstMetadata();
|
|
2417
|
+
writePoint10ToPointDataArrays(point, target.positions, target.intensities, target.classifications, target.scale, target.offset, targetPointIndex);
|
|
2418
|
+
writePoint10MetadataToPointDataTarget(point, target, targetPointIndex);
|
|
2419
|
+
}
|
|
2420
|
+
decompressPointDataBatch(target, pointCount) {
|
|
2421
|
+
for (let pointIndex = 0; pointIndex < pointCount; pointIndex++) {
|
|
2422
|
+
this.decompressPointData(target, target.pointOffset + pointIndex);
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
readFirstMetadata() {
|
|
2426
|
+
if (this.first) {
|
|
2427
|
+
this.point.readFirstMetadata();
|
|
2428
|
+
this.first = false;
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
class GpsTime10Decompressor {
|
|
2433
|
+
itemVersion;
|
|
2434
|
+
stream;
|
|
2435
|
+
decoder;
|
|
2436
|
+
gpsTimeMultiModel = new ArithmeticModel(516);
|
|
2437
|
+
gpsTime0DiffModel = new ArithmeticModel(6);
|
|
2438
|
+
gpsTime = createIntegerDecompressor(32, 9);
|
|
2439
|
+
lastGpsSequence = 0;
|
|
2440
|
+
nextGpsSequence = 0;
|
|
2441
|
+
lastGpsTime = new Array(4).fill(0);
|
|
2442
|
+
lastGpsTimeDiff = new Array(4).fill(0);
|
|
2443
|
+
multiExtremeCounter = new Array(4).fill(0);
|
|
2444
|
+
haveLast = false;
|
|
2445
|
+
constructor(stream, decoder,
|
|
2446
|
+
/** LASzip item codec version selected by the VLR. */ itemVersion = 2) {
|
|
2447
|
+
this.itemVersion = itemVersion;
|
|
2448
|
+
this.stream = stream;
|
|
2449
|
+
this.decoder = decoder;
|
|
2450
|
+
if (itemVersion === 1) {
|
|
2451
|
+
this.gpsTimeMultiModel = new ArithmeticModel(512);
|
|
2452
|
+
this.gpsTime0DiffModel = new ArithmeticModel(3);
|
|
2453
|
+
this.gpsTime = createIntegerDecompressor(32, 6);
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
decompress(output, outputOffset) {
|
|
2457
|
+
writeFloat64(this.decompressGpsTime(), output, outputOffset);
|
|
2458
|
+
return outputOffset + 8;
|
|
2459
|
+
}
|
|
2460
|
+
/** Decode one legacy GPS time value without materializing raw point bytes. */
|
|
2461
|
+
decompressGpsTime() {
|
|
2462
|
+
if (!this.haveLast) {
|
|
2463
|
+
this.lastGpsTime[0] = readFloat64FromStream(this.stream);
|
|
2464
|
+
this.haveLast = true;
|
|
2465
|
+
return this.lastGpsTime[0];
|
|
2466
|
+
}
|
|
2467
|
+
if (this.itemVersion === 1)
|
|
2468
|
+
this.decodeLegacyGpsTime();
|
|
2469
|
+
else
|
|
2470
|
+
this.decodeGpsTime();
|
|
2471
|
+
return this.lastGpsTime[this.lastGpsSequence];
|
|
2472
|
+
}
|
|
2473
|
+
/** Decode the single GPS-time sequence used by LASzip item version 1. */
|
|
2474
|
+
decodeLegacyGpsTime() {
|
|
2475
|
+
const previousDifference = this.lastGpsTimeDiff[0];
|
|
2476
|
+
if (previousDifference === 0) {
|
|
2477
|
+
const symbol = this.decoder.decodeSymbol(this.gpsTime0DiffModel);
|
|
2478
|
+
if (symbol === 1) {
|
|
2479
|
+
const difference = this.gpsTime.decompress(this.decoder, 0, 0);
|
|
2480
|
+
this.lastGpsTimeDiff[0] = difference;
|
|
2481
|
+
this.lastGpsTime[0] = addInt32ToFloat64Bits(this.lastGpsTime[0], difference);
|
|
2482
|
+
}
|
|
2483
|
+
else if (symbol === 2) {
|
|
2484
|
+
this.lastGpsTime[0] = bigUint64ToFloat64(this.decoder.readUint64());
|
|
2485
|
+
}
|
|
2486
|
+
return;
|
|
2487
|
+
}
|
|
2488
|
+
const multiplier = this.decoder.decodeSymbol(this.gpsTimeMultiModel);
|
|
2489
|
+
if (multiplier === 511)
|
|
2490
|
+
return;
|
|
2491
|
+
if (multiplier === 510) {
|
|
2492
|
+
this.lastGpsTime[0] = bigUint64ToFloat64(this.decoder.readUint64());
|
|
2493
|
+
return;
|
|
2494
|
+
}
|
|
2495
|
+
const context = multiplier === 1 ? 1 : multiplier === 0 ? 2 : multiplier < 10 ? 3 : multiplier < 50 ? 4 : 5;
|
|
2496
|
+
const prediction = multiplier === 0
|
|
2497
|
+
? Math.trunc(previousDifference / 4)
|
|
2498
|
+
: toInt32(multiplier * previousDifference);
|
|
2499
|
+
const difference = this.gpsTime.decompress(this.decoder, prediction, context);
|
|
2500
|
+
if (multiplier === 1) {
|
|
2501
|
+
this.lastGpsTimeDiff[0] = difference;
|
|
2502
|
+
this.multiExtremeCounter[0] = 0;
|
|
2503
|
+
}
|
|
2504
|
+
else if (multiplier === 0 || multiplier === 509) {
|
|
2505
|
+
if (++this.multiExtremeCounter[0] > 3) {
|
|
2506
|
+
this.lastGpsTimeDiff[0] = difference;
|
|
2507
|
+
this.multiExtremeCounter[0] = 0;
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
this.lastGpsTime[0] = addInt32ToFloat64Bits(this.lastGpsTime[0], difference);
|
|
2511
|
+
}
|
|
2512
|
+
decodeGpsTime() {
|
|
2513
|
+
while (true) {
|
|
2514
|
+
if (this.lastGpsTimeDiff[this.lastGpsSequence] === 0) {
|
|
2515
|
+
const multi = this.decoder.decodeSymbol(this.gpsTime0DiffModel);
|
|
2516
|
+
if (multi === 0) {
|
|
2517
|
+
break;
|
|
2518
|
+
}
|
|
2519
|
+
if (multi === 1) {
|
|
2520
|
+
const gpsTimeDiff = this.gpsTime.decompress(this.decoder, 0, 0);
|
|
2521
|
+
this.lastGpsTimeDiff[this.lastGpsSequence] = gpsTimeDiff;
|
|
2522
|
+
this.lastGpsTime[this.lastGpsSequence] = addInt32ToFloat64Bits(this.lastGpsTime[this.lastGpsSequence], gpsTimeDiff);
|
|
2523
|
+
this.multiExtremeCounter[this.lastGpsSequence] = 0;
|
|
2524
|
+
break;
|
|
2525
|
+
}
|
|
2526
|
+
if (multi === 2) {
|
|
2527
|
+
this.readFullGpsTime();
|
|
2528
|
+
break;
|
|
2529
|
+
}
|
|
2530
|
+
this.lastGpsSequence = (this.lastGpsSequence + multi - 2) & 3;
|
|
2531
|
+
continue;
|
|
2532
|
+
}
|
|
2533
|
+
let multi = this.decoder.decodeSymbol(this.gpsTimeMultiModel);
|
|
2534
|
+
let gpsTimeDiff = 0;
|
|
2535
|
+
if (multi === 1) {
|
|
2536
|
+
const symbol = this.gpsTime.decompress(this.decoder, this.lastGpsTimeDiff[this.lastGpsSequence], 1);
|
|
2537
|
+
this.lastGpsTime[this.lastGpsSequence] = addInt32ToFloat64Bits(this.lastGpsTime[this.lastGpsSequence], symbol);
|
|
2538
|
+
this.multiExtremeCounter[this.lastGpsSequence] = 0;
|
|
2539
|
+
}
|
|
2540
|
+
else if (multi < GPS_TIME10_MULTI_UNCHANGED) {
|
|
2541
|
+
if (multi === 0) {
|
|
2542
|
+
gpsTimeDiff = this.gpsTime.decompress(this.decoder, 0, 7);
|
|
2543
|
+
this.multiExtremeCounter[this.lastGpsSequence]++;
|
|
2544
|
+
if (this.multiExtremeCounter[this.lastGpsSequence] > 3) {
|
|
2545
|
+
this.multiExtremeCounter[this.lastGpsSequence] = 0;
|
|
2546
|
+
this.lastGpsTimeDiff[this.lastGpsSequence] = gpsTimeDiff;
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
else if (multi < GPS_TIME_MULTI) {
|
|
2550
|
+
const tag = multi < 10 ? 2 : 3;
|
|
2551
|
+
gpsTimeDiff = this.gpsTime.decompress(this.decoder, multi * this.lastGpsTimeDiff[this.lastGpsSequence], tag);
|
|
2552
|
+
}
|
|
2553
|
+
else if (multi === GPS_TIME_MULTI) {
|
|
2554
|
+
gpsTimeDiff = this.gpsTime.decompress(this.decoder, GPS_TIME_MULTI * this.lastGpsTimeDiff[this.lastGpsSequence], 4);
|
|
2555
|
+
this.multiExtremeCounter[this.lastGpsSequence]++;
|
|
2556
|
+
if (this.multiExtremeCounter[this.lastGpsSequence] > 3) {
|
|
2557
|
+
this.multiExtremeCounter[this.lastGpsSequence] = 0;
|
|
2558
|
+
this.lastGpsTimeDiff[this.lastGpsSequence] = gpsTimeDiff;
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
else {
|
|
2562
|
+
multi = GPS_TIME_MULTI - multi;
|
|
2563
|
+
if (multi > GPS_TIME_MULTI_MINUS) {
|
|
2564
|
+
gpsTimeDiff = this.gpsTime.decompress(this.decoder, multi * this.lastGpsTimeDiff[this.lastGpsSequence], 5);
|
|
2565
|
+
}
|
|
2566
|
+
else {
|
|
2567
|
+
gpsTimeDiff = this.gpsTime.decompress(this.decoder, GPS_TIME_MULTI_MINUS * this.lastGpsTimeDiff[this.lastGpsSequence], 6);
|
|
2568
|
+
this.multiExtremeCounter[this.lastGpsSequence]++;
|
|
2569
|
+
if (this.multiExtremeCounter[this.lastGpsSequence] > 3) {
|
|
2570
|
+
this.multiExtremeCounter[this.lastGpsSequence] = 0;
|
|
2571
|
+
this.lastGpsTimeDiff[this.lastGpsSequence] = gpsTimeDiff;
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
this.lastGpsTime[this.lastGpsSequence] = addInt32ToFloat64Bits(this.lastGpsTime[this.lastGpsSequence], gpsTimeDiff);
|
|
2576
|
+
}
|
|
2577
|
+
else if (multi === GPS_TIME10_MULTI_CODE_FULL) {
|
|
2578
|
+
this.readFullGpsTime();
|
|
2579
|
+
}
|
|
2580
|
+
else if (multi >= GPS_TIME10_MULTI_CODE_FULL) {
|
|
2581
|
+
this.lastGpsSequence = (this.lastGpsSequence + multi - GPS_TIME10_MULTI_CODE_FULL) & 3;
|
|
2582
|
+
continue;
|
|
2583
|
+
}
|
|
2584
|
+
break;
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
readFullGpsTime() {
|
|
2588
|
+
this.nextGpsSequence = (this.nextGpsSequence + 1) & 3;
|
|
2589
|
+
const lastTimeBits = float64ToBigUint64(this.lastGpsTime[this.lastGpsSequence]);
|
|
2590
|
+
const upper = this.gpsTime.decompress(this.decoder, Number(lastTimeBits >> 32n) | 0, 8);
|
|
2591
|
+
const lower = this.decoder.readInt();
|
|
2592
|
+
this.lastGpsTime[this.nextGpsSequence] = bigUint64ToFloat64((BigInt(upper >>> 0) << 32n) | BigInt(lower));
|
|
2593
|
+
this.lastGpsSequence = this.nextGpsSequence;
|
|
2594
|
+
this.lastGpsTimeDiff[this.lastGpsSequence] = 0;
|
|
2595
|
+
this.multiExtremeCounter[this.lastGpsSequence] = 0;
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
class PointFormat1Decompressor {
|
|
2599
|
+
point;
|
|
2600
|
+
gpsTime;
|
|
2601
|
+
bytes;
|
|
2602
|
+
first = true;
|
|
2603
|
+
constructor(stream, extraByteCount, metadata) {
|
|
2604
|
+
this.point = new Point10Decompressor(stream, metadata.point10ItemVersion ?? 2);
|
|
2605
|
+
const decoder = this.point.getDecoder();
|
|
2606
|
+
this.gpsTime = new GpsTime10Decompressor(stream, decoder, metadata.gpsTime11ItemVersion ?? 2);
|
|
2607
|
+
this.bytes = new Byte10Decompressor(stream, decoder, extraByteCount, metadata.byteItemVersion ?? 2);
|
|
2608
|
+
}
|
|
2609
|
+
decompress(output, outputOffset) {
|
|
2610
|
+
outputOffset = this.point.decompress(output, outputOffset);
|
|
2611
|
+
outputOffset = this.gpsTime.decompress(output, outputOffset);
|
|
2612
|
+
outputOffset = this.bytes.decompress(output, outputOffset);
|
|
2613
|
+
this.readFirstMetadata();
|
|
2614
|
+
return outputOffset;
|
|
2615
|
+
}
|
|
2616
|
+
/** Decode PDRF 1 points directly into represented Arrow columns. */
|
|
2617
|
+
decompressPointData(target, targetPointIndex) {
|
|
2618
|
+
const point = this.point.decompressPoint();
|
|
2619
|
+
const gpsTime = this.gpsTime.decompressGpsTime();
|
|
2620
|
+
this.bytes.decompressToTarget(target.extraBytes, targetPointIndex * this.bytes.byteCount);
|
|
2621
|
+
this.readFirstMetadata();
|
|
2622
|
+
writePoint10ToPointDataArrays(point, target.positions, target.intensities, target.classifications, target.scale, target.offset, targetPointIndex);
|
|
2623
|
+
writePoint10MetadataToPointDataTarget(point, target, targetPointIndex);
|
|
2624
|
+
if (target.gpsTimes) {
|
|
2625
|
+
target.gpsTimes[targetPointIndex] = gpsTime;
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
decompressPointDataBatch(target, pointCount) {
|
|
2629
|
+
for (let pointIndex = 0; pointIndex < pointCount; pointIndex++) {
|
|
2630
|
+
this.decompressPointData(target, target.pointOffset + pointIndex);
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
readFirstMetadata() {
|
|
2634
|
+
if (this.first) {
|
|
2635
|
+
this.point.readFirstMetadata();
|
|
2636
|
+
this.first = false;
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
class PointFormat2Decompressor {
|
|
2641
|
+
point;
|
|
2642
|
+
rgb;
|
|
2643
|
+
bytes;
|
|
2644
|
+
first = true;
|
|
2645
|
+
constructor(stream, extraByteCount, metadata) {
|
|
2646
|
+
this.point = new Point10Decompressor(stream, metadata.point10ItemVersion ?? 2);
|
|
2647
|
+
const decoder = this.point.getDecoder();
|
|
2648
|
+
this.rgb = new RGB10Decompressor(stream, decoder, metadata.rgb12ItemVersion ?? 2);
|
|
2649
|
+
this.bytes = new Byte10Decompressor(stream, decoder, extraByteCount, metadata.byteItemVersion ?? 2);
|
|
2650
|
+
}
|
|
2651
|
+
decompress(output, outputOffset) {
|
|
2652
|
+
outputOffset = this.point.decompress(output, outputOffset);
|
|
2653
|
+
outputOffset = this.rgb.decompress(output, outputOffset);
|
|
2654
|
+
outputOffset = this.bytes.decompress(output, outputOffset);
|
|
2655
|
+
this.readFirstMetadata();
|
|
2656
|
+
return outputOffset;
|
|
2657
|
+
}
|
|
2658
|
+
/** Decode PDRF 2 points directly into represented Arrow columns. */
|
|
2659
|
+
decompressPointData(target, targetPointIndex) {
|
|
2660
|
+
const point = this.point.decompressPoint();
|
|
2661
|
+
this.rgb.decompressRgb();
|
|
2662
|
+
this.bytes.decompressToTarget(target.extraBytes, targetPointIndex * this.bytes.byteCount);
|
|
2663
|
+
this.readFirstMetadata();
|
|
2664
|
+
writePoint10ToPointDataArrays(point, target.positions, target.intensities, target.classifications, target.scale, target.offset, targetPointIndex);
|
|
2665
|
+
writePoint10MetadataToPointDataTarget(point, target, targetPointIndex);
|
|
2666
|
+
writeRgbToPointDataTarget(this.rgb.decodedRed, this.rgb.decodedGreen, this.rgb.decodedBlue, target, targetPointIndex);
|
|
2667
|
+
}
|
|
2668
|
+
decompressPointDataBatch(target, pointCount) {
|
|
2669
|
+
for (let pointIndex = 0; pointIndex < pointCount; pointIndex++) {
|
|
2670
|
+
this.decompressPointData(target, target.pointOffset + pointIndex);
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
readFirstMetadata() {
|
|
2674
|
+
if (this.first) {
|
|
2675
|
+
this.point.readFirstMetadata();
|
|
2676
|
+
this.first = false;
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
class PointFormat3Decompressor {
|
|
2681
|
+
point;
|
|
2682
|
+
gpsTime;
|
|
2683
|
+
rgb;
|
|
2684
|
+
bytes;
|
|
2685
|
+
first = true;
|
|
2686
|
+
/** Whether only the common position, color, intensity, and classification columns are needed. */
|
|
2687
|
+
directCommonOutput;
|
|
2688
|
+
constructor(stream, extraByteCount, metadata, selection = null) {
|
|
2689
|
+
this.point = new Point10Decompressor(stream, metadata.point10ItemVersion ?? 2);
|
|
2690
|
+
const decoder = this.point.getDecoder();
|
|
2691
|
+
this.gpsTime = new GpsTime10Decompressor(stream, decoder, metadata.gpsTime11ItemVersion ?? 2);
|
|
2692
|
+
this.rgb = new RGB10Decompressor(stream, decoder, metadata.rgb12ItemVersion ?? 2);
|
|
2693
|
+
this.bytes = new Byte10Decompressor(stream, decoder, extraByteCount, metadata.byteItemVersion ?? 2);
|
|
2694
|
+
this.directCommonOutput = Boolean(selection &&
|
|
2695
|
+
!selection.gpsTime &&
|
|
2696
|
+
!selection.scanAngle &&
|
|
2697
|
+
!selection.userData &&
|
|
2698
|
+
!selection.pointSourceId &&
|
|
2699
|
+
!selection.flags &&
|
|
2700
|
+
!selection.waveform &&
|
|
2701
|
+
!selection.extraBytes);
|
|
2702
|
+
}
|
|
2703
|
+
decompress(output, outputOffset) {
|
|
2704
|
+
outputOffset = this.point.decompress(output, outputOffset);
|
|
2705
|
+
outputOffset = this.gpsTime.decompress(output, outputOffset);
|
|
2706
|
+
outputOffset = this.rgb.decompress(output, outputOffset);
|
|
2707
|
+
outputOffset = this.bytes.decompress(output, outputOffset);
|
|
2708
|
+
this.readFirstMetadata();
|
|
2709
|
+
return outputOffset;
|
|
2710
|
+
}
|
|
2711
|
+
/** Decode one legacy PDRF 3 point directly into typed point-data arrays. */
|
|
2712
|
+
decompressPointData(target, targetPointIndex) {
|
|
2713
|
+
const point = this.point.decompressPoint();
|
|
2714
|
+
const gpsTime = this.gpsTime.decompressGpsTime();
|
|
2715
|
+
this.rgb.decompressRgb();
|
|
2716
|
+
if (this.directCommonOutput) {
|
|
2717
|
+
this.bytes.decompressToTarget();
|
|
2718
|
+
this.readFirstMetadata();
|
|
2719
|
+
writePoint10ToPointDataArrays(point, target.positions, target.intensities, target.classifications, target.scale, target.offset, targetPointIndex);
|
|
2720
|
+
if (target.colors) {
|
|
2721
|
+
const colorOffset = targetPointIndex * 4;
|
|
2722
|
+
target.colors[colorOffset] = this.rgb.decodedRed & 0xff;
|
|
2723
|
+
target.colors[colorOffset + 1] = this.rgb.decodedGreen & 0xff;
|
|
2724
|
+
target.colors[colorOffset + 2] = this.rgb.decodedBlue & 0xff;
|
|
2725
|
+
target.colors[colorOffset + 3] = 255;
|
|
2726
|
+
}
|
|
2727
|
+
else if (target.rawColors) {
|
|
2728
|
+
const colorOffset = targetPointIndex * 3;
|
|
2729
|
+
target.rawColors[colorOffset] = this.rgb.decodedRed;
|
|
2730
|
+
target.rawColors[colorOffset + 1] = this.rgb.decodedGreen;
|
|
2731
|
+
target.rawColors[colorOffset + 2] = this.rgb.decodedBlue;
|
|
2732
|
+
}
|
|
2733
|
+
return;
|
|
2734
|
+
}
|
|
2735
|
+
this.bytes.decompressToTarget(target.extraBytes, targetPointIndex * this.bytes.byteCount);
|
|
2736
|
+
this.readFirstMetadata();
|
|
2737
|
+
writePoint10ToPointDataArrays(point, target.positions, target.intensities, target.classifications, target.scale, target.offset, targetPointIndex);
|
|
2738
|
+
writePoint10MetadataToPointDataTarget(point, target, targetPointIndex);
|
|
2739
|
+
if (target.gpsTimes) {
|
|
2740
|
+
target.gpsTimes[targetPointIndex] = gpsTime;
|
|
2741
|
+
}
|
|
2742
|
+
writeRgbToPointDataTarget(this.rgb.decodedRed, this.rgb.decodedGreen, this.rgb.decodedBlue, target, targetPointIndex);
|
|
2743
|
+
}
|
|
2744
|
+
/**
|
|
2745
|
+
* Decode legacy PDRF 3 directly into selected typed point-data arrays.
|
|
2746
|
+
*
|
|
2747
|
+
* The common-column branch deliberately duplicates the short output loop. Keeping optional
|
|
2748
|
+
* metadata and Extra Bytes checks outside that loop measurably reduces work for visualization
|
|
2749
|
+
* workloads, which normally request only position, color, intensity, and classification.
|
|
2750
|
+
*/
|
|
2751
|
+
decompressPointDataBatch(target, pointCount) {
|
|
2752
|
+
const positions = target.positions;
|
|
2753
|
+
const intensities = target.intensities;
|
|
2754
|
+
const classifications = target.classifications;
|
|
2755
|
+
const colors = target.colors;
|
|
2756
|
+
const rawColors = target.rawColors;
|
|
2757
|
+
const scale = target.scale;
|
|
2758
|
+
const offset = target.offset;
|
|
2759
|
+
const extraByteCount = this.bytes.byteCount;
|
|
2760
|
+
let targetPointIndex = target.pointOffset;
|
|
2761
|
+
const hasMetadataOutput = Boolean(target.gpsTimes ||
|
|
2762
|
+
target.scanAngles ||
|
|
2763
|
+
target.userData ||
|
|
2764
|
+
target.pointSourceIds ||
|
|
2765
|
+
target.returnNumbers ||
|
|
2766
|
+
target.numberOfReturns ||
|
|
2767
|
+
target.scannerChannels ||
|
|
2768
|
+
target.scanDirectionFlags ||
|
|
2769
|
+
target.edgeOfFlightLines ||
|
|
2770
|
+
target.syntheticFlags ||
|
|
2771
|
+
target.keyPointFlags ||
|
|
2772
|
+
target.withheldFlags ||
|
|
2773
|
+
target.overlapFlags);
|
|
2774
|
+
if (!hasMetadataOutput && !target.extraBytes) {
|
|
2775
|
+
for (let pointIndex = 0; pointIndex < pointCount; pointIndex++) {
|
|
2776
|
+
const point = this.point.decompressPoint();
|
|
2777
|
+
this.gpsTime.decompressGpsTime();
|
|
2778
|
+
this.rgb.decompressRgb();
|
|
2779
|
+
this.bytes.decompressToTarget();
|
|
2780
|
+
this.readFirstMetadata();
|
|
2781
|
+
writePoint10ToPointDataArrays(point, positions, intensities, classifications, scale, offset, targetPointIndex);
|
|
2782
|
+
if (colors) {
|
|
2783
|
+
const colorOffset = targetPointIndex * 4;
|
|
2784
|
+
colors[colorOffset] = this.rgb.decodedRed & 0xff;
|
|
2785
|
+
colors[colorOffset + 1] = this.rgb.decodedGreen & 0xff;
|
|
2786
|
+
colors[colorOffset + 2] = this.rgb.decodedBlue & 0xff;
|
|
2787
|
+
colors[colorOffset + 3] = 255;
|
|
2788
|
+
}
|
|
2789
|
+
else if (rawColors) {
|
|
2790
|
+
const colorOffset = targetPointIndex * 3;
|
|
2791
|
+
rawColors[colorOffset] = this.rgb.decodedRed;
|
|
2792
|
+
rawColors[colorOffset + 1] = this.rgb.decodedGreen;
|
|
2793
|
+
rawColors[colorOffset + 2] = this.rgb.decodedBlue;
|
|
2794
|
+
}
|
|
2795
|
+
targetPointIndex++;
|
|
2796
|
+
}
|
|
2797
|
+
return;
|
|
2798
|
+
}
|
|
2799
|
+
for (let pointIndex = 0; pointIndex < pointCount; pointIndex++) {
|
|
2800
|
+
const point = this.point.decompressPoint();
|
|
2801
|
+
const gpsTime = this.gpsTime.decompressGpsTime();
|
|
2802
|
+
this.rgb.decompressRgb();
|
|
2803
|
+
this.bytes.decompressToTarget(target.extraBytes, targetPointIndex * extraByteCount);
|
|
2804
|
+
this.readFirstMetadata();
|
|
2805
|
+
writePoint10ToPointDataArrays(point, positions, intensities, classifications, scale, offset, targetPointIndex);
|
|
2806
|
+
writePoint10MetadataToPointDataTarget(point, target, targetPointIndex);
|
|
2807
|
+
if (target.gpsTimes) {
|
|
2808
|
+
target.gpsTimes[targetPointIndex] = gpsTime;
|
|
2809
|
+
}
|
|
2810
|
+
writeRgbToPointDataTarget(this.rgb.decodedRed, this.rgb.decodedGreen, this.rgb.decodedBlue, target, targetPointIndex);
|
|
2811
|
+
targetPointIndex++;
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2814
|
+
readFirstMetadata() {
|
|
2815
|
+
if (this.first) {
|
|
2816
|
+
this.point.readFirstMetadata();
|
|
2817
|
+
this.first = false;
|
|
2818
|
+
}
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
/** LASzip v1 decoder for the interleaved legacy waveform packet item. */
|
|
2822
|
+
class WavePacket13Decompressor {
|
|
2823
|
+
/** Compressed chunk source used for the first uncompressed item. */
|
|
2824
|
+
stream;
|
|
2825
|
+
/** Arithmetic decoder shared by all legacy point items. */
|
|
2826
|
+
decoder;
|
|
2827
|
+
/** Waveform state and arithmetic models for the preceding point. */
|
|
2828
|
+
context = new WavePacketDecompressionContext();
|
|
2829
|
+
constructor(stream, decoder) {
|
|
2830
|
+
this.stream = stream;
|
|
2831
|
+
this.decoder = decoder;
|
|
2832
|
+
}
|
|
2833
|
+
/** Decode one complete 29-byte legacy waveform packet reference. */
|
|
2834
|
+
decompress(output, outputOffset) {
|
|
2835
|
+
const context = this.context;
|
|
2836
|
+
if (!context.haveLast) {
|
|
2837
|
+
this.stream.getBytes(output, outputOffset, 29);
|
|
2838
|
+
this.readContext(output, outputOffset);
|
|
2839
|
+
context.haveLast = true;
|
|
2840
|
+
return outputOffset + 29;
|
|
2841
|
+
}
|
|
2842
|
+
context.descriptorIndex = this.decoder.decodeSymbol(context.descriptorModel);
|
|
2843
|
+
const offsetDifferenceSymbol = this.decoder.decodeSymbol(context.offsetDifferenceModels[context.lastOffsetDifferenceSymbol]);
|
|
2844
|
+
context.lastOffsetDifferenceSymbol = offsetDifferenceSymbol;
|
|
2845
|
+
switch (offsetDifferenceSymbol) {
|
|
2846
|
+
case 0:
|
|
2847
|
+
break;
|
|
2848
|
+
case 1:
|
|
2849
|
+
context.offset = BigInt.asUintN(64, context.offset + BigInt(context.packetSize));
|
|
2850
|
+
break;
|
|
2851
|
+
case 2:
|
|
2852
|
+
context.lastOffsetDifference = context.offsetDifferenceDecompressor.decompress(this.decoder, context.lastOffsetDifference, 0);
|
|
2853
|
+
context.offset = BigInt.asUintN(64, context.offset + BigInt(context.lastOffsetDifference));
|
|
2854
|
+
break;
|
|
2855
|
+
default:
|
|
2856
|
+
context.offset = this.decoder.readUint64();
|
|
2857
|
+
break;
|
|
2858
|
+
}
|
|
2859
|
+
context.packetSize =
|
|
2860
|
+
context.packetSizeDecompressor.decompress(this.decoder, context.packetSize | 0, 0) >>> 0;
|
|
2861
|
+
context.returnPointBits = context.returnPointDecompressor.decompress(this.decoder, context.returnPointBits, 0);
|
|
2862
|
+
context.xBits = context.vectorDecompressor.decompress(this.decoder, context.xBits, 0);
|
|
2863
|
+
context.yBits = context.vectorDecompressor.decompress(this.decoder, context.yBits, 1);
|
|
2864
|
+
context.zBits = context.vectorDecompressor.decompress(this.decoder, context.zBits, 2);
|
|
2865
|
+
this.writeContext(output, outputOffset);
|
|
2866
|
+
return outputOffset + 29;
|
|
2867
|
+
}
|
|
2868
|
+
/** Decode one waveform packet reference into a caller-owned 29-byte buffer. */
|
|
2869
|
+
decompressToTarget(target, targetOffset) {
|
|
2870
|
+
this.decompress(target, targetOffset);
|
|
2871
|
+
}
|
|
2872
|
+
/** Initialize waveform predictors from the first uncompressed item. */
|
|
2873
|
+
readContext(input, inputOffset) {
|
|
2874
|
+
const context = this.context;
|
|
2875
|
+
context.descriptorIndex = input[inputOffset];
|
|
2876
|
+
context.offset = readBigUint64(input, inputOffset + 1);
|
|
2877
|
+
context.packetSize = readUint32(input, inputOffset + 9);
|
|
2878
|
+
context.returnPointBits = readInt32(input, inputOffset + 13);
|
|
2879
|
+
context.xBits = readInt32(input, inputOffset + 17);
|
|
2880
|
+
context.yBits = readInt32(input, inputOffset + 21);
|
|
2881
|
+
context.zBits = readInt32(input, inputOffset + 25);
|
|
2882
|
+
}
|
|
2883
|
+
/** Write waveform predictor state as one LAS packet-reference field. */
|
|
2884
|
+
writeContext(output, outputOffset) {
|
|
2885
|
+
const context = this.context;
|
|
2886
|
+
output[outputOffset] = context.descriptorIndex;
|
|
2887
|
+
writeBigUint64(context.offset, output, outputOffset + 1);
|
|
2888
|
+
writeUint32(context.packetSize, output, outputOffset + 9);
|
|
2889
|
+
writeInt32(context.returnPointBits, output, outputOffset + 13);
|
|
2890
|
+
writeInt32(context.xBits, output, outputOffset + 17);
|
|
2891
|
+
writeInt32(context.yBits, output, outputOffset + 21);
|
|
2892
|
+
writeInt32(context.zBits, output, outputOffset + 25);
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
/** LASzip interleaved decoder for LAS point format 4. */
|
|
2896
|
+
class PointFormat4Decompressor {
|
|
2897
|
+
/** Legacy core point decoder. */
|
|
2898
|
+
point;
|
|
2899
|
+
/** GPS time decoder. */
|
|
2900
|
+
gpsTime;
|
|
2901
|
+
/** Legacy waveform packet decoder. */
|
|
2902
|
+
wavePacket;
|
|
2903
|
+
/** Extra Bytes decoder. */
|
|
2904
|
+
bytes;
|
|
2905
|
+
/** Reused sink for waveform references when the caller did not request WAVEFORM output. */
|
|
2906
|
+
waveformScratch = new Uint8Array(29);
|
|
2907
|
+
/** Whether the first raw items remain unread. */
|
|
2908
|
+
first = true;
|
|
2909
|
+
constructor(stream, extraByteCount, metadata) {
|
|
2910
|
+
this.point = new Point10Decompressor(stream, metadata.point10ItemVersion ?? 2);
|
|
2911
|
+
const decoder = this.point.getDecoder();
|
|
2912
|
+
this.gpsTime = new GpsTime10Decompressor(stream, decoder, metadata.gpsTime11ItemVersion ?? 2);
|
|
2913
|
+
this.wavePacket = new WavePacket13Decompressor(stream, decoder);
|
|
2914
|
+
this.bytes = new Byte10Decompressor(stream, decoder, extraByteCount, metadata.byteItemVersion ?? 2);
|
|
2915
|
+
}
|
|
2916
|
+
/** Decode one complete PDRF 4 point record. */
|
|
2917
|
+
decompress(output, outputOffset) {
|
|
2918
|
+
outputOffset = this.point.decompress(output, outputOffset);
|
|
2919
|
+
outputOffset = this.gpsTime.decompress(output, outputOffset);
|
|
2920
|
+
outputOffset = this.wavePacket.decompress(output, outputOffset);
|
|
2921
|
+
outputOffset = this.bytes.decompress(output, outputOffset);
|
|
2922
|
+
this.readFirstMetadata();
|
|
2923
|
+
return outputOffset;
|
|
2924
|
+
}
|
|
2925
|
+
/** Decode PDRF 4 points directly into represented Arrow columns and waveform references. */
|
|
2926
|
+
decompressPointData(target, targetPointIndex) {
|
|
2927
|
+
const point = this.point.decompressPoint();
|
|
2928
|
+
const gpsTime = this.gpsTime.decompressGpsTime();
|
|
2929
|
+
if (target.waveforms) {
|
|
2930
|
+
this.wavePacket.decompressToTarget(target.waveforms, targetPointIndex * 29);
|
|
2931
|
+
}
|
|
2932
|
+
else {
|
|
2933
|
+
this.wavePacket.decompressToTarget(this.waveformScratch, 0);
|
|
2934
|
+
}
|
|
2935
|
+
this.bytes.decompressToTarget(target.extraBytes, targetPointIndex * this.bytes.byteCount);
|
|
2936
|
+
this.readFirstMetadata();
|
|
2937
|
+
writePoint10ToPointDataArrays(point, target.positions, target.intensities, target.classifications, target.scale, target.offset, targetPointIndex);
|
|
2938
|
+
writePoint10MetadataToPointDataTarget(point, target, targetPointIndex);
|
|
2939
|
+
if (target.gpsTimes) {
|
|
2940
|
+
target.gpsTimes[targetPointIndex] = gpsTime;
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
decompressPointDataBatch(target, pointCount) {
|
|
2944
|
+
for (let pointIndex = 0; pointIndex < pointCount; pointIndex++) {
|
|
2945
|
+
this.decompressPointData(target, target.pointOffset + pointIndex);
|
|
2946
|
+
}
|
|
2947
|
+
}
|
|
2948
|
+
/** Initialize the shared legacy arithmetic decoder after first raw items. */
|
|
2949
|
+
readFirstMetadata() {
|
|
2950
|
+
if (this.first) {
|
|
2951
|
+
this.point.readFirstMetadata();
|
|
2952
|
+
this.first = false;
|
|
2953
|
+
}
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
/** LASzip interleaved decoder for LAS point format 5. */
|
|
2957
|
+
class PointFormat5Decompressor {
|
|
2958
|
+
/** Legacy core point decoder. */
|
|
2959
|
+
point;
|
|
2960
|
+
/** GPS time decoder. */
|
|
2961
|
+
gpsTime;
|
|
2962
|
+
/** RGB decoder. */
|
|
2963
|
+
rgb;
|
|
2964
|
+
/** Legacy waveform packet decoder. */
|
|
2965
|
+
wavePacket;
|
|
2966
|
+
/** Extra Bytes decoder. */
|
|
2967
|
+
bytes;
|
|
2968
|
+
/** Reused sink for waveform references when the caller did not request WAVEFORM output. */
|
|
2969
|
+
waveformScratch = new Uint8Array(29);
|
|
2970
|
+
/** Whether the first raw items remain unread. */
|
|
2971
|
+
first = true;
|
|
2972
|
+
constructor(stream, extraByteCount, metadata) {
|
|
2973
|
+
this.point = new Point10Decompressor(stream, metadata.point10ItemVersion ?? 2);
|
|
2974
|
+
const decoder = this.point.getDecoder();
|
|
2975
|
+
this.gpsTime = new GpsTime10Decompressor(stream, decoder, metadata.gpsTime11ItemVersion ?? 2);
|
|
2976
|
+
this.rgb = new RGB10Decompressor(stream, decoder, metadata.rgb12ItemVersion ?? 2);
|
|
2977
|
+
this.wavePacket = new WavePacket13Decompressor(stream, decoder);
|
|
2978
|
+
this.bytes = new Byte10Decompressor(stream, decoder, extraByteCount, metadata.byteItemVersion ?? 2);
|
|
2979
|
+
}
|
|
2980
|
+
/** Decode one complete PDRF 5 point record. */
|
|
2981
|
+
decompress(output, outputOffset) {
|
|
2982
|
+
outputOffset = this.point.decompress(output, outputOffset);
|
|
2983
|
+
outputOffset = this.gpsTime.decompress(output, outputOffset);
|
|
2984
|
+
outputOffset = this.rgb.decompress(output, outputOffset);
|
|
2985
|
+
outputOffset = this.wavePacket.decompress(output, outputOffset);
|
|
2986
|
+
outputOffset = this.bytes.decompress(output, outputOffset);
|
|
2987
|
+
this.readFirstMetadata();
|
|
2988
|
+
return outputOffset;
|
|
2989
|
+
}
|
|
2990
|
+
/** Decode PDRF 5 points directly into represented Arrow columns and waveform references. */
|
|
2991
|
+
decompressPointData(target, targetPointIndex) {
|
|
2992
|
+
const point = this.point.decompressPoint();
|
|
2993
|
+
const gpsTime = this.gpsTime.decompressGpsTime();
|
|
2994
|
+
this.rgb.decompressRgb();
|
|
2995
|
+
if (target.waveforms) {
|
|
2996
|
+
this.wavePacket.decompressToTarget(target.waveforms, targetPointIndex * 29);
|
|
2997
|
+
}
|
|
2998
|
+
else {
|
|
2999
|
+
this.wavePacket.decompressToTarget(this.waveformScratch, 0);
|
|
3000
|
+
}
|
|
3001
|
+
this.bytes.decompressToTarget(target.extraBytes, targetPointIndex * this.bytes.byteCount);
|
|
3002
|
+
this.readFirstMetadata();
|
|
3003
|
+
writePoint10ToPointDataArrays(point, target.positions, target.intensities, target.classifications, target.scale, target.offset, targetPointIndex);
|
|
3004
|
+
writePoint10MetadataToPointDataTarget(point, target, targetPointIndex);
|
|
3005
|
+
if (target.gpsTimes) {
|
|
3006
|
+
target.gpsTimes[targetPointIndex] = gpsTime;
|
|
3007
|
+
}
|
|
3008
|
+
writeRgbToPointDataTarget(this.rgb.decodedRed, this.rgb.decodedGreen, this.rgb.decodedBlue, target, targetPointIndex);
|
|
3009
|
+
}
|
|
3010
|
+
decompressPointDataBatch(target, pointCount) {
|
|
3011
|
+
for (let pointIndex = 0; pointIndex < pointCount; pointIndex++) {
|
|
3012
|
+
this.decompressPointData(target, target.pointOffset + pointIndex);
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
/** Initialize the shared legacy arithmetic decoder after first raw items. */
|
|
3016
|
+
readFirstMetadata() {
|
|
3017
|
+
if (this.first) {
|
|
3018
|
+
this.point.readFirstMetadata();
|
|
3019
|
+
this.first = false;
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
class PointFormat6Decompressor {
|
|
3024
|
+
stream;
|
|
3025
|
+
point;
|
|
3026
|
+
bytes;
|
|
3027
|
+
/** Extra bytes stored with the first point and in independent later layers. */
|
|
3028
|
+
extraByteCount;
|
|
3029
|
+
first = true;
|
|
3030
|
+
constructor(stream, extraByteCount, outputMode, metadata, selection) {
|
|
3031
|
+
this.stream = stream;
|
|
3032
|
+
this.extraByteCount = extraByteCount;
|
|
3033
|
+
this.point = new Point14Decompressor(stream, outputMode === 'raw' ? Point14DecompressionMode.Full : Point14DecompressionMode.PointData, metadata.point14ItemVersion ?? 3, selection);
|
|
3034
|
+
this.bytes =
|
|
3035
|
+
(outputMode === 'raw' || selection?.extraBytes) && extraByteCount
|
|
3036
|
+
? new Byte14Decompressor(stream, extraByteCount, metadata.byte14ItemVersion ?? 3)
|
|
3037
|
+
: null;
|
|
3038
|
+
}
|
|
3039
|
+
decompress(output, outputOffset) {
|
|
3040
|
+
outputOffset = this.point.decompress(output, outputOffset);
|
|
3041
|
+
if (this.bytes) {
|
|
3042
|
+
outputOffset = this.bytes.decompress(output, outputOffset, this.point.itemContextChannel);
|
|
3043
|
+
}
|
|
3044
|
+
this.readFirstMetadata();
|
|
3045
|
+
return outputOffset;
|
|
3046
|
+
}
|
|
3047
|
+
decompressPointData(target, targetPointIndex) {
|
|
3048
|
+
const point = this.point.decompressPoint();
|
|
3049
|
+
if (this.bytes && target.extraBytes) {
|
|
3050
|
+
this.bytes.decompress(target.extraBytes, targetPointIndex * this.extraByteCount, this.point.itemContextChannel);
|
|
3051
|
+
}
|
|
3052
|
+
else if (this.first && this.extraByteCount) {
|
|
3053
|
+
this.stream.consume(this.extraByteCount);
|
|
3054
|
+
}
|
|
3055
|
+
this.readFirstMetadata();
|
|
3056
|
+
writePoint14ToPointDataTarget(point, target, targetPointIndex);
|
|
3057
|
+
}
|
|
3058
|
+
decompressPointDataBatch(target, pointCount) {
|
|
3059
|
+
const positions = target.positions;
|
|
3060
|
+
const intensities = target.intensities;
|
|
3061
|
+
const classifications = target.classifications;
|
|
3062
|
+
const scale = target.scale;
|
|
3063
|
+
const offset = target.offset;
|
|
3064
|
+
let targetPointIndex = target.pointOffset;
|
|
3065
|
+
for (let pointIndex = 0; pointIndex < pointCount; pointIndex++) {
|
|
3066
|
+
const point = this.point.decompressPoint();
|
|
3067
|
+
if (this.bytes && target.extraBytes) {
|
|
3068
|
+
this.bytes.decompress(target.extraBytes, targetPointIndex * this.extraByteCount, this.point.itemContextChannel);
|
|
3069
|
+
}
|
|
3070
|
+
else if (this.first && this.extraByteCount) {
|
|
3071
|
+
this.stream.consume(this.extraByteCount);
|
|
3072
|
+
}
|
|
3073
|
+
this.readFirstMetadata();
|
|
3074
|
+
writePoint14ToPointDataArrays(point, positions, intensities, classifications, scale, offset, targetPointIndex++);
|
|
3075
|
+
writeGpsTimeToPointDataTarget(point, target, targetPointIndex - 1);
|
|
3076
|
+
writePoint14MetadataToPointDataTarget(point, target, targetPointIndex - 1);
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
readFirstMetadata() {
|
|
3080
|
+
if (this.first) {
|
|
3081
|
+
this.stream.getUint32();
|
|
3082
|
+
this.point.readSizes();
|
|
3083
|
+
let skippedExtraByteLength = 0;
|
|
3084
|
+
if (this.bytes) {
|
|
3085
|
+
this.bytes.readSizes();
|
|
3086
|
+
}
|
|
3087
|
+
else {
|
|
3088
|
+
for (let index = 0; index < this.extraByteCount; index++) {
|
|
3089
|
+
skippedExtraByteLength += this.stream.getUint32();
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
this.point.readData();
|
|
3093
|
+
if (this.bytes) {
|
|
3094
|
+
this.bytes.readData();
|
|
3095
|
+
}
|
|
3096
|
+
else {
|
|
3097
|
+
this.stream.consume(skippedExtraByteLength);
|
|
3098
|
+
}
|
|
3099
|
+
this.first = false;
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
class PointFormat7Decompressor {
|
|
3104
|
+
stream;
|
|
3105
|
+
point;
|
|
3106
|
+
rgb;
|
|
3107
|
+
bytes;
|
|
3108
|
+
/** Extra bytes stored with the first point and in independent later layers. */
|
|
3109
|
+
extraByteCount;
|
|
3110
|
+
first = true;
|
|
3111
|
+
constructor(stream, extraByteCount, outputMode, metadata, selection) {
|
|
3112
|
+
this.stream = stream;
|
|
3113
|
+
this.extraByteCount = extraByteCount;
|
|
3114
|
+
this.point = new Point14Decompressor(stream, outputMode === 'raw' ? Point14DecompressionMode.Full : Point14DecompressionMode.PointData, metadata.point14ItemVersion ?? 3, selection);
|
|
3115
|
+
this.rgb =
|
|
3116
|
+
outputMode === 'raw' || selection?.color
|
|
3117
|
+
? new RGB14Decompressor(stream, metadata.rgb14ItemVersion ?? 3)
|
|
3118
|
+
: null;
|
|
3119
|
+
this.bytes =
|
|
3120
|
+
(outputMode === 'raw' || selection?.extraBytes) && extraByteCount
|
|
3121
|
+
? new Byte14Decompressor(stream, extraByteCount, metadata.byte14ItemVersion ?? 3)
|
|
3122
|
+
: null;
|
|
3123
|
+
}
|
|
3124
|
+
decompress(output, outputOffset) {
|
|
3125
|
+
outputOffset = this.point.decompress(output, outputOffset);
|
|
3126
|
+
outputOffset = this.rgb.decompress(output, outputOffset, this.point.itemContextChannel);
|
|
3127
|
+
if (this.bytes) {
|
|
3128
|
+
outputOffset = this.bytes.decompress(output, outputOffset, this.point.itemContextChannel);
|
|
3129
|
+
}
|
|
3130
|
+
this.readFirstMetadata();
|
|
3131
|
+
return outputOffset;
|
|
3132
|
+
}
|
|
3133
|
+
/** Decode one PDRF 7 point directly into represented typed-array columns. */
|
|
3134
|
+
decompressPointData(target, targetPointIndex) {
|
|
3135
|
+
const point = this.point.decompressPoint();
|
|
3136
|
+
if (this.rgb) {
|
|
3137
|
+
this.rgb.decompressRgb(this.point.itemContextChannel);
|
|
3138
|
+
}
|
|
3139
|
+
else if (this.first) {
|
|
3140
|
+
this.stream.consume(6);
|
|
3141
|
+
}
|
|
3142
|
+
// The first point stores extra bytes before the layered stream metadata.
|
|
3143
|
+
if (this.bytes && target.extraBytes) {
|
|
3144
|
+
this.bytes.decompress(target.extraBytes, targetPointIndex * this.extraByteCount, this.point.itemContextChannel);
|
|
3145
|
+
}
|
|
3146
|
+
else if (this.first && this.extraByteCount) {
|
|
3147
|
+
this.stream.consume(this.extraByteCount);
|
|
3148
|
+
}
|
|
3149
|
+
this.readFirstMetadata();
|
|
3150
|
+
writePoint14ToPointDataTarget(point, target, targetPointIndex);
|
|
3151
|
+
if (this.rgb) {
|
|
3152
|
+
writeRgbToPointDataTarget(this.rgb.decodedRed, this.rgb.decodedGreen, this.rgb.decodedBlue, target, targetPointIndex);
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
/**
|
|
3156
|
+
* Decode PDRF 7 points directly into represented typed-array columns.
|
|
3157
|
+
*
|
|
3158
|
+
* First-point literals and layer metadata are handled once before the steady-state loop. The
|
|
3159
|
+
* common-column loop then avoids per-point capability checks; the comprehensive loop preserves
|
|
3160
|
+
* optional metadata and Extra Bytes output.
|
|
3161
|
+
*/
|
|
3162
|
+
decompressPointDataBatch(target, pointCount) {
|
|
3163
|
+
const positions = target.positions;
|
|
3164
|
+
const intensities = target.intensities;
|
|
3165
|
+
const classifications = target.classifications;
|
|
3166
|
+
const colors = target.colors;
|
|
3167
|
+
const rawColors = target.rawColors;
|
|
3168
|
+
const scale = target.scale;
|
|
3169
|
+
const offset = target.offset;
|
|
3170
|
+
let targetPointIndex = target.pointOffset;
|
|
3171
|
+
let remainingPointCount = pointCount;
|
|
3172
|
+
// Decode first-point literals and layer metadata before entering the steady-state loop.
|
|
3173
|
+
if (this.first && remainingPointCount > 0) {
|
|
3174
|
+
const point = this.point.decompressPoint();
|
|
3175
|
+
if (this.rgb) {
|
|
3176
|
+
this.rgb.decompressRgb(this.point.itemContextChannel);
|
|
3177
|
+
}
|
|
3178
|
+
else {
|
|
3179
|
+
this.stream.consume(6);
|
|
3180
|
+
}
|
|
3181
|
+
if (this.bytes && target.extraBytes) {
|
|
3182
|
+
this.bytes.decompress(target.extraBytes, targetPointIndex * this.extraByteCount, this.point.itemContextChannel);
|
|
3183
|
+
}
|
|
3184
|
+
else if (this.extraByteCount) {
|
|
3185
|
+
this.stream.consume(this.extraByteCount);
|
|
3186
|
+
}
|
|
3187
|
+
this.readFirstMetadata();
|
|
3188
|
+
writePoint14ToPointDataArrays(point, positions, intensities, classifications, scale, offset, targetPointIndex);
|
|
3189
|
+
writeGpsTimeToPointDataTarget(point, target, targetPointIndex);
|
|
3190
|
+
writePoint14MetadataToPointDataTarget(point, target, targetPointIndex);
|
|
3191
|
+
if (colors && this.rgb) {
|
|
3192
|
+
const colorOffset = targetPointIndex * 4;
|
|
3193
|
+
colors[colorOffset] = this.rgb.decodedRed & 0xff;
|
|
3194
|
+
colors[colorOffset + 1] = this.rgb.decodedGreen & 0xff;
|
|
3195
|
+
colors[colorOffset + 2] = this.rgb.decodedBlue & 0xff;
|
|
3196
|
+
colors[colorOffset + 3] = 255;
|
|
3197
|
+
}
|
|
3198
|
+
else if (rawColors && this.rgb) {
|
|
3199
|
+
const colorOffset = targetPointIndex * 3;
|
|
3200
|
+
rawColors[colorOffset] = this.rgb.decodedRed;
|
|
3201
|
+
rawColors[colorOffset + 1] = this.rgb.decodedGreen;
|
|
3202
|
+
rawColors[colorOffset + 2] = this.rgb.decodedBlue;
|
|
3203
|
+
}
|
|
3204
|
+
targetPointIndex++;
|
|
3205
|
+
remainingPointCount--;
|
|
3206
|
+
}
|
|
3207
|
+
const hasMetadataOutput = Boolean(target.gpsTimes ||
|
|
3208
|
+
target.scanAngles ||
|
|
3209
|
+
target.userData ||
|
|
3210
|
+
target.pointSourceIds ||
|
|
3211
|
+
target.returnNumbers ||
|
|
3212
|
+
target.numberOfReturns ||
|
|
3213
|
+
target.scannerChannels ||
|
|
3214
|
+
target.scanDirectionFlags ||
|
|
3215
|
+
target.edgeOfFlightLines ||
|
|
3216
|
+
target.syntheticFlags ||
|
|
3217
|
+
target.keyPointFlags ||
|
|
3218
|
+
target.withheldFlags ||
|
|
3219
|
+
target.overlapFlags);
|
|
3220
|
+
const hasExtraByteOutput = Boolean(this.bytes && target.extraBytes);
|
|
3221
|
+
if (!hasMetadataOutput && !hasExtraByteOutput) {
|
|
3222
|
+
for (let pointIndex = 0; pointIndex < remainingPointCount; pointIndex++) {
|
|
3223
|
+
const point = this.point.decompressPoint();
|
|
3224
|
+
this.rgb?.decompressRgb(this.point.itemContextChannel);
|
|
3225
|
+
writePoint14ToPointDataArrays(point, positions, intensities, classifications, scale, offset, targetPointIndex);
|
|
3226
|
+
if (colors && this.rgb) {
|
|
3227
|
+
const colorOffset = targetPointIndex * 4;
|
|
3228
|
+
colors[colorOffset] = this.rgb.decodedRed & 0xff;
|
|
3229
|
+
colors[colorOffset + 1] = this.rgb.decodedGreen & 0xff;
|
|
3230
|
+
colors[colorOffset + 2] = this.rgb.decodedBlue & 0xff;
|
|
3231
|
+
colors[colorOffset + 3] = 255;
|
|
3232
|
+
}
|
|
3233
|
+
else if (rawColors && this.rgb) {
|
|
3234
|
+
const colorOffset = targetPointIndex * 3;
|
|
3235
|
+
rawColors[colorOffset] = this.rgb.decodedRed;
|
|
3236
|
+
rawColors[colorOffset + 1] = this.rgb.decodedGreen;
|
|
3237
|
+
rawColors[colorOffset + 2] = this.rgb.decodedBlue;
|
|
3238
|
+
}
|
|
3239
|
+
targetPointIndex++;
|
|
3240
|
+
}
|
|
3241
|
+
return;
|
|
3242
|
+
}
|
|
3243
|
+
for (let pointIndex = 0; pointIndex < remainingPointCount; pointIndex++) {
|
|
3244
|
+
const point = this.point.decompressPoint();
|
|
3245
|
+
this.rgb?.decompressRgb(this.point.itemContextChannel);
|
|
3246
|
+
if (this.bytes && target.extraBytes) {
|
|
3247
|
+
this.bytes.decompress(target.extraBytes, targetPointIndex * this.extraByteCount, this.point.itemContextChannel);
|
|
3248
|
+
}
|
|
3249
|
+
writePoint14ToPointDataArrays(point, positions, intensities, classifications, scale, offset, targetPointIndex);
|
|
3250
|
+
writeGpsTimeToPointDataTarget(point, target, targetPointIndex);
|
|
3251
|
+
writePoint14MetadataToPointDataTarget(point, target, targetPointIndex);
|
|
3252
|
+
if (colors && this.rgb) {
|
|
3253
|
+
const colorOffset = targetPointIndex * 4;
|
|
3254
|
+
colors[colorOffset] = this.rgb.decodedRed & 0xff;
|
|
3255
|
+
colors[colorOffset + 1] = this.rgb.decodedGreen & 0xff;
|
|
3256
|
+
colors[colorOffset + 2] = this.rgb.decodedBlue & 0xff;
|
|
3257
|
+
colors[colorOffset + 3] = 255;
|
|
3258
|
+
}
|
|
3259
|
+
else if (rawColors && this.rgb) {
|
|
3260
|
+
const colorOffset = targetPointIndex * 3;
|
|
3261
|
+
rawColors[colorOffset] = this.rgb.decodedRed;
|
|
3262
|
+
rawColors[colorOffset + 1] = this.rgb.decodedGreen;
|
|
3263
|
+
rawColors[colorOffset + 2] = this.rgb.decodedBlue;
|
|
3264
|
+
}
|
|
3265
|
+
targetPointIndex++;
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
readFirstMetadata() {
|
|
3269
|
+
if (this.first) {
|
|
3270
|
+
this.stream.getUint32();
|
|
3271
|
+
this.point.readSizes();
|
|
3272
|
+
const skippedRgbByteLength = this.rgb ? 0 : this.stream.getUint32();
|
|
3273
|
+
this.rgb?.readSizes();
|
|
3274
|
+
let skippedExtraByteLength = 0;
|
|
3275
|
+
if (this.bytes) {
|
|
3276
|
+
this.bytes.readSizes();
|
|
3277
|
+
}
|
|
3278
|
+
else {
|
|
3279
|
+
for (let index = 0; index < this.extraByteCount; index++) {
|
|
3280
|
+
skippedExtraByteLength += this.stream.getUint32();
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
this.point.readData();
|
|
3284
|
+
if (this.rgb) {
|
|
3285
|
+
this.rgb.readData();
|
|
3286
|
+
}
|
|
3287
|
+
else {
|
|
3288
|
+
this.stream.consume(skippedRgbByteLength);
|
|
3289
|
+
}
|
|
3290
|
+
if (this.bytes) {
|
|
3291
|
+
this.bytes.readData();
|
|
3292
|
+
}
|
|
3293
|
+
else {
|
|
3294
|
+
this.stream.consume(skippedExtraByteLength);
|
|
3295
|
+
}
|
|
3296
|
+
this.first = false;
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
class PointFormat8Decompressor {
|
|
3301
|
+
stream;
|
|
3302
|
+
point;
|
|
3303
|
+
rgb;
|
|
3304
|
+
nir;
|
|
3305
|
+
bytes;
|
|
3306
|
+
/** Extra bytes stored with the first point and in independent later layers. */
|
|
3307
|
+
extraByteCount;
|
|
3308
|
+
first = true;
|
|
3309
|
+
constructor(stream, extraByteCount, outputMode, metadata, selection) {
|
|
3310
|
+
this.stream = stream;
|
|
3311
|
+
this.extraByteCount = extraByteCount;
|
|
3312
|
+
this.point = new Point14Decompressor(stream, outputMode === 'raw' ? Point14DecompressionMode.Full : Point14DecompressionMode.PointData, metadata.point14ItemVersion ?? 3, selection);
|
|
3313
|
+
this.rgb =
|
|
3314
|
+
outputMode === 'raw' || selection?.color
|
|
3315
|
+
? new RGB14Decompressor(stream, metadata.rgb14ItemVersion ?? 3)
|
|
3316
|
+
: null;
|
|
3317
|
+
this.nir =
|
|
3318
|
+
outputMode === 'raw' || selection?.nir
|
|
3319
|
+
? new NIR14Decompressor(stream, metadata.rgb14ItemVersion ?? 3)
|
|
3320
|
+
: null;
|
|
3321
|
+
this.bytes =
|
|
3322
|
+
(outputMode === 'raw' || selection?.extraBytes) && extraByteCount
|
|
3323
|
+
? new Byte14Decompressor(stream, extraByteCount, metadata.byte14ItemVersion ?? 3)
|
|
3324
|
+
: null;
|
|
3325
|
+
}
|
|
3326
|
+
decompress(output, outputOffset) {
|
|
3327
|
+
outputOffset = this.point.decompress(output, outputOffset);
|
|
3328
|
+
outputOffset = this.rgb.decompress(output, outputOffset, this.point.itemContextChannel);
|
|
3329
|
+
outputOffset = this.nir.decompress(output, outputOffset, this.point.itemContextChannel);
|
|
3330
|
+
if (this.bytes) {
|
|
3331
|
+
outputOffset = this.bytes.decompress(output, outputOffset, this.point.itemContextChannel);
|
|
3332
|
+
}
|
|
3333
|
+
this.readFirstMetadata();
|
|
3334
|
+
return outputOffset;
|
|
3335
|
+
}
|
|
3336
|
+
decompressPointData(target, targetPointIndex) {
|
|
3337
|
+
const point = this.point.decompressPoint();
|
|
3338
|
+
if (this.rgb) {
|
|
3339
|
+
this.rgb.decompressRgb(this.point.itemContextChannel);
|
|
3340
|
+
}
|
|
3341
|
+
else if (this.first) {
|
|
3342
|
+
this.stream.consume(6);
|
|
3343
|
+
}
|
|
3344
|
+
if (!this.nir && this.first) {
|
|
3345
|
+
this.stream.consume(2);
|
|
3346
|
+
}
|
|
3347
|
+
const nir = this.nir ? this.nir.decompressNir(this.point.itemContextChannel) : 0;
|
|
3348
|
+
if (this.bytes && target.extraBytes) {
|
|
3349
|
+
this.bytes.decompress(target.extraBytes, targetPointIndex * this.extraByteCount, this.point.itemContextChannel);
|
|
3350
|
+
}
|
|
3351
|
+
if (this.first) {
|
|
3352
|
+
this.stream.consume(this.bytes ? 0 : this.extraByteCount);
|
|
3353
|
+
}
|
|
3354
|
+
this.readFirstMetadata();
|
|
3355
|
+
writePoint14ToPointDataTarget(point, target, targetPointIndex);
|
|
3356
|
+
writeNirToPointDataTarget(nir, target, targetPointIndex);
|
|
3357
|
+
if (this.rgb) {
|
|
3358
|
+
writeRgbToPointDataTarget(this.rgb.decodedRed, this.rgb.decodedGreen, this.rgb.decodedBlue, target, targetPointIndex);
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
decompressPointDataBatch(target, pointCount) {
|
|
3362
|
+
const positions = target.positions;
|
|
3363
|
+
const intensities = target.intensities;
|
|
3364
|
+
const classifications = target.classifications;
|
|
3365
|
+
const colors = target.colors;
|
|
3366
|
+
const rawColors = target.rawColors;
|
|
3367
|
+
const scale = target.scale;
|
|
3368
|
+
const offset = target.offset;
|
|
3369
|
+
let targetPointIndex = target.pointOffset;
|
|
3370
|
+
for (let pointIndex = 0; pointIndex < pointCount; pointIndex++) {
|
|
3371
|
+
const point = this.point.decompressPoint();
|
|
3372
|
+
if (this.rgb) {
|
|
3373
|
+
this.rgb.decompressRgb(this.point.itemContextChannel);
|
|
3374
|
+
}
|
|
3375
|
+
else if (this.first) {
|
|
3376
|
+
this.stream.consume(6);
|
|
3377
|
+
}
|
|
3378
|
+
if (!this.nir && this.first) {
|
|
3379
|
+
this.stream.consume(2);
|
|
3380
|
+
}
|
|
3381
|
+
const nir = this.nir ? this.nir.decompressNir(this.point.itemContextChannel) : 0;
|
|
3382
|
+
if (this.bytes && target.extraBytes) {
|
|
3383
|
+
this.bytes.decompress(target.extraBytes, targetPointIndex * this.extraByteCount, this.point.itemContextChannel);
|
|
3384
|
+
}
|
|
3385
|
+
if (this.first) {
|
|
3386
|
+
this.stream.consume(this.bytes ? 0 : this.extraByteCount);
|
|
3387
|
+
}
|
|
3388
|
+
this.readFirstMetadata();
|
|
3389
|
+
writePoint14ToPointDataArrays(point, positions, intensities, classifications, scale, offset, targetPointIndex);
|
|
3390
|
+
writeGpsTimeToPointDataTarget(point, target, targetPointIndex);
|
|
3391
|
+
writePoint14MetadataToPointDataTarget(point, target, targetPointIndex);
|
|
3392
|
+
if (colors && this.rgb) {
|
|
3393
|
+
const colorOffset = targetPointIndex * 4;
|
|
3394
|
+
colors[colorOffset] = this.rgb.decodedRed & 0xff;
|
|
3395
|
+
colors[colorOffset + 1] = this.rgb.decodedGreen & 0xff;
|
|
3396
|
+
colors[colorOffset + 2] = this.rgb.decodedBlue & 0xff;
|
|
3397
|
+
colors[colorOffset + 3] = 255;
|
|
3398
|
+
}
|
|
3399
|
+
else if (rawColors && this.rgb) {
|
|
3400
|
+
const colorOffset = targetPointIndex * 3;
|
|
3401
|
+
rawColors[colorOffset] = this.rgb.decodedRed;
|
|
3402
|
+
rawColors[colorOffset + 1] = this.rgb.decodedGreen;
|
|
3403
|
+
rawColors[colorOffset + 2] = this.rgb.decodedBlue;
|
|
3404
|
+
}
|
|
3405
|
+
writeNirToPointDataTarget(nir, target, targetPointIndex);
|
|
3406
|
+
targetPointIndex++;
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
readFirstMetadata() {
|
|
3410
|
+
if (this.first) {
|
|
3411
|
+
this.stream.getUint32();
|
|
3412
|
+
this.point.readSizes();
|
|
3413
|
+
const skippedRgbByteLength = this.rgb ? 0 : this.stream.getUint32();
|
|
3414
|
+
this.rgb?.readSizes();
|
|
3415
|
+
const skippedNirByteLength = this.nir ? 0 : this.stream.getUint32();
|
|
3416
|
+
this.nir?.readSizes();
|
|
3417
|
+
let skippedExtraByteLength = 0;
|
|
3418
|
+
if (this.bytes) {
|
|
3419
|
+
this.bytes.readSizes();
|
|
3420
|
+
}
|
|
3421
|
+
else {
|
|
3422
|
+
for (let index = 0; index < this.extraByteCount; index++) {
|
|
3423
|
+
skippedExtraByteLength += this.stream.getUint32();
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
this.point.readData();
|
|
3427
|
+
if (this.rgb) {
|
|
3428
|
+
this.rgb.readData();
|
|
3429
|
+
}
|
|
3430
|
+
else {
|
|
3431
|
+
this.stream.consume(skippedRgbByteLength);
|
|
3432
|
+
}
|
|
3433
|
+
if (this.nir) {
|
|
3434
|
+
this.nir.readData();
|
|
3435
|
+
}
|
|
3436
|
+
else {
|
|
3437
|
+
this.stream.consume(skippedNirByteLength);
|
|
3438
|
+
}
|
|
3439
|
+
if (this.bytes) {
|
|
3440
|
+
this.bytes.readData();
|
|
3441
|
+
}
|
|
3442
|
+
else {
|
|
3443
|
+
this.stream.consume(skippedExtraByteLength);
|
|
3444
|
+
}
|
|
3445
|
+
this.first = false;
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
/** LASzip layered decoder for LAS 1.4 point format 9. */
|
|
3450
|
+
class PointFormat9Decompressor {
|
|
3451
|
+
/** Compressed chunk source. */
|
|
3452
|
+
stream;
|
|
3453
|
+
/** Core LAS 1.4 point decoder. */
|
|
3454
|
+
point;
|
|
3455
|
+
/** Waveform packet reference decoder, omitted for selective Arrow output. */
|
|
3456
|
+
wavePacket;
|
|
3457
|
+
/** Extra Bytes decoder retained for raw or selected direct output. */
|
|
3458
|
+
bytes;
|
|
3459
|
+
/** Extra bytes stored with the first point and in independent later layers. */
|
|
3460
|
+
extraByteCount;
|
|
3461
|
+
/** Whether the first point and layered stream metadata remain unread. */
|
|
3462
|
+
first = true;
|
|
3463
|
+
waveformScratch = new Uint8Array(29);
|
|
3464
|
+
constructor(stream, extraByteCount, outputMode, metadata, selection) {
|
|
3465
|
+
this.stream = stream;
|
|
3466
|
+
this.extraByteCount = extraByteCount;
|
|
3467
|
+
this.point = new Point14Decompressor(stream, outputMode === 'raw' ? Point14DecompressionMode.Full : Point14DecompressionMode.PointData, metadata.point14ItemVersion ?? 3, selection);
|
|
3468
|
+
this.wavePacket =
|
|
3469
|
+
outputMode === 'raw' || Boolean(selection?.waveform)
|
|
3470
|
+
? new WavePacket14Decompressor(stream, metadata.wavePacketItemVersion ?? 3)
|
|
3471
|
+
: null;
|
|
3472
|
+
this.bytes =
|
|
3473
|
+
(outputMode === 'raw' || selection?.extraBytes) && extraByteCount
|
|
3474
|
+
? new Byte14Decompressor(stream, extraByteCount, metadata.byte14ItemVersion ?? 3)
|
|
3475
|
+
: null;
|
|
3476
|
+
}
|
|
3477
|
+
/** Decode one complete PDRF 9 point record. */
|
|
3478
|
+
decompress(output, outputOffset) {
|
|
3479
|
+
outputOffset = this.point.decompress(output, outputOffset);
|
|
3480
|
+
outputOffset = this.wavePacket.decompress(output, outputOffset, this.point.itemContextChannel);
|
|
3481
|
+
if (this.bytes) {
|
|
3482
|
+
outputOffset = this.bytes.decompress(output, outputOffset, this.point.itemContextChannel);
|
|
3483
|
+
}
|
|
3484
|
+
this.readFirstMetadata();
|
|
3485
|
+
return outputOffset;
|
|
3486
|
+
}
|
|
3487
|
+
/** Decode one PDRF 9 point directly into represented Arrow columns. */
|
|
3488
|
+
decompressPointData(target, targetPointIndex) {
|
|
3489
|
+
const point = this.point.decompressPoint();
|
|
3490
|
+
if (this.wavePacket) {
|
|
3491
|
+
this.wavePacket.decompressToTarget(this.waveformScratch, 0, this.point.itemContextChannel);
|
|
3492
|
+
if (target.waveforms) {
|
|
3493
|
+
target.waveforms.set(this.waveformScratch, targetPointIndex * 29);
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
else if (this.first) {
|
|
3497
|
+
this.stream.consume(29);
|
|
3498
|
+
}
|
|
3499
|
+
if (this.bytes && target.extraBytes) {
|
|
3500
|
+
this.bytes.decompress(target.extraBytes, targetPointIndex * this.extraByteCount, this.point.itemContextChannel);
|
|
3501
|
+
}
|
|
3502
|
+
else if (this.first) {
|
|
3503
|
+
this.stream.consume(this.extraByteCount);
|
|
3504
|
+
}
|
|
3505
|
+
this.readFirstMetadata();
|
|
3506
|
+
writePoint14ToPointDataTarget(point, target, targetPointIndex);
|
|
3507
|
+
}
|
|
3508
|
+
/** Decode PDRF 9 points directly into represented Arrow columns. */
|
|
3509
|
+
decompressPointDataBatch(target, pointCount) {
|
|
3510
|
+
const positions = target.positions;
|
|
3511
|
+
const intensities = target.intensities;
|
|
3512
|
+
const classifications = target.classifications;
|
|
3513
|
+
const scale = target.scale;
|
|
3514
|
+
const offset = target.offset;
|
|
3515
|
+
let targetPointIndex = target.pointOffset;
|
|
3516
|
+
for (let pointIndex = 0; pointIndex < pointCount; pointIndex++) {
|
|
3517
|
+
const point = this.point.decompressPoint();
|
|
3518
|
+
if (this.wavePacket) {
|
|
3519
|
+
this.wavePacket.decompressToTarget(this.waveformScratch, 0, this.point.itemContextChannel);
|
|
3520
|
+
if (target.waveforms) {
|
|
3521
|
+
target.waveforms.set(this.waveformScratch, targetPointIndex * 29);
|
|
3522
|
+
}
|
|
3523
|
+
}
|
|
3524
|
+
else if (this.first) {
|
|
3525
|
+
this.stream.consume(29);
|
|
3526
|
+
}
|
|
3527
|
+
if (this.bytes && target.extraBytes) {
|
|
3528
|
+
this.bytes.decompress(target.extraBytes, targetPointIndex * this.extraByteCount, this.point.itemContextChannel);
|
|
3529
|
+
}
|
|
3530
|
+
else if (this.first) {
|
|
3531
|
+
this.stream.consume(this.extraByteCount);
|
|
3532
|
+
}
|
|
3533
|
+
this.readFirstMetadata();
|
|
3534
|
+
writePoint14ToPointDataArrays(point, positions, intensities, classifications, scale, offset, targetPointIndex++);
|
|
3535
|
+
writeGpsTimeToPointDataTarget(point, target, targetPointIndex - 1);
|
|
3536
|
+
writePoint14MetadataToPointDataTarget(point, target, targetPointIndex - 1);
|
|
3537
|
+
}
|
|
3538
|
+
}
|
|
3539
|
+
/** Read and bind or skip the independent PDRF 9 field layers. */
|
|
3540
|
+
readFirstMetadata() {
|
|
3541
|
+
if (this.first) {
|
|
3542
|
+
this.stream.getUint32();
|
|
3543
|
+
this.point.readSizes();
|
|
3544
|
+
const skippedWavePacketByteLength = this.wavePacket ? 0 : this.stream.getUint32();
|
|
3545
|
+
this.wavePacket?.readSizes();
|
|
3546
|
+
let skippedExtraByteLength = 0;
|
|
3547
|
+
if (this.bytes) {
|
|
3548
|
+
this.bytes.readSizes();
|
|
3549
|
+
}
|
|
3550
|
+
else {
|
|
3551
|
+
for (let index = 0; index < this.extraByteCount; index++) {
|
|
3552
|
+
skippedExtraByteLength += this.stream.getUint32();
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
this.point.readData();
|
|
3556
|
+
if (this.wavePacket) {
|
|
3557
|
+
this.wavePacket.readData();
|
|
3558
|
+
}
|
|
3559
|
+
else {
|
|
3560
|
+
this.stream.consume(skippedWavePacketByteLength);
|
|
3561
|
+
}
|
|
3562
|
+
if (this.bytes) {
|
|
3563
|
+
this.bytes.readData();
|
|
3564
|
+
}
|
|
3565
|
+
else {
|
|
3566
|
+
this.stream.consume(skippedExtraByteLength);
|
|
3567
|
+
}
|
|
3568
|
+
this.first = false;
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
/** LASzip layered decoder for LAS 1.4 point format 10. */
|
|
3573
|
+
class PointFormat10Decompressor {
|
|
3574
|
+
/** Compressed chunk source. */
|
|
3575
|
+
stream;
|
|
3576
|
+
/** Core LAS 1.4 point decoder. */
|
|
3577
|
+
point;
|
|
3578
|
+
/** RGB decoder retained for raw output or when direct output requests color. */
|
|
3579
|
+
rgb;
|
|
3580
|
+
/** NIR decoder, omitted for selective Arrow output. */
|
|
3581
|
+
nir;
|
|
3582
|
+
/** Waveform packet reference decoder, omitted for selective Arrow output. */
|
|
3583
|
+
wavePacket;
|
|
3584
|
+
/** Extra Bytes decoder retained for raw or selected direct output. */
|
|
3585
|
+
bytes;
|
|
3586
|
+
/** Extra bytes stored with the first point and in independent later layers. */
|
|
3587
|
+
extraByteCount;
|
|
3588
|
+
/** Whether the first point and layered stream metadata remain unread. */
|
|
3589
|
+
first = true;
|
|
3590
|
+
waveformScratch = new Uint8Array(29);
|
|
3591
|
+
constructor(stream, extraByteCount, outputMode, metadata, selection) {
|
|
3592
|
+
this.stream = stream;
|
|
3593
|
+
this.extraByteCount = extraByteCount;
|
|
3594
|
+
this.point = new Point14Decompressor(stream, outputMode === 'raw' ? Point14DecompressionMode.Full : Point14DecompressionMode.PointData, metadata.point14ItemVersion ?? 3, selection);
|
|
3595
|
+
this.rgb =
|
|
3596
|
+
outputMode === 'raw' || selection?.color
|
|
3597
|
+
? new RGB14Decompressor(stream, metadata.rgb14ItemVersion ?? 3)
|
|
3598
|
+
: null;
|
|
3599
|
+
this.nir =
|
|
3600
|
+
outputMode === 'raw' || selection?.nir
|
|
3601
|
+
? new NIR14Decompressor(stream, metadata.rgb14ItemVersion ?? 3)
|
|
3602
|
+
: null;
|
|
3603
|
+
this.wavePacket =
|
|
3604
|
+
outputMode === 'raw' || Boolean(selection?.waveform)
|
|
3605
|
+
? new WavePacket14Decompressor(stream, metadata.wavePacketItemVersion ?? 3)
|
|
3606
|
+
: null;
|
|
3607
|
+
this.bytes =
|
|
3608
|
+
(outputMode === 'raw' || selection?.extraBytes) && extraByteCount
|
|
3609
|
+
? new Byte14Decompressor(stream, extraByteCount, metadata.byte14ItemVersion ?? 3)
|
|
3610
|
+
: null;
|
|
3611
|
+
}
|
|
3612
|
+
/** Decode one complete PDRF 10 point record. */
|
|
3613
|
+
decompress(output, outputOffset) {
|
|
3614
|
+
outputOffset = this.point.decompress(output, outputOffset);
|
|
3615
|
+
outputOffset = this.rgb.decompress(output, outputOffset, this.point.itemContextChannel);
|
|
3616
|
+
outputOffset = this.nir.decompress(output, outputOffset, this.point.itemContextChannel);
|
|
3617
|
+
outputOffset = this.wavePacket.decompress(output, outputOffset, this.point.itemContextChannel);
|
|
3618
|
+
if (this.bytes) {
|
|
3619
|
+
outputOffset = this.bytes.decompress(output, outputOffset, this.point.itemContextChannel);
|
|
3620
|
+
}
|
|
3621
|
+
this.readFirstMetadata();
|
|
3622
|
+
return outputOffset;
|
|
3623
|
+
}
|
|
3624
|
+
/** Decode one PDRF 10 point directly into represented Arrow columns. */
|
|
3625
|
+
decompressPointData(target, targetPointIndex) {
|
|
3626
|
+
const point = this.point.decompressPoint();
|
|
3627
|
+
if (this.rgb) {
|
|
3628
|
+
this.rgb.decompressRgb(this.point.itemContextChannel);
|
|
3629
|
+
}
|
|
3630
|
+
else if (this.first) {
|
|
3631
|
+
this.stream.consume(6);
|
|
3632
|
+
}
|
|
3633
|
+
const nir = this.nir ? this.nir.decompressNir(this.point.itemContextChannel) : 0;
|
|
3634
|
+
if (this.first) {
|
|
3635
|
+
this.stream.consume(this.nir ? 0 : 2);
|
|
3636
|
+
}
|
|
3637
|
+
if (this.wavePacket) {
|
|
3638
|
+
this.wavePacket.decompressToTarget(this.waveformScratch, 0, this.point.itemContextChannel);
|
|
3639
|
+
if (target.waveforms) {
|
|
3640
|
+
target.waveforms.set(this.waveformScratch, targetPointIndex * 29);
|
|
3641
|
+
}
|
|
3642
|
+
}
|
|
3643
|
+
else if (this.first) {
|
|
3644
|
+
this.stream.consume(29);
|
|
3645
|
+
}
|
|
3646
|
+
if (this.bytes && target.extraBytes) {
|
|
3647
|
+
this.bytes.decompress(target.extraBytes, targetPointIndex * this.extraByteCount, this.point.itemContextChannel);
|
|
3648
|
+
}
|
|
3649
|
+
else if (this.first) {
|
|
3650
|
+
this.stream.consume(this.extraByteCount);
|
|
3651
|
+
}
|
|
3652
|
+
this.readFirstMetadata();
|
|
3653
|
+
writePoint14ToPointDataTarget(point, target, targetPointIndex);
|
|
3654
|
+
writeNirToPointDataTarget(nir, target, targetPointIndex);
|
|
3655
|
+
if (this.rgb) {
|
|
3656
|
+
writeRgbToPointDataTarget(this.rgb.decodedRed, this.rgb.decodedGreen, this.rgb.decodedBlue, target, targetPointIndex);
|
|
3657
|
+
}
|
|
3658
|
+
}
|
|
3659
|
+
/** Decode PDRF 10 points directly into represented Arrow columns. */
|
|
3660
|
+
decompressPointDataBatch(target, pointCount) {
|
|
3661
|
+
const positions = target.positions;
|
|
3662
|
+
const intensities = target.intensities;
|
|
3663
|
+
const classifications = target.classifications;
|
|
3664
|
+
const colors = target.colors;
|
|
3665
|
+
const rawColors = target.rawColors;
|
|
3666
|
+
const scale = target.scale;
|
|
3667
|
+
const offset = target.offset;
|
|
3668
|
+
let targetPointIndex = target.pointOffset;
|
|
3669
|
+
for (let pointIndex = 0; pointIndex < pointCount; pointIndex++) {
|
|
3670
|
+
const point = this.point.decompressPoint();
|
|
3671
|
+
if (this.rgb) {
|
|
3672
|
+
this.rgb.decompressRgb(this.point.itemContextChannel);
|
|
3673
|
+
}
|
|
3674
|
+
else if (this.first) {
|
|
3675
|
+
this.stream.consume(6);
|
|
3676
|
+
}
|
|
3677
|
+
const nir = this.nir ? this.nir.decompressNir(this.point.itemContextChannel) : 0;
|
|
3678
|
+
if (this.first) {
|
|
3679
|
+
this.stream.consume(this.nir ? 0 : 2);
|
|
3680
|
+
}
|
|
3681
|
+
if (this.wavePacket) {
|
|
3682
|
+
this.wavePacket.decompressToTarget(this.waveformScratch, 0, this.point.itemContextChannel);
|
|
3683
|
+
if (target.waveforms) {
|
|
3684
|
+
target.waveforms.set(this.waveformScratch, targetPointIndex * 29);
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
else if (this.first) {
|
|
3688
|
+
this.stream.consume(29);
|
|
3689
|
+
}
|
|
3690
|
+
if (this.bytes && target.extraBytes) {
|
|
3691
|
+
this.bytes.decompress(target.extraBytes, targetPointIndex * this.extraByteCount, this.point.itemContextChannel);
|
|
3692
|
+
}
|
|
3693
|
+
else if (this.first) {
|
|
3694
|
+
this.stream.consume(this.extraByteCount);
|
|
3695
|
+
}
|
|
3696
|
+
this.readFirstMetadata();
|
|
3697
|
+
writePoint14ToPointDataArrays(point, positions, intensities, classifications, scale, offset, targetPointIndex);
|
|
3698
|
+
writeGpsTimeToPointDataTarget(point, target, targetPointIndex);
|
|
3699
|
+
writePoint14MetadataToPointDataTarget(point, target, targetPointIndex);
|
|
3700
|
+
if (colors && this.rgb) {
|
|
3701
|
+
const colorOffset = targetPointIndex * 4;
|
|
3702
|
+
colors[colorOffset] = this.rgb.decodedRed & 0xff;
|
|
3703
|
+
colors[colorOffset + 1] = this.rgb.decodedGreen & 0xff;
|
|
3704
|
+
colors[colorOffset + 2] = this.rgb.decodedBlue & 0xff;
|
|
3705
|
+
colors[colorOffset + 3] = 255;
|
|
3706
|
+
}
|
|
3707
|
+
else if (rawColors && this.rgb) {
|
|
3708
|
+
const colorOffset = targetPointIndex * 3;
|
|
3709
|
+
rawColors[colorOffset] = this.rgb.decodedRed;
|
|
3710
|
+
rawColors[colorOffset + 1] = this.rgb.decodedGreen;
|
|
3711
|
+
rawColors[colorOffset + 2] = this.rgb.decodedBlue;
|
|
3712
|
+
}
|
|
3713
|
+
writeNirToPointDataTarget(nir, target, targetPointIndex);
|
|
3714
|
+
targetPointIndex++;
|
|
3715
|
+
}
|
|
3716
|
+
}
|
|
3717
|
+
/** Read and bind or skip the independent PDRF 10 field layers. */
|
|
3718
|
+
readFirstMetadata() {
|
|
3719
|
+
if (this.first) {
|
|
3720
|
+
this.stream.getUint32();
|
|
3721
|
+
this.point.readSizes();
|
|
3722
|
+
const skippedRgbByteLength = this.rgb ? 0 : this.stream.getUint32();
|
|
3723
|
+
this.rgb?.readSizes();
|
|
3724
|
+
const skippedNirByteLength = this.nir ? 0 : this.stream.getUint32();
|
|
3725
|
+
this.nir?.readSizes();
|
|
3726
|
+
const skippedWavePacketByteLength = this.wavePacket ? 0 : this.stream.getUint32();
|
|
3727
|
+
this.wavePacket?.readSizes();
|
|
3728
|
+
let skippedExtraByteLength = 0;
|
|
3729
|
+
if (this.bytes) {
|
|
3730
|
+
this.bytes.readSizes();
|
|
3731
|
+
}
|
|
3732
|
+
else {
|
|
3733
|
+
for (let index = 0; index < this.extraByteCount; index++) {
|
|
3734
|
+
skippedExtraByteLength += this.stream.getUint32();
|
|
3735
|
+
}
|
|
3736
|
+
}
|
|
3737
|
+
this.point.readData();
|
|
3738
|
+
if (this.rgb) {
|
|
3739
|
+
this.rgb.readData();
|
|
3740
|
+
}
|
|
3741
|
+
else {
|
|
3742
|
+
this.stream.consume(skippedRgbByteLength);
|
|
3743
|
+
}
|
|
3744
|
+
if (this.nir) {
|
|
3745
|
+
this.nir.readData();
|
|
3746
|
+
}
|
|
3747
|
+
else {
|
|
3748
|
+
this.stream.consume(skippedNirByteLength);
|
|
3749
|
+
}
|
|
3750
|
+
if (this.wavePacket) {
|
|
3751
|
+
this.wavePacket.readData();
|
|
3752
|
+
}
|
|
3753
|
+
else {
|
|
3754
|
+
this.stream.consume(skippedWavePacketByteLength);
|
|
3755
|
+
}
|
|
3756
|
+
if (this.bytes) {
|
|
3757
|
+
this.bytes.readData();
|
|
3758
|
+
}
|
|
3759
|
+
else {
|
|
3760
|
+
this.stream.consume(skippedExtraByteLength);
|
|
3761
|
+
}
|
|
3762
|
+
this.first = false;
|
|
3763
|
+
}
|
|
3764
|
+
}
|
|
3765
|
+
}
|
|
3766
|
+
function createIntegerDecompressor(bits, contexts) {
|
|
3767
|
+
const decompressor = new IntegerDecompressor(bits, contexts);
|
|
3768
|
+
decompressor.init();
|
|
3769
|
+
return decompressor;
|
|
3770
|
+
}
|
|
3771
|
+
function createModels(count, symbols) {
|
|
3772
|
+
return Array.from({ length: count }, () => new ArithmeticModel(symbols));
|
|
3773
|
+
}
|
|
3774
|
+
function getExtraByteCount(metadata) {
|
|
3775
|
+
const baseLength = getPointDataRecordBaseLength(metadata.pointDataRecordFormat);
|
|
3776
|
+
const extraByteCount = metadata.pointDataRecordLength - baseLength;
|
|
3777
|
+
if (extraByteCount < 0) {
|
|
3778
|
+
throw new Error(`Invalid point record length ${metadata.pointDataRecordLength}`);
|
|
3779
|
+
}
|
|
3780
|
+
return extraByteCount;
|
|
3781
|
+
}
|
|
3782
|
+
function getPointDataRecordBaseLength(pointDataRecordFormat) {
|
|
3783
|
+
switch (pointDataRecordFormat) {
|
|
3784
|
+
case 0:
|
|
3785
|
+
return 20;
|
|
3786
|
+
case 1:
|
|
3787
|
+
return 28;
|
|
3788
|
+
case 2:
|
|
3789
|
+
return 26;
|
|
3790
|
+
case 3:
|
|
3791
|
+
return 34;
|
|
3792
|
+
case 4:
|
|
3793
|
+
return 57;
|
|
3794
|
+
case 5:
|
|
3795
|
+
return 63;
|
|
3796
|
+
case 6:
|
|
3797
|
+
return 30;
|
|
3798
|
+
case 7:
|
|
3799
|
+
return 36;
|
|
3800
|
+
case 8:
|
|
3801
|
+
return 38;
|
|
3802
|
+
case 9:
|
|
3803
|
+
return 59;
|
|
3804
|
+
case 10:
|
|
3805
|
+
return 67;
|
|
3806
|
+
default:
|
|
3807
|
+
throw new Error(`TypeScript LAZ decoder does not support point format ${pointDataRecordFormat}`);
|
|
3808
|
+
}
|
|
3809
|
+
}
|
|
3810
|
+
function hasLayeredChunkSizeHeaders(pointDataRecordFormat) {
|
|
3811
|
+
return pointDataRecordFormat >= 6 && pointDataRecordFormat <= 10;
|
|
3812
|
+
}
|
|
3813
|
+
function getChunkSizeHeaderCount(pointDataRecordFormat, extraByteCount) {
|
|
3814
|
+
switch (pointDataRecordFormat) {
|
|
3815
|
+
case 6:
|
|
3816
|
+
return 9 + extraByteCount;
|
|
3817
|
+
case 7:
|
|
3818
|
+
return 10 + extraByteCount;
|
|
3819
|
+
case 8:
|
|
3820
|
+
return 11 + extraByteCount;
|
|
3821
|
+
case 9:
|
|
3822
|
+
return 10 + extraByteCount;
|
|
3823
|
+
case 10:
|
|
3824
|
+
return 12 + extraByteCount;
|
|
3825
|
+
default:
|
|
3826
|
+
throw new Error(`TypeScript LAZ decoder does not support point format ${pointDataRecordFormat}`);
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
function createPoint14() {
|
|
3830
|
+
return {
|
|
3831
|
+
x: 0,
|
|
3832
|
+
y: 0,
|
|
3833
|
+
z: 0,
|
|
3834
|
+
intensity: 0,
|
|
3835
|
+
returns: 0,
|
|
3836
|
+
flags: 0,
|
|
3837
|
+
classification: 0,
|
|
3838
|
+
userData: 0,
|
|
3839
|
+
scanAngle: 0,
|
|
3840
|
+
pointSourceId: 0,
|
|
3841
|
+
gpsTime: 0
|
|
3842
|
+
};
|
|
3843
|
+
}
|
|
3844
|
+
function createPoint10() {
|
|
3845
|
+
return {
|
|
3846
|
+
x: 0,
|
|
3847
|
+
y: 0,
|
|
3848
|
+
z: 0,
|
|
3849
|
+
intensity: 0,
|
|
3850
|
+
bitByte: 0,
|
|
3851
|
+
classification: 0,
|
|
3852
|
+
scanAngleRank: 0,
|
|
3853
|
+
userData: 0,
|
|
3854
|
+
pointSourceId: 0
|
|
3855
|
+
};
|
|
3856
|
+
}
|
|
3857
|
+
/** Read one unaligned legacy core point directly into reusable predictor state. */
|
|
3858
|
+
function readPoint10FromStreamInto(point, stream) {
|
|
3859
|
+
point.x = readInt32FromStream(stream);
|
|
3860
|
+
point.y = readInt32FromStream(stream);
|
|
3861
|
+
point.z = readInt32FromStream(stream);
|
|
3862
|
+
point.intensity = readUint16FromStream(stream);
|
|
3863
|
+
point.bitByte = stream.getByte();
|
|
3864
|
+
point.classification = stream.getByte();
|
|
3865
|
+
point.scanAngleRank = toInt8(stream.getByte());
|
|
3866
|
+
point.userData = stream.getByte();
|
|
3867
|
+
point.pointSourceId = readUint16FromStream(stream);
|
|
3868
|
+
}
|
|
3869
|
+
/** Copy legacy point predictor state in place without allocating an object. */
|
|
3870
|
+
function copyPoint10(target, source) {
|
|
3871
|
+
target.x = source.x;
|
|
3872
|
+
target.y = source.y;
|
|
3873
|
+
target.z = source.z;
|
|
3874
|
+
target.intensity = source.intensity;
|
|
3875
|
+
target.bitByte = source.bitByte;
|
|
3876
|
+
target.classification = source.classification;
|
|
3877
|
+
target.scanAngleRank = source.scanAngleRank;
|
|
3878
|
+
target.userData = source.userData;
|
|
3879
|
+
target.pointSourceId = source.pointSourceId;
|
|
3880
|
+
}
|
|
3881
|
+
function writePoint10(point, bytes, offset) {
|
|
3882
|
+
writeInt32(point.x, bytes, offset);
|
|
3883
|
+
writeInt32(point.y, bytes, offset + 4);
|
|
3884
|
+
writeInt32(point.z, bytes, offset + 8);
|
|
3885
|
+
writeUint16(point.intensity, bytes, offset + 12);
|
|
3886
|
+
bytes[offset + 14] = point.bitByte;
|
|
3887
|
+
bytes[offset + 15] = point.classification;
|
|
3888
|
+
bytes[offset + 16] = point.scanAngleRank & 0xff;
|
|
3889
|
+
bytes[offset + 17] = point.userData;
|
|
3890
|
+
writeUint16(point.pointSourceId, bytes, offset + 18);
|
|
3891
|
+
}
|
|
3892
|
+
/** Write common legacy point fields directly into caller-owned typed arrays. */
|
|
3893
|
+
function writePoint10ToPointDataArrays(point, positions, intensities, classifications, scale, offset, targetPointIndex) {
|
|
3894
|
+
const positionOffset = targetPointIndex * 3;
|
|
3895
|
+
positions[positionOffset] = point.x * scale[0] + offset[0];
|
|
3896
|
+
positions[positionOffset + 1] = point.y * scale[1] + offset[1];
|
|
3897
|
+
positions[positionOffset + 2] = point.z * scale[2] + offset[2];
|
|
3898
|
+
if (intensities) {
|
|
3899
|
+
intensities[targetPointIndex] = point.intensity;
|
|
3900
|
+
}
|
|
3901
|
+
if (classifications) {
|
|
3902
|
+
classifications[targetPointIndex] = point.classification & 0x1f;
|
|
3903
|
+
}
|
|
3904
|
+
}
|
|
3905
|
+
/** Write optional legacy point metadata into the columns represented by a decode target. */
|
|
3906
|
+
function writePoint10MetadataToPointDataTarget(point, target, targetPointIndex) {
|
|
3907
|
+
const classificationFlags = point.classification >> 5;
|
|
3908
|
+
if (target.syntheticFlags) {
|
|
3909
|
+
target.syntheticFlags[targetPointIndex] = classificationFlags & 1;
|
|
3910
|
+
}
|
|
3911
|
+
if (target.keyPointFlags) {
|
|
3912
|
+
target.keyPointFlags[targetPointIndex] = (classificationFlags >> 1) & 1;
|
|
3913
|
+
}
|
|
3914
|
+
if (target.withheldFlags) {
|
|
3915
|
+
target.withheldFlags[targetPointIndex] = (classificationFlags >> 2) & 1;
|
|
3916
|
+
}
|
|
3917
|
+
if (target.overlapFlags) {
|
|
3918
|
+
target.overlapFlags[targetPointIndex] = 0;
|
|
3919
|
+
}
|
|
3920
|
+
if (target.scanAngles) {
|
|
3921
|
+
target.scanAngles[targetPointIndex] = point.scanAngleRank;
|
|
3922
|
+
}
|
|
3923
|
+
if (target.userData) {
|
|
3924
|
+
target.userData[targetPointIndex] = point.userData;
|
|
3925
|
+
}
|
|
3926
|
+
if (target.pointSourceIds) {
|
|
3927
|
+
target.pointSourceIds[targetPointIndex] = point.pointSourceId;
|
|
3928
|
+
}
|
|
3929
|
+
if (target.returnNumbers) {
|
|
3930
|
+
target.returnNumbers[targetPointIndex] = point.bitByte & 0x07;
|
|
3931
|
+
}
|
|
3932
|
+
if (target.numberOfReturns) {
|
|
3933
|
+
target.numberOfReturns[targetPointIndex] = (point.bitByte >> 3) & 0x07;
|
|
3934
|
+
}
|
|
3935
|
+
if (target.scannerChannels) {
|
|
3936
|
+
target.scannerChannels[targetPointIndex] = 0;
|
|
3937
|
+
}
|
|
3938
|
+
if (target.scanDirectionFlags) {
|
|
3939
|
+
target.scanDirectionFlags[targetPointIndex] = (point.bitByte >> 6) & 1;
|
|
3940
|
+
}
|
|
3941
|
+
if (target.edgeOfFlightLines) {
|
|
3942
|
+
target.edgeOfFlightLines[targetPointIndex] = (point.bitByte >> 7) & 1;
|
|
3943
|
+
}
|
|
3944
|
+
}
|
|
3945
|
+
function getPoint10ReturnNumber(point) {
|
|
3946
|
+
return point.bitByte & 0x07;
|
|
3947
|
+
}
|
|
3948
|
+
function getPoint10NumberOfReturns(point) {
|
|
3949
|
+
return (point.bitByte >> 3) & 0x07;
|
|
3950
|
+
}
|
|
3951
|
+
function getPoint10ScanDirectionFlag(point) {
|
|
3952
|
+
return (point.bitByte >> 6) & 1;
|
|
3953
|
+
}
|
|
3954
|
+
function copyPoint14(target, source) {
|
|
3955
|
+
target.x = source.x;
|
|
3956
|
+
target.y = source.y;
|
|
3957
|
+
target.z = source.z;
|
|
3958
|
+
target.intensity = source.intensity;
|
|
3959
|
+
target.returns = source.returns;
|
|
3960
|
+
target.flags = source.flags;
|
|
3961
|
+
target.classification = source.classification;
|
|
3962
|
+
target.userData = source.userData;
|
|
3963
|
+
target.scanAngle = source.scanAngle;
|
|
3964
|
+
target.pointSourceId = source.pointSourceId;
|
|
3965
|
+
target.gpsTime = source.gpsTime;
|
|
3966
|
+
}
|
|
3967
|
+
function readPoint14Into(point, bytes, offset) {
|
|
3968
|
+
point.x = readInt32(bytes, offset);
|
|
3969
|
+
point.y = readInt32(bytes, offset + 4);
|
|
3970
|
+
point.z = readInt32(bytes, offset + 8);
|
|
3971
|
+
point.intensity = readUint16(bytes, offset + 12);
|
|
3972
|
+
point.returns = bytes[offset + 14];
|
|
3973
|
+
point.flags = bytes[offset + 15];
|
|
3974
|
+
point.classification = bytes[offset + 16];
|
|
3975
|
+
point.userData = bytes[offset + 17];
|
|
3976
|
+
point.scanAngle = readInt16(bytes, offset + 18);
|
|
3977
|
+
point.pointSourceId = readUint16(bytes, offset + 20);
|
|
3978
|
+
point.gpsTime = readFloat64(bytes, offset + 22);
|
|
3979
|
+
}
|
|
3980
|
+
function readPoint14FromStreamInto(point, stream) {
|
|
3981
|
+
point.x = readInt32FromStream(stream);
|
|
3982
|
+
point.y = readInt32FromStream(stream);
|
|
3983
|
+
point.z = readInt32FromStream(stream);
|
|
3984
|
+
point.intensity = readUint16FromStream(stream);
|
|
3985
|
+
point.returns = stream.getByte();
|
|
3986
|
+
point.flags = stream.getByte();
|
|
3987
|
+
point.classification = stream.getByte();
|
|
3988
|
+
point.userData = stream.getByte();
|
|
3989
|
+
point.scanAngle = toInt16(readUint16FromStream(stream));
|
|
3990
|
+
point.pointSourceId = readUint16FromStream(stream);
|
|
3991
|
+
point.gpsTime = readFloat64FromStream(stream);
|
|
3992
|
+
}
|
|
3993
|
+
function writePoint14(point, bytes, offset) {
|
|
3994
|
+
writeInt32(point.x, bytes, offset);
|
|
3995
|
+
writeInt32(point.y, bytes, offset + 4);
|
|
3996
|
+
writeInt32(point.z, bytes, offset + 8);
|
|
3997
|
+
writeUint16(point.intensity, bytes, offset + 12);
|
|
3998
|
+
bytes[offset + 14] = point.returns;
|
|
3999
|
+
bytes[offset + 15] = point.flags;
|
|
4000
|
+
bytes[offset + 16] = point.classification;
|
|
4001
|
+
bytes[offset + 17] = point.userData;
|
|
4002
|
+
writeInt16(point.scanAngle, bytes, offset + 18);
|
|
4003
|
+
writeUint16(point.pointSourceId, bytes, offset + 20);
|
|
4004
|
+
writeFloat64(point.gpsTime, bytes, offset + 22);
|
|
4005
|
+
}
|
|
4006
|
+
function writePoint14ToPointDataTarget(point, target, targetPointIndex) {
|
|
4007
|
+
writePoint14ToPointDataArrays(point, target.positions, target.intensities, target.classifications, target.scale, target.offset, targetPointIndex);
|
|
4008
|
+
writeGpsTimeToPointDataTarget(point, target, targetPointIndex);
|
|
4009
|
+
writePoint14MetadataToPointDataTarget(point, target, targetPointIndex);
|
|
4010
|
+
}
|
|
4011
|
+
function writePoint14ToPointDataArrays(point, positions, intensities, classifications, scale, offset, targetPointIndex) {
|
|
4012
|
+
const positionOffset = targetPointIndex * 3;
|
|
4013
|
+
positions[positionOffset] = point.x * scale[0] + offset[0];
|
|
4014
|
+
positions[positionOffset + 1] = point.y * scale[1] + offset[1];
|
|
4015
|
+
positions[positionOffset + 2] = point.z * scale[2] + offset[2];
|
|
4016
|
+
if (intensities) {
|
|
4017
|
+
intensities[targetPointIndex] = point.intensity;
|
|
4018
|
+
}
|
|
4019
|
+
if (classifications) {
|
|
4020
|
+
classifications[targetPointIndex] = point.classification;
|
|
4021
|
+
}
|
|
4022
|
+
}
|
|
4023
|
+
function writeGpsTimeToPointDataTarget(point, target, targetPointIndex) {
|
|
4024
|
+
if (target.gpsTimes) {
|
|
4025
|
+
target.gpsTimes[targetPointIndex] = point.gpsTime;
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
function writePoint14MetadataToPointDataTarget(point, target, targetPointIndex) {
|
|
4029
|
+
if (target.scanAngles) {
|
|
4030
|
+
target.scanAngles[targetPointIndex] = point.scanAngle;
|
|
4031
|
+
}
|
|
4032
|
+
if (target.userData) {
|
|
4033
|
+
target.userData[targetPointIndex] = point.userData;
|
|
4034
|
+
}
|
|
4035
|
+
if (target.pointSourceIds) {
|
|
4036
|
+
target.pointSourceIds[targetPointIndex] = point.pointSourceId;
|
|
4037
|
+
}
|
|
4038
|
+
if (target.returnNumbers) {
|
|
4039
|
+
target.returnNumbers[targetPointIndex] = point.returns & 0x0f;
|
|
4040
|
+
}
|
|
4041
|
+
if (target.numberOfReturns) {
|
|
4042
|
+
target.numberOfReturns[targetPointIndex] = point.returns >> 4;
|
|
4043
|
+
}
|
|
4044
|
+
if (target.scannerChannels) {
|
|
4045
|
+
target.scannerChannels[targetPointIndex] = (point.flags >> 4) & 0x03;
|
|
4046
|
+
}
|
|
4047
|
+
if (target.scanDirectionFlags) {
|
|
4048
|
+
target.scanDirectionFlags[targetPointIndex] = (point.flags >> 6) & 1;
|
|
4049
|
+
}
|
|
4050
|
+
if (target.edgeOfFlightLines) {
|
|
4051
|
+
target.edgeOfFlightLines[targetPointIndex] = (point.flags >> 7) & 1;
|
|
4052
|
+
}
|
|
4053
|
+
if (target.syntheticFlags) {
|
|
4054
|
+
target.syntheticFlags[targetPointIndex] = point.flags & 1;
|
|
4055
|
+
}
|
|
4056
|
+
if (target.keyPointFlags) {
|
|
4057
|
+
target.keyPointFlags[targetPointIndex] = (point.flags >> 1) & 1;
|
|
4058
|
+
}
|
|
4059
|
+
if (target.withheldFlags) {
|
|
4060
|
+
target.withheldFlags[targetPointIndex] = (point.flags >> 2) & 1;
|
|
4061
|
+
}
|
|
4062
|
+
if (target.overlapFlags) {
|
|
4063
|
+
target.overlapFlags[targetPointIndex] = (point.flags >> 3) & 1;
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4066
|
+
function writeNirToPointDataTarget(value, target, targetPointIndex) {
|
|
4067
|
+
if (target.nir) {
|
|
4068
|
+
target.nir[targetPointIndex] = value;
|
|
4069
|
+
}
|
|
4070
|
+
}
|
|
4071
|
+
function writeRgbToPointDataTarget(red, green, blue, target, targetPointIndex) {
|
|
4072
|
+
if (target.colors) {
|
|
4073
|
+
const colorOffset = targetPointIndex * 4;
|
|
4074
|
+
target.colors[colorOffset] = red & 0xff;
|
|
4075
|
+
target.colors[colorOffset + 1] = green & 0xff;
|
|
4076
|
+
target.colors[colorOffset + 2] = blue & 0xff;
|
|
4077
|
+
target.colors[colorOffset + 3] = 255;
|
|
4078
|
+
return;
|
|
4079
|
+
}
|
|
4080
|
+
if (!target.rawColors) {
|
|
4081
|
+
return;
|
|
4082
|
+
}
|
|
4083
|
+
const colorOffset = targetPointIndex * 3;
|
|
4084
|
+
target.rawColors[colorOffset] = red;
|
|
4085
|
+
target.rawColors[colorOffset + 1] = green;
|
|
4086
|
+
target.rawColors[colorOffset + 2] = blue;
|
|
4087
|
+
}
|
|
4088
|
+
function getScannerChannel(point) {
|
|
4089
|
+
return (point.flags >> 4) & 0x03;
|
|
4090
|
+
}
|
|
4091
|
+
function setScannerChannel(point, scannerChannel) {
|
|
4092
|
+
point.flags = ((scannerChannel & 0x03) << 4) | (point.flags & ~0x30);
|
|
4093
|
+
}
|
|
4094
|
+
function setClassFlags(point, flags) {
|
|
4095
|
+
point.flags = (flags & 0x0f) | (point.flags & 0xf0);
|
|
4096
|
+
}
|
|
4097
|
+
function setScanDirectionFlag(point, flag) {
|
|
4098
|
+
point.flags = ((flag & 1) << 6) | (point.flags & 0xbf);
|
|
4099
|
+
}
|
|
4100
|
+
function setEdgeOfFlightLine(point, flag) {
|
|
4101
|
+
point.flags = ((flag & 1) << 7) | (point.flags & 0x7f);
|
|
4102
|
+
}
|
|
4103
|
+
function mergeFlags(point) {
|
|
4104
|
+
return (point.flags & 0x0f) | (((point.flags >> 6) & 1) << 4) | (((point.flags >> 7) & 1) << 5);
|
|
4105
|
+
}
|
|
4106
|
+
function readUint16(bytes, offset) {
|
|
4107
|
+
return bytes[offset] | (bytes[offset + 1] << 8);
|
|
4108
|
+
}
|
|
4109
|
+
/** Read an unaligned little-endian unsigned 16-bit integer without allocating a DataView. */
|
|
4110
|
+
function readUint16FromStream(stream) {
|
|
4111
|
+
const b0 = stream.getByte();
|
|
4112
|
+
const b1 = stream.getByte();
|
|
4113
|
+
return b0 | (b1 << 8);
|
|
4114
|
+
}
|
|
4115
|
+
function writeUint16(value, bytes, offset) {
|
|
4116
|
+
bytes[offset] = value & 0xff;
|
|
4117
|
+
bytes[offset + 1] = (value >> 8) & 0xff;
|
|
4118
|
+
}
|
|
4119
|
+
function readInt16(bytes, offset) {
|
|
4120
|
+
return toInt16(readUint16(bytes, offset));
|
|
4121
|
+
}
|
|
4122
|
+
function writeInt16(value, bytes, offset) {
|
|
4123
|
+
writeUint16(value, bytes, offset);
|
|
4124
|
+
}
|
|
4125
|
+
/** Read an unaligned little-endian unsigned 32-bit integer. */
|
|
4126
|
+
function readUint32(bytes, offset) {
|
|
4127
|
+
return ((bytes[offset] |
|
|
4128
|
+
(bytes[offset + 1] << 8) |
|
|
4129
|
+
(bytes[offset + 2] << 16) |
|
|
4130
|
+
((bytes[offset + 3] << 24) >>> 0)) >>>
|
|
4131
|
+
0);
|
|
4132
|
+
}
|
|
4133
|
+
/** Write an unaligned little-endian unsigned 32-bit integer. */
|
|
4134
|
+
function writeUint32(value, bytes, offset) {
|
|
4135
|
+
writeInt32(value, bytes, offset);
|
|
4136
|
+
}
|
|
4137
|
+
/** Read an unaligned little-endian unsigned 64-bit integer without precision loss. */
|
|
4138
|
+
function readBigUint64(bytes, offset) {
|
|
4139
|
+
const lower = readUint32(bytes, offset);
|
|
4140
|
+
const upper = readUint32(bytes, offset + 4);
|
|
4141
|
+
return (BigInt(upper) << 32n) | BigInt(lower);
|
|
4142
|
+
}
|
|
4143
|
+
/** Write an unaligned little-endian unsigned 64-bit integer without precision loss. */
|
|
4144
|
+
function writeBigUint64(value, bytes, offset) {
|
|
4145
|
+
writeUint32(Number(value & 0xffffffffn), bytes, offset);
|
|
4146
|
+
writeUint32(Number((value >> 32n) & 0xffffffffn), bytes, offset + 4);
|
|
4147
|
+
}
|
|
4148
|
+
function readInt32(bytes, offset) {
|
|
4149
|
+
return (bytes[offset] | (bytes[offset + 1] << 8) | (bytes[offset + 2] << 16) | (bytes[offset + 3] << 24));
|
|
4150
|
+
}
|
|
4151
|
+
/** Read an unaligned little-endian signed 32-bit integer without allocating a DataView. */
|
|
4152
|
+
function readInt32FromStream(stream) {
|
|
4153
|
+
const b0 = stream.getByte();
|
|
4154
|
+
const b1 = stream.getByte();
|
|
4155
|
+
const b2 = stream.getByte();
|
|
4156
|
+
const b3 = stream.getByte();
|
|
4157
|
+
return b0 | (b1 << 8) | (b2 << 16) | (b3 << 24);
|
|
4158
|
+
}
|
|
4159
|
+
function writeInt32(value, bytes, offset) {
|
|
4160
|
+
bytes[offset] = value & 0xff;
|
|
4161
|
+
bytes[offset + 1] = (value >> 8) & 0xff;
|
|
4162
|
+
bytes[offset + 2] = (value >> 16) & 0xff;
|
|
4163
|
+
bytes[offset + 3] = (value >> 24) & 0xff;
|
|
4164
|
+
}
|
|
4165
|
+
function readFloat64(bytes, offset) {
|
|
4166
|
+
for (let index = 0; index < 8; index++) {
|
|
4167
|
+
FLOAT64_SCRATCH_BYTES[index] = bytes[offset + index];
|
|
4168
|
+
}
|
|
4169
|
+
return FLOAT64_SCRATCH_VIEW.getFloat64(0, true);
|
|
4170
|
+
}
|
|
4171
|
+
/** Read an unaligned little-endian float64 through the shared aligned scratch view. */
|
|
4172
|
+
function readFloat64FromStream(stream) {
|
|
4173
|
+
for (let index = 0; index < 8; index++) {
|
|
4174
|
+
FLOAT64_SCRATCH_BYTES[index] = stream.getByte();
|
|
4175
|
+
}
|
|
4176
|
+
return FLOAT64_SCRATCH_VIEW.getFloat64(0, true);
|
|
4177
|
+
}
|
|
4178
|
+
function writeFloat64(value, bytes, offset) {
|
|
4179
|
+
FLOAT64_SCRATCH_VIEW.setFloat64(0, value, true);
|
|
4180
|
+
for (let index = 0; index < 8; index++) {
|
|
4181
|
+
bytes[offset + index] = FLOAT64_SCRATCH_BYTES[index];
|
|
4182
|
+
}
|
|
4183
|
+
}
|
|
4184
|
+
function clampUint8(value) {
|
|
4185
|
+
return value <= 0 ? 0 : value >= 255 ? 255 : value;
|
|
4186
|
+
}
|
|
4187
|
+
function toInt16(value) {
|
|
4188
|
+
const uint16 = value & 0xffff;
|
|
4189
|
+
return uint16 & 0x8000 ? uint16 - 0x10000 : uint16;
|
|
4190
|
+
}
|
|
4191
|
+
function toInt8(value) {
|
|
4192
|
+
const uint8 = value & 0xff;
|
|
4193
|
+
return uint8 & 0x80 ? uint8 - 0x100 : uint8;
|
|
4194
|
+
}
|
|
4195
|
+
function toInt32(value) {
|
|
4196
|
+
return value | 0;
|
|
4197
|
+
}
|
|
4198
|
+
function float64ToBigUint64(value) {
|
|
4199
|
+
FLOAT64_SCRATCH_VIEW.setFloat64(0, value, true);
|
|
4200
|
+
return FLOAT64_SCRATCH_VIEW.getBigUint64(0, true);
|
|
4201
|
+
}
|
|
4202
|
+
function bigUint64ToFloat64(value) {
|
|
4203
|
+
FLOAT64_SCRATCH_VIEW.setBigUint64(0, value, true);
|
|
4204
|
+
return FLOAT64_SCRATCH_VIEW.getFloat64(0, true);
|
|
4205
|
+
}
|
|
4206
|
+
function addInt32ToFloat64Bits(value, diff) {
|
|
4207
|
+
const bits = BigInt.asIntN(64, BigInt.asIntN(64, float64ToBigUint64(value)) + BigInt(diff));
|
|
4208
|
+
return bigUint64ToFloat64(BigInt.asUintN(64, bits));
|
|
4209
|
+
}
|
|
4210
|
+
function toUint8Array(arrayBuffer) {
|
|
4211
|
+
if (arrayBuffer instanceof ArrayBuffer) {
|
|
4212
|
+
return new Uint8Array(arrayBuffer);
|
|
4213
|
+
}
|
|
4214
|
+
return new Uint8Array(arrayBuffer.buffer, arrayBuffer.byteOffset, arrayBuffer.byteLength);
|
|
4215
|
+
}
|
|
4216
|
+
function concatenateUint8Arrays(chunks) {
|
|
4217
|
+
const byteLength = chunks.reduce((total, chunk) => total + chunk.byteLength, 0);
|
|
4218
|
+
const result = new Uint8Array(byteLength);
|
|
4219
|
+
let offset = 0;
|
|
4220
|
+
for (const chunk of chunks) {
|
|
4221
|
+
result.set(chunk, offset);
|
|
4222
|
+
offset += chunk.byteLength;
|
|
4223
|
+
}
|
|
4224
|
+
return result;
|
|
4225
|
+
}
|
|
4226
|
+
//# sourceMappingURL=laz-chunk-decoder.js.map
|