@gisatcz/deckgl-geolib 0.0.4 → 1.2.1-dev.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.
@@ -0,0 +1,13 @@
1
+ import { CompositeLayer } from '@deck.gl/core';
2
+ import { GeoImageOptions } from '../geoimage/geoimage';
3
+ declare class CogBitmapLayer extends CompositeLayer<any> {
4
+ static layerName: string;
5
+ id: string;
6
+ url: string;
7
+ static displayName: string;
8
+ constructor(id: string, url: string, options: GeoImageOptions);
9
+ initializeState(): void;
10
+ init(url: string): Promise<void>;
11
+ renderLayers(): any;
12
+ }
13
+ export default CogBitmapLayer;
@@ -0,0 +1,15 @@
1
+ import { CompositeLayer } from '@deck.gl/core';
2
+ import { GeoImageOptions } from '../geoimage/geoimage';
3
+ declare class CogTerrainLayer extends CompositeLayer<any> {
4
+ static layerName: string;
5
+ bitmapUrl: string;
6
+ urlType: 'none' | 'tile' | 'cog';
7
+ id: string;
8
+ terrainUrl: string;
9
+ static displayName: string;
10
+ constructor(id: string, terrainUrl: string, terrainOptions: GeoImageOptions, bitmapUrl?: string, bitmapOptions?: GeoImageOptions);
11
+ initializeState(): void;
12
+ init(terrainUrl: string): Promise<void>;
13
+ renderLayers(): any[];
14
+ }
15
+ 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
+ }
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,4 @@
1
+ declare function isTileServiceUrl(url: string): boolean;
2
+ declare function isCogUrl(url: string): boolean;
3
+ declare function getTileUrl(service: string, x: number, y: number, z: number): string;
4
+ export { isTileServiceUrl, isCogUrl, getTileUrl };
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@gisatcz/deckgl-geolib",
3
- "version": "0.0.4",
3
+ "version": "1.2.1-dev.0",
4
4
  "private": false,
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/index.d.ts",
8
+ "sideEffects": false,
8
9
  "scripts": {
9
10
  "rollup": "rollup -c",
10
11
  "start": "yarn && yarn rollup",
@@ -16,12 +17,10 @@
16
17
  "@rollup/plugin-json": "^6.0.0",
17
18
  "@rollup/plugin-node-resolve": "^15.1.0",
18
19
  "@rollup/plugin-typescript": "^11.1.1",
19
- "@typescript-eslint/eslint-plugin": "^5.59.9",
20
- "@typescript-eslint/parser": "^5.59.9",
20
+ "@types/pako": "^2.0.0",
21
21
  "eslint": "^8.42.0",
22
22
  "eslint-config-airbnb": "^19.0.4",
23
23
  "eslint-config-prettier": "^8.3.0",
24
- "eslint-config-standard": "^16.0.3",
25
24
  "eslint-plugin-import": "^2.27.5",
26
25
  "eslint-plugin-jsx-a11y": "^6.7.1",
27
26
  "eslint-plugin-node": "^11.1.0",
@@ -29,7 +28,6 @@
29
28
  "eslint-plugin-promise": "^5.2.0",
30
29
  "eslint-plugin-react": "^7.32.2",
31
30
  "eslint-plugin-react-hooks": "^4.6.0",
32
- "prettier": "^2.5.1",
33
31
  "rollup-plugin-dts": "^5.3.0",
34
32
  "rollup-plugin-terser": "^7.0.2",
35
33
  "typescript": "^5.0.4"
@@ -42,12 +40,15 @@
42
40
  "@deck.gl/geo-layers": "^8.9.18",
43
41
  "@deck.gl/layers": "^8.9.18",
44
42
  "@deck.gl/mesh-layers": "^8.9.18",
43
+ "@fortawesome/fontawesome-svg-core": "^6.4.0",
45
44
  "@math.gl/web-mercator": "^3.6.3",
46
45
  "@types/chroma-js": "^2.4.0",
47
46
  "chroma-js": "^2.4.2",
47
+ "eslint": "^8.42.0",
48
48
  "geotiff": "^2.0.7",
49
49
  "jpeg-js": "^0.4.4",
50
50
  "pako": "^2.1.0",
51
- "rollup": "^3.25.1"
51
+ "rollup": "^3.25.1",
52
+ "url": "^0.11.1"
52
53
  }
53
54
  }
package/rollup.config.mjs CHANGED
@@ -4,12 +4,11 @@ import typescript from '@rollup/plugin-typescript';
4
4
  // import dts from 'rollup-plugin-dts';
