@loaders.gl/lerc 4.0.0-beta.7
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 +41 -0
- package/README.md +5 -0
- package/dist/index.cjs +58 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/lerc-loader.js +21 -0
- package/dist/lerc-loader.js.map +1 -0
- package/dist/lib/parsers/lerc/lerc-types.js +2 -0
- package/dist/lib/parsers/lerc/lerc-types.js.map +1 -0
- package/dist/workers/lerc-worker.js +4 -0
- package/dist/workers/lerc-worker.js.map +1 -0
- package/package.json +47 -0
- package/src/index.ts +5 -0
- package/src/lerc-loader.ts +48 -0
- package/src/lib/parsers/lerc/lerc-types.ts +43 -0
- package/src/workers/lerc-worker.ts +6 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Copyright (c) 2015 Uber Technologies, Inc.
|
|
2
|
+
|
|
3
|
+
This software includes parts of PhiloGL (https://github.com/philogb/philogl)
|
|
4
|
+
under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs.
|
|
5
|
+
|
|
6
|
+
This software includes adaptations of postprocessing code from THREE.js (https://github.com/mrdoob/three.js/) under MIT license. Additional attribution given in specific source files. THREE.js parts Copyright © 2010-2018 three.js authors.
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
|
16
|
+
all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
loaders.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium) under the Apache 2 License:
|
|
28
|
+
|
|
29
|
+
Copyright 2011-2018 CesiumJS Contributors
|
|
30
|
+
|
|
31
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
32
|
+
you may not use this file except in compliance with the License.
|
|
33
|
+
You may obtain a copy of the License at
|
|
34
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
35
|
+
|
|
36
|
+
Unless required by applicable law or agreed to in writing, software
|
|
37
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
38
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
39
|
+
See the License for the specific language governing permissions and limitations under the License.
|
|
40
|
+
|
|
41
|
+
Cesium-derived code can be found in the submodule: modules/3d-tiles
|
package/README.md
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
LERCLoader: () => LERCLoader
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
|
|
37
|
+
// src/lerc-loader.ts
|
|
38
|
+
var Lerc = __toESM(require("lerc"), 1);
|
|
39
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
40
|
+
var LERCLoader = {
|
|
41
|
+
id: "lerc",
|
|
42
|
+
name: "LERC",
|
|
43
|
+
module: "wms",
|
|
44
|
+
version: VERSION,
|
|
45
|
+
worker: false,
|
|
46
|
+
extensions: ["lrc", "lerc", "lerc2", "lerc1"],
|
|
47
|
+
mimeTypes: ["application/octet-stream"],
|
|
48
|
+
// test: ?,
|
|
49
|
+
options: {
|
|
50
|
+
wms: {}
|
|
51
|
+
},
|
|
52
|
+
parse: async (arrayBuffer, options) => parseLERC(arrayBuffer, options)
|
|
53
|
+
};
|
|
54
|
+
async function parseLERC(arrayBuffer, options) {
|
|
55
|
+
await Lerc.load();
|
|
56
|
+
const pixelBlock = Lerc.decode(arrayBuffer, options == null ? void 0 : options.lerc);
|
|
57
|
+
return pixelBlock;
|
|
58
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["LERCLoader"],"sources":["../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n// LERC - Limited Error Raster Compression\nexport type {LERCData} from './lib/parsers/lerc/lerc-types';\nexport {LERCLoader} from './lerc-loader';\n"],"mappings":"SAIQA,UAAU"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as Lerc from 'lerc';
|
|
2
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
3
|
+
export const LERCLoader = {
|
|
4
|
+
id: 'lerc',
|
|
5
|
+
name: 'LERC',
|
|
6
|
+
module: 'wms',
|
|
7
|
+
version: VERSION,
|
|
8
|
+
worker: false,
|
|
9
|
+
extensions: ['lrc', 'lerc', 'lerc2', 'lerc1'],
|
|
10
|
+
mimeTypes: ['application/octet-stream'],
|
|
11
|
+
options: {
|
|
12
|
+
wms: {}
|
|
13
|
+
},
|
|
14
|
+
parse: async (arrayBuffer, options) => parseLERC(arrayBuffer, options)
|
|
15
|
+
};
|
|
16
|
+
async function parseLERC(arrayBuffer, options) {
|
|
17
|
+
await Lerc.load();
|
|
18
|
+
const pixelBlock = Lerc.decode(arrayBuffer, options === null || options === void 0 ? void 0 : options.lerc);
|
|
19
|
+
return pixelBlock;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=lerc-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lerc-loader.js","names":["Lerc","VERSION","__VERSION__","LERCLoader","id","name","module","version","worker","extensions","mimeTypes","options","wms","parse","arrayBuffer","parseLERC","load","pixelBlock","decode","lerc"],"sources":["../src/lerc-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {LERCData} from './lib/parsers/lerc/lerc-types';\nimport * as Lerc from 'lerc';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type LERCLoaderOptions = LoaderOptions & {\n lerc?: {\n /**\tThe number of bytes to skip in the input byte stream. A valid Lerc file is expected at that position. */\n inputOffset?: number;\n /**\tIt is recommended to use the returned mask instead of setting this value. */\n noDataValue?: number;\n /**\t(ndepth LERC2 only) If true, returned depth values are pixel-interleaved. */\n returnInterleaved?: boolean;\n };\n};\n\n/**\n * Loader for the LERC raster format\n */\nexport const LERCLoader: LoaderWithParser<LERCData, never, LERCLoaderOptions> = {\n id: 'lerc',\n name: 'LERC',\n\n module: 'wms',\n version: VERSION,\n worker: false,\n extensions: ['lrc', 'lerc', 'lerc2', 'lerc1'],\n mimeTypes: ['application/octet-stream'],\n // test: ?,\n options: {\n wms: {}\n },\n parse: async (arrayBuffer: ArrayBuffer, options?: LERCLoaderOptions) =>\n parseLERC(arrayBuffer, options)\n};\n\nasync function parseLERC(arrayBuffer: ArrayBuffer, options?: LERCLoaderOptions): Promise<LERCData> {\n // Load the WASM library\n await Lerc.load();\n // Perform the decode\n const pixelBlock = Lerc.decode(arrayBuffer, options?.lerc);\n return pixelBlock;\n}\n"],"mappings":"AAIA,OAAO,KAAKA,IAAI,MAAM,MAAM;AAI5B,MAAMC,OAAO,GAAG,OAAOC,WAAW,KAAK,WAAW,GAAGA,WAAW,GAAG,QAAQ;AAgB3E,OAAO,MAAMC,UAAgE,GAAG;EAC9EC,EAAE,EAAE,MAAM;EACVC,IAAI,EAAE,MAAM;EAEZC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEN,OAAO;EAChBO,MAAM,EAAE,KAAK;EACbC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC;EAC7CC,SAAS,EAAE,CAAC,0BAA0B,CAAC;EAEvCC,OAAO,EAAE;IACPC,GAAG,EAAE,CAAC;EACR,CAAC;EACDC,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAEH,OAA2B,KACjEI,SAAS,CAACD,WAAW,EAAEH,OAAO;AAClC,CAAC;AAED,eAAeI,SAASA,CAACD,WAAwB,EAAEH,OAA2B,EAAqB;EAEjG,MAAMX,IAAI,CAACgB,IAAI,CAAC,CAAC;EAEjB,MAAMC,UAAU,GAAGjB,IAAI,CAACkB,MAAM,CAACJ,WAAW,EAAEH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEQ,IAAI,CAAC;EAC1D,OAAOF,UAAU;AACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lerc-types.js","names":[],"sources":["../../../../src/lib/parsers/lerc/lerc-types.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n/** Data returned by LERC loader */\nexport type LERCData = {\n /**\tWidth of decoded image */\n width: number;\n /**\tHeight of decoded image */\n height: number;\n /**\tThe type of pixels represented in the output */\n pixelType: LercPixelType;\n /**\t[statistics_band1, statistics_band2, …] Each element is a statistics object representing min and max values */\n statistics: BandStats[];\n /**\t[band1, band2, …] Each band is a typed array of width * height * depthCount */\n pixels: TypedArray[];\n /**\tTyped array with a size of width*height, or null if all pixels are valid */\n mask: Uint8Array;\n /**\tDepth count */\n depthCount: number;\n /**\tarray\t[band1_mask, band2_mask, …] Each band is a Uint8Array of width * height * depthCount */\n bandMasks?: Uint8Array[];\n};\n\nexport type LercPixelType = 'S8' | 'U8' | 'S16' | 'U16' | 'S32' | 'U32' | 'F32' | 'F64';\n\nexport interface BandStats {\n minValue: number;\n maxValue: number;\n depthStats?: {\n minValues: Float64Array;\n maxValues: Float64Array;\n };\n}\n\nexport type TypedArray =\n | Int8Array\n | Uint8Array\n | Uint8ClampedArray\n | Int16Array\n | Uint16Array\n | Int32Array\n | Uint32Array\n | Float32Array\n | Float64Array;\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lerc-worker.js","names":["createLoaderWorker","LERCLoader"],"sources":["../../src/workers/lerc-worker.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport {LERCLoader} from '../lerc-loader';\n\ncreateLoaderWorker(LERCLoader);\n"],"mappings":"AAEA,SAAQA,kBAAkB,QAAO,0BAA0B;AAAC,SACpDC,UAAU;AAElBD,kBAAkB,CAACC,UAAU,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@loaders.gl/lerc",
|
|
3
|
+
"version": "4.0.0-beta.7",
|
|
4
|
+
"description": "Framework-independent loader for LERC (Limited Error Raster Compression) files",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/visgl/loaders.gl"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"webgl",
|
|
16
|
+
"loader",
|
|
17
|
+
"parser",
|
|
18
|
+
"LERC"
|
|
19
|
+
],
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
|
+
"main": "dist/index.cjs",
|
|
22
|
+
"module": "dist/index.js",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"import": "./dist/index.js",
|
|
26
|
+
"require": "./dist/index.cjs",
|
|
27
|
+
"types": "./dist/index.d.ts"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"files": [
|
|
32
|
+
"src",
|
|
33
|
+
"dist",
|
|
34
|
+
"README.md"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"pre-build": "npm run build-bundle && npm run build-bundle -- --env=dev && npm run build-worker",
|
|
38
|
+
"build-bundle": "# ocular-bundle ./src/index.ts",
|
|
39
|
+
"build-worker": "# esbuild src/workers/lerc-worker.ts --bundle --outfile=dist/lerc-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@loaders.gl/loader-utils": "4.0.0-beta.7",
|
|
43
|
+
"@loaders.gl/schema": "4.0.0-beta.7",
|
|
44
|
+
"lerc": "^4.0.1"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "5b6cab0ab5d73212cfa37fa5da6e25ad7ef83fe5"
|
|
47
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
4
|
+
import type {LERCData} from './lib/parsers/lerc/lerc-types';
|
|
5
|
+
import * as Lerc from 'lerc';
|
|
6
|
+
|
|
7
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
8
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
9
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
10
|
+
|
|
11
|
+
export type LERCLoaderOptions = LoaderOptions & {
|
|
12
|
+
lerc?: {
|
|
13
|
+
/** The number of bytes to skip in the input byte stream. A valid Lerc file is expected at that position. */
|
|
14
|
+
inputOffset?: number;
|
|
15
|
+
/** It is recommended to use the returned mask instead of setting this value. */
|
|
16
|
+
noDataValue?: number;
|
|
17
|
+
/** (ndepth LERC2 only) If true, returned depth values are pixel-interleaved. */
|
|
18
|
+
returnInterleaved?: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Loader for the LERC raster format
|
|
24
|
+
*/
|
|
25
|
+
export const LERCLoader: LoaderWithParser<LERCData, never, LERCLoaderOptions> = {
|
|
26
|
+
id: 'lerc',
|
|
27
|
+
name: 'LERC',
|
|
28
|
+
|
|
29
|
+
module: 'wms',
|
|
30
|
+
version: VERSION,
|
|
31
|
+
worker: false,
|
|
32
|
+
extensions: ['lrc', 'lerc', 'lerc2', 'lerc1'],
|
|
33
|
+
mimeTypes: ['application/octet-stream'],
|
|
34
|
+
// test: ?,
|
|
35
|
+
options: {
|
|
36
|
+
wms: {}
|
|
37
|
+
},
|
|
38
|
+
parse: async (arrayBuffer: ArrayBuffer, options?: LERCLoaderOptions) =>
|
|
39
|
+
parseLERC(arrayBuffer, options)
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
async function parseLERC(arrayBuffer: ArrayBuffer, options?: LERCLoaderOptions): Promise<LERCData> {
|
|
43
|
+
// Load the WASM library
|
|
44
|
+
await Lerc.load();
|
|
45
|
+
// Perform the decode
|
|
46
|
+
const pixelBlock = Lerc.decode(arrayBuffer, options?.lerc);
|
|
47
|
+
return pixelBlock;
|
|
48
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// loaders.gl, MIT license
|
|
2
|
+
|
|
3
|
+
/** Data returned by LERC loader */
|
|
4
|
+
export type LERCData = {
|
|
5
|
+
/** Width of decoded image */
|
|
6
|
+
width: number;
|
|
7
|
+
/** Height of decoded image */
|
|
8
|
+
height: number;
|
|
9
|
+
/** The type of pixels represented in the output */
|
|
10
|
+
pixelType: LercPixelType;
|
|
11
|
+
/** [statistics_band1, statistics_band2, …] Each element is a statistics object representing min and max values */
|
|
12
|
+
statistics: BandStats[];
|
|
13
|
+
/** [band1, band2, …] Each band is a typed array of width * height * depthCount */
|
|
14
|
+
pixels: TypedArray[];
|
|
15
|
+
/** Typed array with a size of width*height, or null if all pixels are valid */
|
|
16
|
+
mask: Uint8Array;
|
|
17
|
+
/** Depth count */
|
|
18
|
+
depthCount: number;
|
|
19
|
+
/** array [band1_mask, band2_mask, …] Each band is a Uint8Array of width * height * depthCount */
|
|
20
|
+
bandMasks?: Uint8Array[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type LercPixelType = 'S8' | 'U8' | 'S16' | 'U16' | 'S32' | 'U32' | 'F32' | 'F64';
|
|
24
|
+
|
|
25
|
+
export interface BandStats {
|
|
26
|
+
minValue: number;
|
|
27
|
+
maxValue: number;
|
|
28
|
+
depthStats?: {
|
|
29
|
+
minValues: Float64Array;
|
|
30
|
+
maxValues: Float64Array;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type TypedArray =
|
|
35
|
+
| Int8Array
|
|
36
|
+
| Uint8Array
|
|
37
|
+
| Uint8ClampedArray
|
|
38
|
+
| Int16Array
|
|
39
|
+
| Uint16Array
|
|
40
|
+
| Int32Array
|
|
41
|
+
| Uint32Array
|
|
42
|
+
| Float32Array
|
|
43
|
+
| Float64Array;
|