@gisatcz/deckgl-geolib 0.0.3 → 1.2.0
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/.eslintignore +2 -0
- package/.eslintrc.cjs +3 -0
- package/dist/cjs/index.js +99799 -18
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +5 -0
- package/dist/cjs/index.min.js.map +1 -0
- package/dist/cjs/types/cogbitmaplayer/CogBitmapLayer.d.ts +16 -0
- package/dist/cjs/types/cogterrainlayer/CogTerrainLayer.d.ts +18 -0
- package/dist/cjs/types/cogtiles/cogtiles.d.ts +29 -0
- package/dist/cjs/types/geoimage/geoimage.d.ts +49 -0
- package/dist/cjs/types/index.d.ts +11 -2
- package/dist/cjs/types/utilities/tileurls.d.ts +4 -0
- package/dist/esm/index.js +99797 -18
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +5 -0
- package/dist/esm/index.min.js.map +1 -0
- package/dist/esm/types/cogbitmaplayer/CogBitmapLayer.d.ts +16 -0
- package/dist/esm/types/cogterrainlayer/CogTerrainLayer.d.ts +18 -0
- package/dist/esm/types/cogtiles/cogtiles.d.ts +29 -0
- package/dist/esm/types/geoimage/geoimage.d.ts +49 -0
- package/dist/esm/types/index.d.ts +11 -2
- package/dist/esm/types/utilities/tileurls.d.ts +4 -0
- package/package.json +42 -36
- package/rollup.config.mjs +70 -0
- package/src/cogbitmaplayer/CogBitmapLayer.ts +104 -0
- package/src/cogbitmaplayer/README.md +52 -0
- package/src/cogterrainlayer/CogTerrainLayer.ts +174 -0
- package/src/cogterrainlayer/README.md +41 -0
- package/src/cogtiles/README.md +72 -0
- package/src/cogtiles/cogtiles.ts +355 -0
- package/src/cogtiles/lzw.js +256 -0
- package/src/geoimage/README.md +110 -0
- package/src/geoimage/geoimage.ts +390 -0
- package/src/index.ts +11 -0
- package/src/utilities/tileurls.ts +21 -0
- package/tsconfig.json +3 -0
- package/README.md +0 -1
- package/dist/cjs/classes/geoImage/GeoImage.d.ts +0 -38
- package/dist/cjs/classes/geoImage/index.d.ts +0 -1
- package/dist/cjs/classes/geoImage/interface.d.ts +0 -32
- package/dist/cjs/classes/index.d.ts +0 -1
- package/dist/cjs/hooks/index.d.ts +0 -1
- package/dist/cjs/hooks/useGeoData/index.d.ts +0 -1
- package/dist/cjs/hooks/useGeoData/useGeoData.d.ts +0 -9
- package/dist/cjs/index.d.ts +0 -2
- package/dist/cjs/types/classes/geoImage/GeoImage.d.ts +0 -38
- package/dist/cjs/types/classes/geoImage/index.d.ts +0 -1
- package/dist/cjs/types/classes/geoImage/interface.d.ts +0 -32
- package/dist/cjs/types/classes/index.d.ts +0 -1
- package/dist/cjs/types/hooks/index.d.ts +0 -1
- package/dist/cjs/types/hooks/useGeoData/index.d.ts +0 -1
- package/dist/cjs/types/hooks/useGeoData/useGeoData.d.ts +0 -9
- package/dist/esm/classes/geoImage/GeoImage.d.ts +0 -38
- package/dist/esm/classes/geoImage/index.d.ts +0 -1
- package/dist/esm/classes/geoImage/interface.d.ts +0 -32
- package/dist/esm/classes/index.d.ts +0 -1
- package/dist/esm/hooks/index.d.ts +0 -1
- package/dist/esm/hooks/useGeoData/index.d.ts +0 -1
- package/dist/esm/hooks/useGeoData/useGeoData.d.ts +0 -9
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/types/classes/geoImage/GeoImage.d.ts +0 -38
- package/dist/esm/types/classes/geoImage/index.d.ts +0 -1
- package/dist/esm/types/classes/geoImage/interface.d.ts +0 -32
- package/dist/esm/types/classes/index.d.ts +0 -1
- package/dist/esm/types/hooks/index.d.ts +0 -1
- package/dist/esm/types/hooks/useGeoData/index.d.ts +0 -1
- package/dist/esm/types/hooks/useGeoData/useGeoData.d.ts +0 -9
- package/dist/index.d.ts +0 -80
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="deck.gl" />
|
|
2
|
+
/// <reference types="deck.gl" />
|
|
3
|
+
import { CompositeLayer } from '@deck.gl/core';
|
|
4
|
+
import { TileLayer } from '@deck.gl/geo-layers';
|
|
5
|
+
import { GeoImageOptions } from '../geoimage/geoimage';
|
|
6
|
+
declare class CogBitmapLayer extends CompositeLayer<any> {
|
|
7
|
+
static layerName: string;
|
|
8
|
+
id: string;
|
|
9
|
+
url: string;
|
|
10
|
+
static displayName: string;
|
|
11
|
+
constructor(id: string, url: string, options: GeoImageOptions);
|
|
12
|
+
initializeState(): void;
|
|
13
|
+
init(url: string): Promise<void>;
|
|
14
|
+
renderLayers(): TileLayer<unknown, import("@deck.gl/geo-layers/tile-layer/tile-layer").TileLayerProps<unknown>>;
|
|
15
|
+
}
|
|
16
|
+
export default CogBitmapLayer;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="deck.gl" />
|
|
2
|
+
/// <reference types="deck.gl" />
|
|
3
|
+
import { CompositeLayer } from '@deck.gl/core';
|
|
4
|
+
import { TileLayer } from '@deck.gl/geo-layers';
|
|
5
|
+
import { GeoImageOptions } from '../geoimage/geoimage';
|
|
6
|
+
declare class CogTerrainLayer extends CompositeLayer<any> {
|
|
7
|
+
static layerName: string;
|
|
8
|
+
bitmapUrl: string;
|
|
9
|
+
urlType: 'none' | 'tile' | 'cog';
|
|
10
|
+
id: string;
|
|
11
|
+
terrainUrl: string;
|
|
12
|
+
static displayName: string;
|
|
13
|
+
constructor(id: string, terrainUrl: string, terrainOptions: GeoImageOptions, bitmapUrl?: string, bitmapOptions?: GeoImageOptions);
|
|
14
|
+
initializeState(): void;
|
|
15
|
+
init(terrainUrl: string): Promise<void>;
|
|
16
|
+
renderLayers(): TileLayer<unknown, import("@deck.gl/geo-layers/tile-layer/tile-layer").TileLayerProps<unknown>>[];
|
|
17
|
+
}
|
|
18
|
+
export default CogTerrainLayer;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CogTiff, CogTiffImage } from '@cogeotiff/core';
|
|
2
|
+
import LZWDecoder from './lzw';
|
|
3
|
+
import GeoImage, { GeoImageOptions } from '../geoimage/geoimage';
|
|
4
|
+
declare class CogTiles {
|
|
5
|
+
cog: CogTiff;
|
|
6
|
+
zoomRange: number[];
|
|
7
|
+
tileSize: number;
|
|
8
|
+
lowestOriginTileOffset: number[];
|
|
9
|
+
lowestOriginTileSize: number;
|
|
10
|
+
loaded: boolean;
|
|
11
|
+
geo: GeoImage;
|
|
12
|
+
lzw: LZWDecoder;
|
|
13
|
+
options: GeoImageOptions;
|
|
14
|
+
constructor(options: GeoImageOptions);
|
|
15
|
+
initializeCog(url: string): Promise<CogTiff>;
|
|
16
|
+
getTileSize(cog: CogTiff): number;
|
|
17
|
+
getZoomRange(cog: CogTiff): number[];
|
|
18
|
+
getBoundsAsLatLon(cog: CogTiff): [number, number, number, number];
|
|
19
|
+
getOriginAsLatLon(cog: CogTiff): number[];
|
|
20
|
+
getImageTileIndex(img: CogTiffImage): number[];
|
|
21
|
+
getResolutionFromZoomLevel(tileSize: number, z: number): number;
|
|
22
|
+
getZoomLevelFromResolution(tileSize: number, resolution: number): number;
|
|
23
|
+
getLatLon(input: number[]): number[];
|
|
24
|
+
getTile(x: number, y: number, z: number): Promise<string>;
|
|
25
|
+
getFormat(sampleFormat: number[] | number, bitsPerSample: number[] | number): any;
|
|
26
|
+
getNoDataValue(tags: any): number;
|
|
27
|
+
testCog(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export default CogTiles;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { GeoTIFFImage } from 'geotiff';
|
|
2
|
+
import chroma from 'chroma-js';
|
|
3
|
+
export type GeoImageOptions = {
|
|
4
|
+
type: 'image' | 'terrain';
|
|
5
|
+
format?: 'uint8' | 'uint16' | 'uint32' | 'int8' | 'int16' | 'int32' | 'float32' | 'float64';
|
|
6
|
+
useHeatMap?: boolean;
|
|
7
|
+
useColorsBasedOnValues?: boolean;
|
|
8
|
+
useAutoRange?: boolean;
|
|
9
|
+
useDataForOpacity?: boolean;
|
|
10
|
+
useChannel?: number | null;
|
|
11
|
+
useSingleColor?: boolean;
|
|
12
|
+
clipLow?: number | null;
|
|
13
|
+
clipHigh?: number | null;
|
|
14
|
+
multiplier?: number;
|
|
15
|
+
color?: Array<number> | chroma.Color;
|
|
16
|
+
colorScale?: Array<string> | Array<chroma.Color>;
|
|
17
|
+
colorScaleValueRange?: number[];
|
|
18
|
+
colorsBasedOnValues?: [number | undefined, chroma.Color][];
|
|
19
|
+
alpha?: number;
|
|
20
|
+
noDataValue?: number;
|
|
21
|
+
numOfChannels?: number;
|
|
22
|
+
nullColor?: Array<number> | chroma.Color;
|
|
23
|
+
unidentifiedColor?: Array<number> | chroma.Color;
|
|
24
|
+
clippedColor?: Array<number> | chroma.Color;
|
|
25
|
+
};
|
|
26
|
+
export default class GeoImage {
|
|
27
|
+
data: GeoTIFFImage | undefined;
|
|
28
|
+
scale: (num: number, inMin: number, inMax: number, outMin: number, outMax: number) => number;
|
|
29
|
+
setUrl(url: string): Promise<void>;
|
|
30
|
+
getMap(input: string | {
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
rasters: any[];
|
|
34
|
+
}, options: GeoImageOptions): Promise<any>;
|
|
35
|
+
getHeightmap(input: string | {
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
rasters: any[];
|
|
39
|
+
}, options: GeoImageOptions): Promise<any>;
|
|
40
|
+
getBitmap(input: string | {
|
|
41
|
+
width: number;
|
|
42
|
+
height: number;
|
|
43
|
+
rasters: any[];
|
|
44
|
+
}, options: GeoImageOptions): Promise<any>;
|
|
45
|
+
getMinMax(array: any, options: any): any[];
|
|
46
|
+
getColorValue(dataArray: [], options: GeoImageOptions, arrayLength: number, numOfChannels?: number): any[];
|
|
47
|
+
getDefaultColor(size: any, nullColor: any): any[];
|
|
48
|
+
getColorFromChromaType(colorDefinition: any): any[];
|
|
49
|
+
}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import CogBitmapLayer from './cogbitmaplayer/CogBitmapLayer';
|
|
2
|
+
import CogTerrainLayer from './cogterrainlayer/CogTerrainLayer';
|
|
3
|
+
import cogtiles from './cogtiles/cogtiles';
|
|
4
|
+
import GeoImage from './geoimage/geoimage';
|
|
5
|
+
declare const _default: {
|
|
6
|
+
CogBitmapLayer: typeof CogBitmapLayer;
|
|
7
|
+
CogTerrainLayer: typeof CogTerrainLayer;
|
|
8
|
+
cogtiles: typeof cogtiles;
|
|
9
|
+
GeoImage: typeof GeoImage;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,49 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gisatcz/deckgl-geolib",
|
|
3
|
-
"
|
|
4
|
-
"version": "0.0.3",
|
|
5
|
-
"description": "geoimage lib",
|
|
3
|
+
"version": "1.2.0",
|
|
6
4
|
"private": false,
|
|
5
|
+
"main": "dist/cjs/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
7
9
|
"scripts": {
|
|
8
10
|
"rollup": "rollup -c",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
"author": "Filip Micanek",
|
|
13
|
-
"license": "ISC",
|
|
14
|
-
"peerDependencies": {
|
|
15
|
-
"deck.gl": "^8.6.8",
|
|
16
|
-
"geotiff": "^2.0.4",
|
|
17
|
-
"react": "^16.13.1 || ^17.0.2 || ^18.1.0 ",
|
|
18
|
-
"react-dom": "^16.13.1 || ^17.0.2 || ^18.1.0 "
|
|
11
|
+
"start": "yarn && yarn rollup",
|
|
12
|
+
"lint": "eslint src/**/* -c ./.eslintrc.cjs",
|
|
13
|
+
"lintFix": "eslint src/**/* -c ./.eslintrc.cjs --fix"
|
|
19
14
|
},
|
|
20
15
|
"devDependencies": {
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
16
|
+
"@rollup/plugin-commonjs": "^25.0.1",
|
|
17
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
18
|
+
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
19
|
+
"@rollup/plugin-typescript": "^11.1.1",
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^5.59.9",
|
|
21
|
+
"@typescript-eslint/parser": "^5.59.9",
|
|
22
|
+
"eslint": "^8.42.0",
|
|
23
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
24
|
+
"eslint-config-prettier": "^8.3.0",
|
|
25
|
+
"eslint-plugin-import": "^2.27.5",
|
|
26
|
+
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
27
|
+
"eslint-plugin-node": "^11.1.0",
|
|
28
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
29
|
+
"eslint-plugin-promise": "^5.2.0",
|
|
30
|
+
"eslint-plugin-react": "^7.32.2",
|
|
31
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
32
|
+
"prettier": "^2.5.1",
|
|
33
|
+
"rollup-plugin-dts": "^5.3.0",
|
|
36
34
|
"rollup-plugin-terser": "^7.0.2",
|
|
37
|
-
"typescript": "^
|
|
35
|
+
"typescript": "^5.0.4"
|
|
38
36
|
},
|
|
39
|
-
"main": "dist/cjs/index.js",
|
|
40
|
-
"module": "dist/esm/index.js",
|
|
41
|
-
"files": [
|
|
42
|
-
"dist"
|
|
43
|
-
],
|
|
44
|
-
"types": "dist/index.d.ts",
|
|
45
37
|
"dependencies": {
|
|
38
|
+
"@chunkd/source-url": "^6.0.0",
|
|
39
|
+
"@cogeotiff/core": "^7.2.1",
|
|
40
|
+
"@deck.gl/core": "^8.9.18",
|
|
41
|
+
"@deck.gl/extensions": "^8.9.18",
|
|
42
|
+
"@deck.gl/geo-layers": "^8.9.18",
|
|
43
|
+
"@deck.gl/layers": "^8.9.18",
|
|
44
|
+
"@deck.gl/mesh-layers": "^8.9.18",
|
|
45
|
+
"@math.gl/web-mercator": "^3.6.3",
|
|
46
|
+
"@types/chroma-js": "^2.4.0",
|
|
47
|
+
"chroma-js": "^2.4.2",
|
|
48
|
+
"eslint": "^8.42.0",
|
|
49
|
+
"geotiff": "^2.0.7",
|
|
46
50
|
"jpeg-js": "^0.4.4",
|
|
47
|
-
"pako": "^2.0
|
|
51
|
+
"pako": "^2.1.0",
|
|
52
|
+
"rollup": "^3.25.1",
|
|
53
|
+
"url": "^0.11.1"
|
|
48
54
|
}
|
|
49
55
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
2
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
3
|
+
import typescript from '@rollup/plugin-typescript';
|
|
4
|
+
// import dts from 'rollup-plugin-dts';
|
|
5
|
+
import { terser } from 'rollup-plugin-terser';
|
|
6
|
+
import json from '@rollup/plugin-json';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
|
|
9
|
+
// import resolve from 'rollup-plugin-node-resolve';
|
|
10
|
+
|
|
11
|
+
const packageJson = {
|
|
12
|
+
main: './dist/cjs/',
|
|
13
|
+
module: './dist/esm/',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default [
|
|
17
|
+
{
|
|
18
|
+
external: [
|
|
19
|
+
'isomorphic-fetch',
|
|
20
|
+
'chroma-js',
|
|
21
|
+
'react',
|
|
22
|
+
'react-dom',
|
|
23
|
+
'@deck.gl/core',
|
|
24
|
+
'@deck.gl/react',
|
|
25
|
+
'@deck.gl/geo-layers',
|
|
26
|
+
'@deck.gl/layers',
|
|
27
|
+
'@luma.gl/constants',
|
|
28
|
+
'@luma.gl/core',
|
|
29
|
+
'@loaders.gl/core',
|
|
30
|
+
],
|
|
31
|
+
input: './src/index.ts',
|
|
32
|
+
inlineDynamicImports: true,
|
|
33
|
+
output: [
|
|
34
|
+
{
|
|
35
|
+
file: path.join(packageJson.main, 'index.js'),
|
|
36
|
+
format: 'cjs',
|
|
37
|
+
sourcemap: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
file: path.join(packageJson.main, 'index.min.js'),
|
|
41
|
+
format: 'cjs',
|
|
42
|
+
sourcemap: true,
|
|
43
|
+
plugins: [terser()],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
file: path.join(packageJson.module, 'index.js'),
|
|
47
|
+
format: 'esm',
|
|
48
|
+
sourcemap: true,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
file: path.join(packageJson.module, 'index.min.js'),
|
|
52
|
+
format: 'esm',
|
|
53
|
+
sourcemap: true,
|
|
54
|
+
plugins: [terser()],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
plugins: [
|
|
58
|
+
json(),
|
|
59
|
+
resolve(),
|
|
60
|
+
commonjs(),
|
|
61
|
+
typescript({ tsconfig: './tsconfig.json', exclude: ['**.js'] }),
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
// {
|
|
65
|
+
// input: 'dist/esm/types/index.d.ts',
|
|
66
|
+
// output: [{ file: 'dist/index.d.ts', format: 'esm' }],
|
|
67
|
+
// plugins: [dts()],
|
|
68
|
+
// external: ['react', 'react-dom'],
|
|
69
|
+
// },
|
|
70
|
+
];
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { CompositeLayer } from '@deck.gl/core';
|
|
2
|
+
import { TileLayer } from '@deck.gl/geo-layers';
|
|
3
|
+
import { BitmapLayer } from '@deck.gl/layers';
|
|
4
|
+
import CogTiles from '../cogtiles/cogtiles';
|
|
5
|
+
|
|
6
|
+
import { GeoImageOptions } from '../geoimage/geoimage';
|
|
7
|
+
|
|
8
|
+
let cogTiles: CogTiles;
|
|
9
|
+
|
|
10
|
+
let tileSize: number;
|
|
11
|
+
let minZoom: number;
|
|
12
|
+
let maxZoom: number;
|
|
13
|
+
// let needsRerender: boolean = false;
|
|
14
|
+
// let extent = [0, 0, 0, 0]
|
|
15
|
+
|
|
16
|
+
class CogBitmapLayer extends CompositeLayer<any> {
|
|
17
|
+
static layerName = 'CogBitmapLayer';
|
|
18
|
+
|
|
19
|
+
// private _isLoaded: boolean;
|
|
20
|
+
|
|
21
|
+
id = '';
|
|
22
|
+
|
|
23
|
+
url: string;
|
|
24
|
+
|
|
25
|
+
static displayName: string;
|
|
26
|
+
|
|
27
|
+
constructor(id:string, url:string, options:GeoImageOptions) {
|
|
28
|
+
super({});
|
|
29
|
+
this.id = id;
|
|
30
|
+
// this.state = {
|
|
31
|
+
// initialized: false,
|
|
32
|
+
// };
|
|
33
|
+
// this._isLoaded = false;
|
|
34
|
+
cogTiles = new CogTiles(options);
|
|
35
|
+
|
|
36
|
+
this.url = url;
|
|
37
|
+
// setTimeout(() => {
|
|
38
|
+
// this.init(url);
|
|
39
|
+
// }, 500);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
initializeState() {
|
|
43
|
+
this.state = {
|
|
44
|
+
initialized: false,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
this.init(this.url);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async init(url:string) {
|
|
51
|
+
const cog = await cogTiles.initializeCog(url);
|
|
52
|
+
this.setState({ initialized: true });
|
|
53
|
+
tileSize = cogTiles.getTileSize(cog);
|
|
54
|
+
const zoomRange = cogTiles.getZoomRange(cog);
|
|
55
|
+
[minZoom, maxZoom] = zoomRange;
|
|
56
|
+
|
|
57
|
+
// console.log(zoomRange)
|
|
58
|
+
|
|
59
|
+
// extent = cogTiles.getBoundsAsLatLon(cog)
|
|
60
|
+
|
|
61
|
+
// console.log(extent)
|
|
62
|
+
|
|
63
|
+
// needsRerender = true;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
renderLayers() {
|
|
67
|
+
if (cogTiles.cog) {
|
|
68
|
+
const layer = new TileLayer({
|
|
69
|
+
id: `${this.id}-${String(performance.now())}`,
|
|
70
|
+
getTileData: (tileData: any) => cogTiles.getTile(
|
|
71
|
+
tileData.index.x,
|
|
72
|
+
tileData.index.y,
|
|
73
|
+
tileData.index.z,
|
|
74
|
+
),
|
|
75
|
+
minZoom,
|
|
76
|
+
maxZoom,
|
|
77
|
+
tileSize,
|
|
78
|
+
maxRequests: 6,
|
|
79
|
+
extent: cogTiles.cog ? cogTiles.getBoundsAsLatLon(cogTiles.cog) : null,
|
|
80
|
+
|
|
81
|
+
renderSubLayers: (props: any) => {
|
|
82
|
+
const {
|
|
83
|
+
bbox: {
|
|
84
|
+
west, south, east, north,
|
|
85
|
+
},
|
|
86
|
+
} = props.tile;
|
|
87
|
+
|
|
88
|
+
return new BitmapLayer(props, {
|
|
89
|
+
data: null,
|
|
90
|
+
image: props.data,
|
|
91
|
+
bounds: [west, south, east, north],
|
|
92
|
+
opacity: 1, // 0.6
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
return layer;
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
CogBitmapLayer.displayName = 'CogBitmapLayer';
|
|
103
|
+
|
|
104
|
+
export default CogBitmapLayer;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# CogBitmapLayer
|
|
2
|
+
A Deck.gl-compatible layer for loading and displaying tiled COG image data
|
|
3
|
+
## Features
|
|
4
|
+
### Tiled data rendering
|
|
5
|
+
- Dynamically load and render tiled COG image data
|
|
6
|
+
### Data visualization
|
|
7
|
+
- Set visualization styling, colors, use heatmap, set data bounds, and more
|
|
8
|
+
### Compression support
|
|
9
|
+
- Supports JPEG, LZW nad DEFLATE data compression methods
|
|
10
|
+
## Usage
|
|
11
|
+
### Initialize the layer
|
|
12
|
+
To create CogBitmapLayer, you need an URL of your COG and also an object containing [geoimage](/geoimage/README.md) options for data processing.
|
|
13
|
+
|
|
14
|
+
#### Example
|
|
15
|
+
Display simple rgb image. If you don't specify a channel to process, it defaults to grayscale, RGB, or RGBA depending on the channel count
|
|
16
|
+
```typescript
|
|
17
|
+
const bitmapLayer = new CogBitmapLayer(
|
|
18
|
+
"cog.tif",
|
|
19
|
+
{type:"image"}
|
|
20
|
+
)
|
|
21
|
+
```
|
|
22
|
+
Display the second channel as a heatmap with data from 0 to 1000
|
|
23
|
+
- Currently, when `useAutoRange` is `true` min and max data value for each image is calculated separately, thus it is recommended to set min and max values in `colorScaleValueRange`.
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
const bitmapLayer = new CogBitmapLayer(
|
|
27
|
+
"cog.tif",
|
|
28
|
+
{type:"image", useHeatmap:true, useChannel:1, colorScaleValueRange: [0, 1000]}
|
|
29
|
+
)
|
|
30
|
+
```
|
|
31
|
+
Display the second channel as a heatmap with data from 0 to 1000 with custom color scale <a id="custom-heatmap-color-scale"></a>
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
const bitmapLayer = new CogBitmapLayer(
|
|
35
|
+
"cog.tif",
|
|
36
|
+
{type:"image", useHeatmap:true, useChannel:1, colorScale: ['green', '#3182bd', [255, 0, 0], colorScaleValueRange: [0, 1000]}
|
|
37
|
+
)
|
|
38
|
+
```
|
|
39
|
+
Display the third channel as a green color and only show data from 100 to 200, the clipped data should be visualized with yellow color
|
|
40
|
+
```typescript
|
|
41
|
+
const bitmapLayer = new CogBitmapLayer(
|
|
42
|
+
"cog.tif",
|
|
43
|
+
{type:"image", useChannel:2, useSingleColor: true, clipLow:100, clipHigh: 200, color: [0, 255, 0], clippedColor: 'yellow'}
|
|
44
|
+
)
|
|
45
|
+
```
|
|
46
|
+
Asign color to specific data values <a id="assigning-color-to-specific-data-value"></a>
|
|
47
|
+
```typescript
|
|
48
|
+
const bitmapLayer = new CogBitmapLayer(
|
|
49
|
+
"cog.tif",
|
|
50
|
+
{type:"image", useChannel:20, useColorsBasedOnValues: true, colorsBasedOnValues: [[1, 'red'], [2, [0,0,255]], [3, '#00FF00']]}
|
|
51
|
+
)
|
|
52
|
+
```
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { CompositeLayer } from '@deck.gl/core';
|
|
2
|
+
import { TileLayer, TerrainLayer } from '@deck.gl/geo-layers';
|
|
3
|
+
|
|
4
|
+
// FIXME
|
|
5
|
+
// eslint-disable-next-line
|
|
6
|
+
import { getTileUrl, isCogUrl, isTileServiceUrl } from '../utilities/tileurls';
|
|
7
|
+
import CogTiles from '../cogtiles/cogtiles';
|
|
8
|
+
|
|
9
|
+
import { GeoImageOptions } from '../geoimage/geoimage';
|
|
10
|
+
|
|
11
|
+
let terrainCogTiles: CogTiles;
|
|
12
|
+
let bitmapCogTiles: CogTiles;
|
|
13
|
+
|
|
14
|
+
let tileSize: number;
|
|
15
|
+
let minZoom: number;
|
|
16
|
+
let maxZoom: number;
|
|
17
|
+
// let needsRerender: boolean = false;
|
|
18
|
+
|
|
19
|
+
class CogTerrainLayer extends CompositeLayer<any> {
|
|
20
|
+
static layerName = 'CogTerrainLayer';
|
|
21
|
+
|
|
22
|
+
bitmapUrl: string;
|
|
23
|
+
|
|
24
|
+
urlType: 'none' | 'tile' | 'cog' = 'none';
|
|
25
|
+
|
|
26
|
+
id = '';
|
|
27
|
+
|
|
28
|
+
terrainUrl: string;
|
|
29
|
+
|
|
30
|
+
static displayName: string;
|
|
31
|
+
|
|
32
|
+
constructor(
|
|
33
|
+
id:string,
|
|
34
|
+
terrainUrl: string,
|
|
35
|
+
terrainOptions: GeoImageOptions,
|
|
36
|
+
bitmapUrl?: string,
|
|
37
|
+
bitmapOptions?: GeoImageOptions,
|
|
38
|
+
) {
|
|
39
|
+
super({});
|
|
40
|
+
this.id = id;
|
|
41
|
+
|
|
42
|
+
if (bitmapUrl) {
|
|
43
|
+
if (isTileServiceUrl(bitmapUrl)) {
|
|
44
|
+
this.bitmapUrl = bitmapUrl;
|
|
45
|
+
this.urlType = 'tile';
|
|
46
|
+
} else if (isCogUrl(bitmapUrl)) {
|
|
47
|
+
bitmapCogTiles = new CogTiles(bitmapOptions!);
|
|
48
|
+
bitmapCogTiles.initializeCog(bitmapUrl);
|
|
49
|
+
this.urlType = 'cog';
|
|
50
|
+
} else {
|
|
51
|
+
console.warn('URL needs to point to a valid cog file, or needs to be in the {x}{y}{z} format.');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
terrainCogTiles = new CogTiles(terrainOptions);
|
|
56
|
+
// this.init(terrainUrl);
|
|
57
|
+
this.terrainUrl = terrainUrl;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
initializeState() {
|
|
61
|
+
this.state = {
|
|
62
|
+
initialized: false,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
this.init(this.terrainUrl);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// async initializeState() {}
|
|
69
|
+
|
|
70
|
+
async init(terrainUrl: string) {
|
|
71
|
+
// console.log("LAYER INITIALIZE STATE");
|
|
72
|
+
|
|
73
|
+
const cog = await terrainCogTiles.initializeCog(terrainUrl);
|
|
74
|
+
tileSize = terrainCogTiles.getTileSize(cog);
|
|
75
|
+
|
|
76
|
+
const zoomRange = terrainCogTiles.getZoomRange(cog);
|
|
77
|
+
[minZoom, maxZoom] = zoomRange;
|
|
78
|
+
|
|
79
|
+
this.setState({ initialized: true });
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
renderLayers() {
|
|
83
|
+
if (terrainCogTiles.cog) {
|
|
84
|
+
// console.log("LAYER RENDER");
|
|
85
|
+
|
|
86
|
+
let bitmapTile: string;
|
|
87
|
+
// let zoomOffset = 0
|
|
88
|
+
|
|
89
|
+
switch (this.urlType) {
|
|
90
|
+
case 'tile':
|
|
91
|
+
// zoomOffset = 0
|
|
92
|
+
break;
|
|
93
|
+
case 'cog':
|
|
94
|
+
// zoomOffset = -2
|
|
95
|
+
break;
|
|
96
|
+
default:
|
|
97
|
+
}
|
|
98
|
+
// console.log("is fully loaded: " + loaded);
|
|
99
|
+
const layer = new TileLayer({
|
|
100
|
+
id: `${this.id}-${String(performance.now())}`,
|
|
101
|
+
zoomOffset: -1,
|
|
102
|
+
getTileData: (tileData: any) => terrainCogTiles.getTile(
|
|
103
|
+
tileData.index.x,
|
|
104
|
+
tileData.index.y,
|
|
105
|
+
tileData.index.z,
|
|
106
|
+
),
|
|
107
|
+
minZoom,
|
|
108
|
+
maxZoom,
|
|
109
|
+
tileSize,
|
|
110
|
+
maxRequests: 6,
|
|
111
|
+
refinementStrategy: 'best-available',
|
|
112
|
+
extent: terrainCogTiles.getBoundsAsLatLon(terrainCogTiles.cog),
|
|
113
|
+
|
|
114
|
+
renderSubLayers: (props: any) => {
|
|
115
|
+
if (props.data && (props.tile.index.x !== undefined)) {
|
|
116
|
+
switch (this.urlType) {
|
|
117
|
+
case 'tile':
|
|
118
|
+
bitmapTile = getTileUrl(
|
|
119
|
+
this.bitmapUrl,
|
|
120
|
+
props.tile.index.x,
|
|
121
|
+
props.tile.index.y,
|
|
122
|
+
props.tile.index.z,
|
|
123
|
+
);
|
|
124
|
+
break;
|
|
125
|
+
case 'cog':
|
|
126
|
+
bitmapTile = bitmapCogTiles.getTile(
|
|
127
|
+
props.tile.index.x,
|
|
128
|
+
props.tile.index.y,
|
|
129
|
+
props.tile.index.z,
|
|
130
|
+
);
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
bitmapTile = null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return new TerrainLayer({
|
|
137
|
+
id: (`terrain-${props.tile.index.x}-${props.tile.index.y}-${props.tile.index.z}`),
|
|
138
|
+
pickable: true,
|
|
139
|
+
elevationDecoder: {
|
|
140
|
+
rScaler: 6553.6,
|
|
141
|
+
gScaler: 25.6,
|
|
142
|
+
bScaler: 0.1,
|
|
143
|
+
offset: -10000,
|
|
144
|
+
},
|
|
145
|
+
elevationData: props.data,
|
|
146
|
+
texture: bitmapTile,
|
|
147
|
+
bounds: [props.tile.bbox.west,
|
|
148
|
+
props.tile.bbox.south,
|
|
149
|
+
props.tile.bbox.east,
|
|
150
|
+
props.tile.bbox.north,
|
|
151
|
+
],
|
|
152
|
+
minZoom,
|
|
153
|
+
maxZoom,
|
|
154
|
+
loadOptions: {
|
|
155
|
+
terrain: {
|
|
156
|
+
skirtHeight: 2000,
|
|
157
|
+
tesselator: 'martini',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
meshMaxError: 12,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
return [layer];
|
|
167
|
+
}
|
|
168
|
+
return [];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
CogTerrainLayer.displayName = 'CogTerrainLayer';
|
|
173
|
+
|
|
174
|
+
export default CogTerrainLayer;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# CogTerrainLayer
|
|
2
|
+
A Deck.gl-compatible layer for loading and displaying tiled COG height data
|
|
3
|
+
## Features
|
|
4
|
+
### Tiled terrain rendering
|
|
5
|
+
- Dynamically load and render tiled COG height data
|
|
6
|
+
- Overlay another COG as a bitmap, or supply a tile service template url.
|
|
7
|
+
### Data visualization
|
|
8
|
+
- Multiply terrain height
|
|
9
|
+
- Clamp COG data on top of generated terrain
|
|
10
|
+
- Set visualization styling, colors, use heatmap, set data bounds, and more
|
|
11
|
+
## Usage
|
|
12
|
+
### Initialize the layer
|
|
13
|
+
To create CogTerrainLayer, you need an URL of your COG and also an object containing [geoimage](/geoimage/README.md) options for data processing.
|
|
14
|
+
For this layer, only needed options are `type`, `format`, and optionally `useChannel` and `multiplier`.
|
|
15
|
+
You can also specify another COG as an overlay and it's corresponding options, or just supply a tile service template url. Overlay options use all of [geoimage](/geoimage/README.md) options and work only with COG
|
|
16
|
+
|
|
17
|
+
#### Example
|
|
18
|
+
Display simple terrain
|
|
19
|
+
```
|
|
20
|
+
const terrainLayer = new CogTerrainLayer(
|
|
21
|
+
"cog.tif",
|
|
22
|
+
{type:"terrain", format:"UINT8"}
|
|
23
|
+
)
|
|
24
|
+
```
|
|
25
|
+
Display terrain with tile service overlay
|
|
26
|
+
```
|
|
27
|
+
const terrainLayer = new CogTerrainLayer(
|
|
28
|
+
"cog.tif",
|
|
29
|
+
{type:"terrain", format:"UINT8"},
|
|
30
|
+
"tile-service.com/{z}/{x}/{y}.png"
|
|
31
|
+
)
|
|
32
|
+
```
|
|
33
|
+
Display terrain with stylized COG overlay
|
|
34
|
+
```
|
|
35
|
+
const terrainLayer = new CogTerrainLayer(
|
|
36
|
+
"cog.tif",
|
|
37
|
+
{type:"terrain", format:"UINT8"},
|
|
38
|
+
"cog-overlay.tif",
|
|
39
|
+
{type:"image, useHeatMap:true, useChannel:2}
|
|
40
|
+
)
|
|
41
|
+
```
|