5
5
  import { terser } from 'rollup-plugin-terser';
6
6
  import json from '@rollup/plugin-json';
7
-
8
- // import resolve from 'rollup-plugin-node-resolve';
7
+ import path from 'path';
9
8
 
10
9
  const packageJson = {
11
- main: './dist/cjs/index.js',
12
- module: './dist/esm/index.js',
10
+ main: './dist/cjs/',
11
+ module: './dist/esm/',
13
12
  };
14
13
 
15
14
  export default [
@@ -25,26 +24,42 @@ export default [
25
24
  '@deck.gl/layers',
26
25
  '@luma.gl/constants',
27
26
  '@luma.gl/core',
28
- '@loaders.gl/core'],
27
+ '@loaders.gl/core',
28
+ ],
29
29
  input: './src/index.ts',
30
- inlineDynamicImports: true,
31
30
  output: [
32
31
  {
33
- file: packageJson.main,
32
+ file: path.join(packageJson.main, 'index.js'),
33
+ format: 'cjs',
34
+ sourcemap: true,
35
+ inlineDynamicImports: true,
36
+ },
37
+ {
38
+ file: path.join(packageJson.main, 'index.min.js'),
34
39
  format: 'cjs',
35
40
  sourcemap: true,
36
41
  plugins: [terser()],
42
+ inlineDynamicImports: true,
43
+ },
44
+ {
45
+ file: path.join(packageJson.module, 'index.js'),
46
+ format: 'esm',
47
+ sourcemap: true,
48
+ inlineDynamicImports: true,
37
49
  },
38
50
  {
39
- file: packageJson.module,
51
+ file: path.join(packageJson.module, 'index.min.js'),
40
52
  format: 'esm',
41
53
  sourcemap: true,
42
54
  plugins: [terser()],
55
+ inlineDynamicImports: true,
43
56
  },
44
57
  ],
45
58
  plugins: [
46
59
  json(),
47
- resolve(),
60
+ resolve({
61
+ preferBuiltins: true,
62
+ }),
48
63
  commonjs(),
49
64
  typescript({ tsconfig: './tsconfig.json', exclude: ['**.js'] }),
50
65
  ],
@@ -1,7 +1,6 @@
1
1
  import { CompositeLayer } from '@deck.gl/core';
2
2
  import { TileLayer } from '@deck.gl/geo-layers';
3
3
  import { BitmapLayer } from '@deck.gl/layers';
4
- import { log } from 'geotiff/dist-node/logging';
5
4
  import CogTiles from '../cogtiles/cogtiles';
6
5
 
7
6
  import { GeoImageOptions } from '../geoimage/geoimage';
