@gisatcz/deckgl-geolib 1.3.0 → 1.3.1-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,15 @@
1
1
  import { CompositeLayer } from '@deck.gl/core';
2
- import { GeoImageOptions } from '../geoimage/geoimage';
2
+ import CogTiles from '../cogtiles/cogtiles.ts';
3
+ import { GeoImageOptions } from '../geoimage/geoimage.ts';
3
4
  declare class CogBitmapLayer extends CompositeLayer<any> {
4
5
  static layerName: string;
5
6
  id: string;
6
7
  url: string;
7
8
  static displayName: string;
9
+ cogTiles: CogTiles;
10
+ tileSize: number;
11
+ minZoom: number;
12
+ maxZoom: number;
8
13
  constructor(id: string, url: string, options: GeoImageOptions);
9
14
  initializeState(): void;
10
15
  init(url: string): Promise<void>;
@@ -1,7 +1,13 @@
1
1
  import { CompositeLayer } from '@deck.gl/core';
2
- import { GeoImageOptions } from '../geoimage/geoimage';
2
+ import CogTiles from '../cogtiles/cogtiles.ts';
3
+ import { GeoImageOptions } from '../geoimage/geoimage.ts';
3
4
  declare class CogTerrainLayer extends CompositeLayer<any> {
4
5
  static layerName: string;
6
+ terrainCogTiles: CogTiles;
7
+ bitmapCogTiles: CogTiles;
8
+ tileSize: number;
9
+ minZoom: number;
10
+ maxZoom: number;
5
11
  bitmapUrl: string;
6
12
  urlType: 'none' | 'tile' | 'cog';
7
13
  id: string;
@@ -1,6 +1,6 @@
1
1
  import { CogTiff, CogTiffImage } from '@cogeotiff/core';
2
- import LZWDecoder from './lzw';
3
- import GeoImage, { GeoImageOptions } from '../geoimage/geoimage';
2
+ import LZWDecoder from './lzw.js';
3
+ import GeoImage, { GeoImageOptions } from '../geoimage/geoimage.ts';
4
4
  declare class CogTiles {
5
5
  cog: CogTiff;
6
6
  zoomRange: number[];
@@ -1,7 +1,7 @@
1
- import CogBitmapLayer from './cogbitmaplayer/CogBitmapLayer';
2
- import CogTerrainLayer from './cogterrainlayer/CogTerrainLayer';
3
- import cogtiles from './cogtiles/cogtiles';
4
- import GeoImage from './geoimage/geoimage';
1
+ import CogBitmapLayer from './cogbitmaplayer/CogBitmapLayer.ts';
2
+ import CogTerrainLayer from './cogterrainlayer/CogTerrainLayer.ts';
3
+ import cogtiles from './cogtiles/cogtiles.ts';
4
+ import GeoImage from './geoimage/geoimage.ts';
5
5
  declare const _default: {
6
6
  CogBitmapLayer: typeof CogBitmapLayer;
7
7
  CogTerrainLayer: typeof CogTerrainLayer;
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@gisatcz/deckgl-geolib",
3
- "version": "1.3.0",
3
+ "version": "1.3.1-dev.1",
4
4
  "private": false,
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
7
+ "type": "module",
7
8
  "types": "dist/index.d.ts",
8
9
  "sideEffects": false,
9
10
  "scripts": {
@@ -49,6 +50,7 @@
49
50
  "jpeg-js": "^0.4.4",
50
51
  "pako": "^2.1.0",
51
52
  "rollup": "^3.25.1",
53
+ "rollup-plugin-polyfill-node": "^0.12.0",
52
54
  "url": "^0.11.1"
53
55
  }
54
56
  }
package/rollup.config.mjs CHANGED
@@ -4,6 +4,7 @@ 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
+ import polyfills from 'rollup-plugin-polyfill-node';
7
8
  import path from 'path';
8
9
 
9
10
  const packageJson = {
@@ -56,6 +57,7 @@ export default [
56
57
  },
57
58
  ],
58
59
  plugins: [
60
+ polyfills(),
59
61
  json(),
60
62
  resolve({
61
63
  preferBuiltins: true,
@@ -1,15 +1,10 @@
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 CogTiles from '../cogtiles/cogtiles';
4
+ import CogTiles from '../cogtiles/cogtiles.ts';
5
5
 
6
- import { GeoImageOptions } from '../geoimage/geoimage';
6
+ import { GeoImageOptions } from '../geoimage/geoimage.ts';
7
7
 
8
- let cogTiles: CogTiles;
9
-
10
- let tileSize: number;
11
- let minZoom: number;
12
- let maxZoom: number;
13
8
  // let needsRerender: boolean = false;
14
9
  // let extent = [0, 0, 0, 0]
15
10
 
@@ -24,6 +19,14 @@ class CogBitmapLayer extends CompositeLayer<any> {
24
19
 
25
20
  static displayName: string;
26
21
 
22
+ cogTiles: CogTiles;
23
+
24
+ tileSize: number;
25
+
26
+ minZoom: number;
27
+
28
+ maxZoom: number;
29
+
27
30
  constructor(id:string, url:string, options:GeoImageOptions) {
28
31
  super({});
29
32
  this.id = id;
@@ -31,7 +34,7 @@ class CogBitmapLayer extends CompositeLayer<any> {
31
34
  // initialized: false,
32
35
  // };
33
36
  // this._isLoaded = false;
34
- cogTiles = new CogTiles(options);
37
+ this.cogTiles = new CogTiles(options);
35
38
 
36
39
  this.url = url;
37
40
  // setTimeout(() => {
@@ -48,11 +51,11 @@ class CogBitmapLayer extends CompositeLayer<any> {
48
51
  }
49
52
 
50
53
  async init(url:string) {
51
- const cog = await cogTiles.initializeCog(url);
54
+ const cog = await this.cogTiles.initializeCog(url);
52
55
  this.setState({ initialized: true });
53
- tileSize = cogTiles.getTileSize(cog);
54
- const zoomRange = cogTiles.getZoomRange(cog);
55
- [minZoom, maxZoom] = zoomRange;
56
+ this.tileSize = this.cogTiles.getTileSize(cog);
57
+ const zoomRange = this.cogTiles.getZoomRange(cog);
58
+ [this.minZoom, this.maxZoom] = zoomRange;
56
59
 
57
60
  // console.log(zoomRange)
58
61
 
@@ -64,19 +67,19 @@ class CogBitmapLayer extends CompositeLayer<any> {
64
67
  }
65
68
 
66
69
  renderLayers() {
67
- if (cogTiles.cog) {
70
+ if (this.cogTiles.cog) {
68
71
  const layer = new TileLayer({
69
72
  id: `${this.id}-${String(performance.now())}`,
70
- getTileData: (tileData: any) => cogTiles.getTile(
73
+ getTileData: (tileData: any) => this.cogTiles.getTile(
71
74
  tileData.index.x,
72
75
  tileData.index.y,
73
76
  tileData.index.z,
74
77
  ),
75
- minZoom,
76
- maxZoom,
77
- tileSize,
78
+ minZoom: this.minZoom,
79
+ maxZoom: this.maxZoom,
80
+ tileSize: this.tileSize,
78
81
  maxRequests: 6,
79
- extent: cogTiles.cog ? cogTiles.getBoundsAsLatLon(cogTiles.cog) : null,
82
+ extent: this.cogTiles.cog ? this.cogTiles.getBoundsAsLatLon(this.cogTiles.cog) : null,
80
83
 
81
84
  renderSubLayers: (props: any) => {
82
85
  const {
@@ -3,22 +3,24 @@ 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 '../utilities/tileurls';
7
- import CogTiles from '../cogtiles/cogtiles';
6
+ import { getTileUrl, isCogUrl, isTileServiceUrl } from '../utilities/tileurls.ts';
7
+ import CogTiles from '../cogtiles/cogtiles.ts';
8
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;
9
+ import { GeoImageOptions } from '../geoimage/geoimage.ts';
18
10
 
19
11
  class CogTerrainLayer extends CompositeLayer<any> {
20
12
  static layerName = 'CogTerrainLayer';
21
13
 
14
+ terrainCogTiles: CogTiles;
15
+
16
+ bitmapCogTiles: CogTiles;
17
+
18
+ tileSize: number;
19
+
20
+ minZoom: number;
21
+
22
+ maxZoom: number;
23
+
22
24
  bitmapUrl: string;
23
25
 
24
26
  urlType: 'none' | 'tile' | 'cog' = 'none';
@@ -44,15 +46,15 @@ class CogTerrainLayer extends CompositeLayer<any> {
44
46
  this.bitmapUrl = bitmapUrl;
45
47
  this.urlType = 'tile';
46
48
  } else if (isCogUrl(bitmapUrl)) {
47
- bitmapCogTiles = new CogTiles(bitmapOptions!);
48
- bitmapCogTiles.initializeCog(bitmapUrl);
49
+ this.bitmapCogTiles = new CogTiles(bitmapOptions!);
50
+ this.bitmapCogTiles.initializeCog(bitmapUrl);
49
51
  this.urlType = 'cog';
50
52
  } else {
51
53
  console.warn('URL needs to point to a valid cog file, or needs to be in the {x}{y}{z} format.');
52
54
  }
53
55
  }
54
56
 
55
- terrainCogTiles = new CogTiles(terrainOptions);
57
+ this.terrainCogTiles = new CogTiles(terrainOptions);
56
58
  // this.init(terrainUrl);
57
59
  this.terrainUrl = terrainUrl;
58
60
  }
@@ -70,17 +72,17 @@ class CogTerrainLayer extends CompositeLayer<any> {
70
72
  async init(terrainUrl: string) {
71
73
  // console.log("LAYER INITIALIZE STATE");
72
74
 
73
- const cog = await terrainCogTiles.initializeCog(terrainUrl);
74
- tileSize = terrainCogTiles.getTileSize(cog);
75
+ const cog = await this.terrainCogTiles.initializeCog(terrainUrl);
76
+ this.tileSize = this.terrainCogTiles.getTileSize(cog);
75
77
 
76
- const zoomRange = terrainCogTiles.getZoomRange(cog);
77
- [minZoom, maxZoom] = zoomRange;
78
+ const zoomRange = this.terrainCogTiles.getZoomRange(cog);
79
+ [this.minZoom, this.maxZoom] = zoomRange;
78
80
 
79
81
  this.setState({ initialized: true });
80
82
  }
81
83
 
82
84
  renderLayers() {
83
- if (terrainCogTiles.cog) {
85
+ if (this.terrainCogTiles.cog) {
84
86
  // console.log("LAYER RENDER");
85
87
 
86
88
  let bitmapTile: string;
@@ -99,17 +101,17 @@ class CogTerrainLayer extends CompositeLayer<any> {
99
101
  const layer = new TileLayer({
100
102
  id: `${this.id}-${String(performance.now())}`,
101
103
  zoomOffset: -1,
102
- getTileData: (tileData: any) => terrainCogTiles.getTile(
104
+ getTileData: (tileData: any) => this.terrainCogTiles.getTile(
103
105
  tileData.index.x,
104
106
  tileData.index.y,
105
107
  tileData.index.z,
106
108
  ),
107
- minZoom,
108
- maxZoom,
109
- tileSize,
109
+ minZoom: this.minZoom,
110
+ maxZoom: this.maxZoom,
111
+ tileSize: this.tileSize,
110
112
  maxRequests: 6,
111
113
  refinementStrategy: 'best-available',
112
- extent: terrainCogTiles.getBoundsAsLatLon(terrainCogTiles.cog),
114
+ extent: this.terrainCogTiles.getBoundsAsLatLon(this.terrainCogTiles.cog),
113
115
 
114
116
  renderSubLayers: (props: any) => {
115
117
  if (props.data && (props.tile.index.x !== undefined)) {
@@ -123,7 +125,7 @@ class CogTerrainLayer extends CompositeLayer<any> {
123
125
  );
124
126
  break;
125
127
  case 'cog':
126
- bitmapTile = bitmapCogTiles.getTile(
128
+ bitmapTile = this.bitmapCogTiles.getTile(
127
129
  props.tile.index.x,
128
130
  props.tile.index.y,
129
131
  props.tile.index.z,
@@ -149,8 +151,8 @@ class CogTerrainLayer extends CompositeLayer<any> {
149
151
  props.tile.bbox.east,
150
152
  props.tile.bbox.north,
151
153
  ],
152
- minZoom,
153
- maxZoom,
154
+ minZoom: this.minZoom,
155
+ maxZoom: this.maxZoom,
154
156
  loadOptions: {
155
157
  terrain: {
156
158
  skirtHeight: 2000,
@@ -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';
10
+ import LZWDecoder from './lzw.js';
11
11
 
12
12
  // Bitmap styling
13
- import GeoImage, { GeoImageOptions } from '../geoimage/geoimage'; // TODO: remove absolute path
13
+ import GeoImage, { GeoImageOptions } from '../geoimage/geoimage.ts'; // TODO: remove absolute path
14
14
 
15
15
  const EARTH_CIRCUMFERENCE = 40075000.0;
16
16
  const EARTH_HALF_CIRCUMFERENCE = 20037500.0;
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
- import CogBitmapLayer from './cogbitmaplayer/CogBitmapLayer';
2
- import CogTerrainLayer from './cogterrainlayer/CogTerrainLayer';
3
- import cogtiles from './cogtiles/cogtiles';
4
- import GeoImage from './geoimage/geoimage';
1
+ import CogBitmapLayer from './cogbitmaplayer/CogBitmapLayer.ts';
2
+ import CogTerrainLayer from './cogterrainlayer/CogTerrainLayer.ts';
3
+ import cogtiles from './cogtiles/cogtiles.ts';
4
+ import GeoImage from './geoimage/geoimage.ts';
5
5
 
6
6
  export default {
7
7
  CogBitmapLayer,