@@ -23,6 +22,8 @@ class CogBitmapLayer extends CompositeLayer<any> {
23
22
 
24
23
  url: string;
25
24
 
25
+ static displayName: string;
26
+
26
27
  constructor(id:string, url:string, options:GeoImageOptions) {
27
28
  super({});
28
29
  this.id = id;
@@ -98,4 +99,6 @@ class CogBitmapLayer extends CompositeLayer<any> {
98
99
  }
99
100
  }
100
101
 
102
+ CogBitmapLayer.displayName = 'CogBitmapLayer';
103
+
101
104
  export default CogBitmapLayer;
@@ -3,7 +3,7 @@ import { TileLayer, TerrainLayer } from '@deck.gl/geo-layers';
3
3
 
4
4
  // FIXME
5
5
  // eslint-disable-next-line
6
- import { getTileUrl, isCogUrl, isTileServiceUrl } from 'example/src/utilities/tileurls';
6
+ import { getTileUrl, isCogUrl, isTileServiceUrl } from '../utilities/tileurls';
7
7
  import CogTiles from '../cogtiles/cogtiles';
8
8
 
9
9
  import { GeoImageOptions } from '../geoimage/geoimage';
@@ -27,6 +27,8 @@ class CogTerrainLayer extends CompositeLayer<any> {
27
27
 
28
28
  terrainUrl: string;
29
29
 
30
+ static displayName: string;
31
+
30
32
  constructor(
31
33
  id:string,
32
34
  terrainUrl: string,
@@ -167,4 +169,6 @@ class CogTerrainLayer extends CompositeLayer<any> {
167
169
  }
168
170
  }
169
171
 
172
+ CogTerrainLayer.displayName = 'CogTerrainLayer';
173
+
170
174
  export default CogTerrainLayer;
@@ -7,10 +7,10 @@ import { SourceUrl } from '@chunkd/source-url';
7
7
  import { inflate } from 'pako';
8
8
  import jpeg from 'jpeg-js';
9
9
  import { worldToLngLat } from '@math.gl/web-mercator';
10
- import LZWDecoder from './lzw'; // TODO: remove absolute path
10
+ import LZWDecoder from './lzw';
11
11
 
12
12
  // Bitmap styling
13
- import { GeoImage, GeoImageOptions } from '../geoimage/geoimage'; // TODO: remove absolute path
13
+ import GeoImage, { GeoImageOptions } from '../geoimage/geoimage'; // TODO: remove absolute path
14
14
 
15
15
  const EARTH_CIRCUMFERENCE = 40075000.0;
16
16
  const EARTH_HALF_CIRCUMFERENCE = 20037500.0;
@@ -41,9 +41,14 @@ class CogTiles {
41
41
  }
42
42
 
43
43
  async initializeCog(url: string) {
44
- // console.log("Initializing CogTiles...")
44
+ // Set native fetch instead node-fetch to SourceUrl
45
+ SourceUrl.fetch = async (input, init) => {
46
+ const res = await fetch(input, init);
47
+ return res;
48
+ };
45
49
 
46
- this.cog = await CogTiff.create(new SourceUrl(url));
50
+ const sourceUrl = new SourceUrl(url);
51
+ this.cog = await CogTiff.create(sourceUrl);
47
52
 
48
53
  this.cog.images.forEach((image:CogTiffImage) => {
49
54
  image.loadGeoTiffTags();
@@ -52,7 +52,7 @@ const DefaultGeoImageOptions: GeoImageOptions = {
52
52
  clippedColor: [0, 0, 0, 0],
53
53
  };
54
54
 
55
- export class GeoImage {
55
+ export default class GeoImage {
56
56
  data: GeoTIFFImage | undefined;
57
57
 
58
58
  scale = (
@@ -317,7 +317,7 @@ export class GeoImage {
317
317
  let maxValue = options.maxValue ? options.maxValue : Number.MIN_VALUE;
318
318
  let minValue = options.minValue ? options.minValue : Number.MAX_VALUE;
319
319
  for (let idx = 0; idx < array.length; idx += 1) {
320
- if (!options.noDataValue || array[idx] !== options.noDataValue) {
320
+ if (options.noDataValue === undefined || array[idx] !== options.noDataValue) {
321
321
  if (array[idx] > maxValue) maxValue = array[idx];
322
322
  if (array[idx] < minValue) minValue = array[idx];
323
323
  }
@@ -336,7 +336,7 @@ export class GeoImage {
336
336
 
337
337
  for (let i = 0; i < arrayLength; i += 4) {
338
338
  let pixelColor = options.nullColor;
339
- if (!options.noDataValue || dataArray[pixel] !== options.noDataValue) {
339
+ if (options.noDataValue === undefined || dataArray[pixel] !== options.noDataValue) {
340
340
  if (
341
341
  (options.clipLow != null && dataArray[pixel] <= options.clipLow)
342
342
  || (options.clipHigh != null && dataArray[pixel] >= options.clipHigh)
package/src/index.ts CHANGED
@@ -1,4 +1,11 @@
1
- export * from './cogbitmaplayer/CogBitmapLayer';
2
- export * from './cogterrainlayer/CogTerrainLayer';
3
- export * from './cogtiles/cogtiles';
4
- export * from './geoimage/geoimage';
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
+
6
+ export default {
7
+ CogBitmapLayer,
8
+ CogTerrainLayer,
9
+ cogtiles,
10
+ GeoImage,
11
+ };
@@ -0,0 +1,21 @@
1
+ function isTileServiceUrl(url:string) {
2
+ if (url.includes('{x}') && url.includes('{y}') && url.includes('{z}')) {
3
+ return true;
4
+ }
5
+ return false;
6
+ }
7
+
8
+ function isCogUrl(url:string) {
9
+ if (url.includes('.tif') || url.includes('.tiff') || url.includes('.TIF') || url.includes('.TIFF')) {
10
+ return true;
11
+ }
12
+ return false;
13
+ }
14
+
15
+ function getTileUrl(service:string, x:number, y:number, z:number) {
16
+ const url = service.replace('{x}', String(x)).replace('{y}', String(y)).replace('{z}', String(z));
17
+
18
+ return url;
19
+ }
20
+
21
+ export { isTileServiceUrl, isCogUrl, getTileUrl };
package/tsconfig.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "extends": "../tsconfig.json"
2
+ "extends": "../tsconfig.json",
3
3
  }