ol 7.1.1-dev.1667574553768 → 7.1.1-dev.1667678878080
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/DataTile.d.ts +34 -11
- package/DataTile.d.ts.map +1 -1
- package/DataTile.js +84 -7
- package/dist/ol.js +2 -2
- package/dist/ol.js.map +1 -1
- package/package.json +1 -1
- package/reproj/DataTile.d.ts.map +1 -1
- package/reproj/DataTile.js +11 -2
- package/source/DataTile.d.ts +2 -0
- package/source/DataTile.d.ts.map +1 -1
- package/source/DataTile.js +1 -0
- package/util.js +1 -1
- package/webgl/TileTexture.d.ts +19 -2
- package/webgl/TileTexture.d.ts.map +1 -1
- package/webgl/TileTexture.js +89 -42
package/package.json
CHANGED
package/reproj/DataTile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTile.d.ts","sourceRoot":"","sources":["DataTile.js"],"names":[],"mappings":";gCAoBsB,MAAM,QAAE,MAAM,QAAE,MAAM,QAAE,MAAM,KAAI,OAAO,gBAAgB,EAAE,OAAO;;;;;gBAK1E,OAAO,uBAAuB,EAAE,OAAO;;;;oBACvC,OAAO,yBAAyB,EAAE,OAAO;;;;gBACzC,OAAO,uBAAuB,EAAE,OAAO;;;;oBACvC,OAAO,yBAAyB,EAAE,OAAO;;;;eACzC,OAAO,iBAAiB,EAAE,SAAS;;;;;;;;gBAEnC,MAAM;;;;YACN,MAAM;;;;qBACN,UAAU;;;;;;;;;;;;;;;;AAdxB;;GAEG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;GAKG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EA2LjB;IAjLC;;;OAGG;IACH,oBAAqC;IAErC;;;OAGG;IACH,gBAA6B;IAE7B;;;OAGG;IACH,oBAAuB;IAEvB;;;OAGG;IACH,qBAAwB;IAExB;;;OAGG;IACH,oBAA4B;IAE5B;;;OAGG;IACH,wBAA6C;IAE7C;;;OAGG;IACH,wBAA6C;IAE7C;;;OAGG;IACH,0BAAsE;IAEtE;;;OAGG;IACH,qBAAsB;IAEtB;;;OAGG;IACH,6BAAgC;IAEhC;;;OAGG;IACH,iBAAiB;IAqDjB;;;OAGG;IACH,uBAOC;IA2EH;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"DataTile.d.ts","sourceRoot":"","sources":["DataTile.js"],"names":[],"mappings":";gCAoBsB,MAAM,QAAE,MAAM,QAAE,MAAM,QAAE,MAAM,KAAI,OAAO,gBAAgB,EAAE,OAAO;;;;;gBAK1E,OAAO,uBAAuB,EAAE,OAAO;;;;oBACvC,OAAO,yBAAyB,EAAE,OAAO;;;;gBACzC,OAAO,uBAAuB,EAAE,OAAO;;;;oBACvC,OAAO,yBAAyB,EAAE,OAAO;;;;eACzC,OAAO,iBAAiB,EAAE,SAAS;;;;;;;;gBAEnC,MAAM;;;;YACN,MAAM;;;;qBACN,UAAU;;;;;;;;;;;;;;;;AAdxB;;GAEG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;GAKG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EA2LjB;IAjLC;;;OAGG;IACH,oBAAqC;IAErC;;;OAGG;IACH,gBAA6B;IAE7B;;;OAGG;IACH,oBAAuB;IAEvB;;;OAGG;IACH,qBAAwB;IAExB;;;OAGG;IACH,oBAA4B;IAE5B;;;OAGG;IACH,wBAA6C;IAE7C;;;OAGG;IACH,wBAA6C;IAE7C;;;OAGG;IACH,0BAAsE;IAEtE;;;OAGG;IACH,qBAAsB;IAEtB;;;OAGG;IACH,6BAAgC;IAEhC;;;OAGG;IACH,iBAAiB;IAqDjB;;;OAGG;IACH,uBAOC;IA2EH;;OAEG;IACH,mBAoKC;IAyDD;;OAEG;IACH,yBAGC;CACF"}
|
package/reproj/DataTile.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {ERROR_THRESHOLD} from './common.js';
|
|
5
5
|
|
|
6
|
-
import DataTile from '../DataTile.js';
|
|
6
|
+
import DataTile, {asArrayLike, asImageLike, toArray} from '../DataTile.js';
|
|
7
7
|
import EventType from '../events/EventType.js';
|
|
8
8
|
import TileState from '../TileState.js';
|
|
9
9
|
import Triangulation from './Triangulation.js';
|
|
@@ -271,7 +271,16 @@ class ReprojDataTile extends DataTile {
|
|
|
271
271
|
}
|
|
272
272
|
const size = tile.getSize();
|
|
273
273
|
const gutter = this.gutter_;
|
|
274
|
-
|
|
274
|
+
/**
|
|
275
|
+
* @type {import("../DataTile.js").ArrayLike}
|
|
276
|
+
*/
|
|
277
|
+
let tileData;
|
|
278
|
+
const arrayData = asArrayLike(tile.getData());
|
|
279
|
+
if (arrayData) {
|
|
280
|
+
tileData = arrayData;
|
|
281
|
+
} else {
|
|
282
|
+
tileData = toArray(asImageLike(tile.getData()));
|
|
283
|
+
}
|
|
275
284
|
const pixelSize = [size[0] + 2 * gutter, size[1] + 2 * gutter];
|
|
276
285
|
const isFloat = tileData instanceof Float32Array;
|
|
277
286
|
const pixelCount = pixelSize[0] * pixelSize[1];
|
package/source/DataTile.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type Options = {
|
|
|
8
8
|
/**
|
|
9
9
|
* Data loader. Called with z, x, and y tile coordinates.
|
|
10
10
|
* Returns {@link import ("../DataTile.js").Data data} for a tile or a promise for the same.
|
|
11
|
+
* For loaders that generate images, the promise should not resolve until the image is loaded.
|
|
11
12
|
*/
|
|
12
13
|
loader?: Loader | undefined;
|
|
13
14
|
/**
|
|
@@ -84,6 +85,7 @@ export type Options = {
|
|
|
84
85
|
* @typedef {Object} Options
|
|
85
86
|
* @property {Loader} [loader] Data loader. Called with z, x, and y tile coordinates.
|
|
86
87
|
* Returns {@link import("../DataTile.js").Data data} for a tile or a promise for the same.
|
|
88
|
+
* For loaders that generate images, the promise should not resolve until the image is loaded.
|
|
87
89
|
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
|
|
88
90
|
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
|
|
89
91
|
* @property {number} [maxZoom=42] Optional max zoom level. Not used if `tileGrid` is provided.
|
package/source/DataTile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTile.d.ts","sourceRoot":"","sources":["DataTile.js"],"names":[],"mappings":";;;;;4BAwBsB,MAAM,QAAE,MAAM,QAAE,MAAM,KAAI,CAAC,OAAO,gBAAgB,EAAE,IAAI,GAAC,QAAQ,OAAO,gBAAgB,EAAE,IAAI,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"DataTile.d.ts","sourceRoot":"","sources":["DataTile.js"],"names":[],"mappings":";;;;;4BAwBsB,MAAM,QAAE,MAAM,QAAE,MAAM,KAAI,CAAC,OAAO,gBAAgB,EAAE,IAAI,GAAC,QAAQ,OAAO,gBAAgB,EAAE,IAAI,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkBxG,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AArBjD;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;GAMG;AACH;IACE;;OAEG;IACH,qBAFW,OAAO,EA6EjB;IA/CC;;;OAGG;IACH,gBAAgE;IAEhE;;;OAGG;IACH,kBAAmE;IAEnE;;;OAGG;IACH,mBAAsB;IAEtB;;;OAGG;IACH,yBAA0B;IAE1B;;OAEG;IACH,gBAA6B;IAmL/B;;;OAGG;IACH,yBAFW,OAAO,oBAAoB,EAAE,OAAO,QAsB9C;IAvMC;;OAEG;IACH,WAFU,MAAM,CAEwD;IAExE;;;OAGG;IACH,+BAAgC;IAEhC;;;OAGG;IACH,gCAAiC;IAGnC;;;;;OAKG;IACH,kCAFW,MAAM,OAAO,YAAY,EAAE,IAAI,CAAC,QAI1C;IAED;;;;;;OAMG;IACH,yBAHW,MAAM,GACL,OAAO,YAAY,EAAE,IAAI,CAWpC;IAeD;;;OAGG;IACH,4BAHW,MAAM,QAKhB;IAED;;;;;;;OAOG;IACH,kBAPW,MAAM,KACN,MAAM,KACN,MAAM,cACN,OAAO,uBAAuB,EAAE,OAAO,cACvC,OAAO,uBAAuB,EAAE,OAAO,GACrC,QAAQ,CAmDpB;IAED;;;;;;;OAOG;IACH,WAPW,MAAM,KACN,MAAM,KACN,MAAM,cACN,MAAM,cACN,OAAO,uBAAuB,EAAE,OAAO,GACrC,QAAQ,CAyCpB;IA8CD;;;;;;;;;;;OAWG;IACH,qCAJW,OAAO,YAAY,EAAE,cAAc,YACnC,OAAO,yBAAyB,EAAE,OAAO,QAWnD;CAyCF"}
|
package/source/DataTile.js
CHANGED
|
@@ -29,6 +29,7 @@ import {toSize} from '../size.js';
|
|
|
29
29
|
* @typedef {Object} Options
|
|
30
30
|
* @property {Loader} [loader] Data loader. Called with z, x, and y tile coordinates.
|
|
31
31
|
* Returns {@link import("../DataTile.js").Data data} for a tile or a promise for the same.
|
|
32
|
+
* For loaders that generate images, the promise should not resolve until the image is loaded.
|
|
32
33
|
* @property {import("./Source.js").AttributionLike} [attributions] Attributions.
|
|
33
34
|
* @property {boolean} [attributionsCollapsible=true] Attributions are collapsible.
|
|
34
35
|
* @property {number} [maxZoom=42] Optional max zoom level. Not used if `tileGrid` is provided.
|
package/util.js
CHANGED
package/webgl/TileTexture.d.ts
CHANGED
|
@@ -71,13 +71,30 @@ declare class TileTexture extends EventTarget {
|
|
|
71
71
|
setTile(tile: TileType): void;
|
|
72
72
|
loaded: boolean | undefined;
|
|
73
73
|
uploadTile_(): void;
|
|
74
|
+
/**
|
|
75
|
+
* @param {import("../DataTile.js").ImageLike} image The image.
|
|
76
|
+
* @param {number} renderCol The column index (in rendered tile space).
|
|
77
|
+
* @param {number} renderRow The row index (in rendered tile space).
|
|
78
|
+
* @return {Uint8ClampedArray|null} The data.
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
private getImagePixelData_;
|
|
82
|
+
/**
|
|
83
|
+
* @param {import("../DataTile.js").ArrayLike} data The data.
|
|
84
|
+
* @param {import("../size.js").Size} sourceSize The size.
|
|
85
|
+
* @param {number} renderCol The column index (in rendered tile space).
|
|
86
|
+
* @param {number} renderRow The row index (in rendered tile space).
|
|
87
|
+
* @return {import("../DataTile.js").ArrayLike|null} The data.
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
private getArrayPixelData_;
|
|
74
91
|
/**
|
|
75
92
|
* Get data for a pixel. If the tile is not loaded, null is returned.
|
|
76
93
|
* @param {number} renderCol The column index (in rendered tile space).
|
|
77
94
|
* @param {number} renderRow The row index (in rendered tile space).
|
|
78
|
-
* @return {import("../DataTile.js").
|
|
95
|
+
* @return {import("../DataTile.js").ArrayLike|null} The data.
|
|
79
96
|
*/
|
|
80
|
-
getPixelData(renderCol: number, renderRow: number): import("../DataTile.js").
|
|
97
|
+
getPixelData(renderCol: number, renderRow: number): import("../DataTile.js").ArrayLike | null;
|
|
81
98
|
}
|
|
82
99
|
import ImageTile from "../ImageTile.js";
|
|
83
100
|
import ReprojTile from "../reproj/Tile.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileTexture.d.ts","sourceRoot":"","sources":["TileTexture.js"],"names":[],"mappings":";uBAoIa,OAAO,gBAAgB,EAAE,OAAO,GAAC,SAAS,GAAC,UAAU;;;;;UAKpD,QAAQ;;;;UACR,OAAO,yBAAyB,EAAE,OAAO;;;;YACzC,OAAO,oBAAoB,EAAE,OAAO;;;;;;AARlD;;GAEG;AAEH;;;;;;GAMG;AAEH;IACE;;OAEG;IACH,qBAFW,OAAO,EA4DjB;IAvDC;;OAEG;IACH,MAFU,QAAQ,CAET;IAET;;OAEG;IACH,UAFU,MAAM,YAAY,CAAC,CAEX;
|
|
1
|
+
{"version":3,"file":"TileTexture.d.ts","sourceRoot":"","sources":["TileTexture.js"],"names":[],"mappings":";uBAoIa,OAAO,gBAAgB,EAAE,OAAO,GAAC,SAAS,GAAC,UAAU;;;;;UAKpD,QAAQ;;;;UACR,OAAO,yBAAyB,EAAE,OAAO;;;;YACzC,OAAO,oBAAoB,EAAE,OAAO;;;;;;AARlD;;GAEG;AAEH;;;;;;GAMG;AAEH;IACE;;OAEG;IACH,qBAFW,OAAO,EA4DjB;IAvDC;;OAEG;IACH,MAFU,QAAQ,CAET;IAET;;OAEG;IACH,UAFU,MAAM,YAAY,CAAC,CAEX;IA8KpB,0BAMC;IAjLC;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,gBAAkC;IAElC;;OAEG;IACH,WAFU,MAAM,CAEI;IAEpB;;;OAGG;IACH,gBAA6B;IAe7B;;OAEG;IACH,QAFU,gBAAgB,CAEN;IAKtB;;OAEG;IACH,cAFW,QAAQ,QAsBlB;IAbG,4BAAkD;IAetD,oBAkGC;IAmBD;;;;;;OAMG;IACH,2BAgCC;IAED;;;;;;;OAOG;IACH,2BA0BC;IAED;;;;;OAKG;IACH,wBAJW,MAAM,aACN,MAAM,GACL,OAAO,gBAAgB,EAAE,SAAS,GAAC,IAAI,CAuBlD;CACF"}
|
package/webgl/TileTexture.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module ol/webgl/TileTexture
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import DataTile from '../DataTile.js';
|
|
5
|
+
import DataTile, {asArrayLike, asImageLike} from '../DataTile.js';
|
|
6
6
|
import EventTarget from '../events/Target.js';
|
|
7
7
|
import EventType from '../events/EventType.js';
|
|
8
8
|
import ImageTile from '../ImageTile.js';
|
|
@@ -30,7 +30,7 @@ function bindAndConfigure(gl, texture, interpolate) {
|
|
|
30
30
|
/**
|
|
31
31
|
* @param {WebGLRenderingContext} gl The WebGL context.
|
|
32
32
|
* @param {WebGLTexture} texture The texture.
|
|
33
|
-
* @param {
|
|
33
|
+
* @param {import("../DataTile.js").ImageLike} image The image.
|
|
34
34
|
* @param {boolean} interpolate Interpolate when resampling.
|
|
35
35
|
*/
|
|
36
36
|
function uploadImageTexture(gl, texture, image, interpolate) {
|
|
@@ -42,7 +42,7 @@ function uploadImageTexture(gl, texture, image, interpolate) {
|
|
|
42
42
|
/**
|
|
43
43
|
* @param {import("./Helper.js").default} helper The WebGL helper.
|
|
44
44
|
* @param {WebGLTexture} texture The texture.
|
|
45
|
-
* @param {import("../DataTile.js").
|
|
45
|
+
* @param {import("../DataTile.js").ArrayLike} data The pixel data.
|
|
46
46
|
* @param {import("../size.js").Size} size The pixel size.
|
|
47
47
|
* @param {number} bandCount The band count.
|
|
48
48
|
* @param {boolean} interpolate Interpolate when resampling.
|
|
@@ -235,20 +235,33 @@ class TileTexture extends EventTarget {
|
|
|
235
235
|
const gl = helper.getGL();
|
|
236
236
|
const tile = this.tile;
|
|
237
237
|
|
|
238
|
+
/**
|
|
239
|
+
* @type {import("../DataTile.js").Data}
|
|
240
|
+
*/
|
|
241
|
+
let data;
|
|
242
|
+
|
|
238
243
|
if (tile instanceof ImageTile || tile instanceof ReprojTile) {
|
|
244
|
+
data = tile.getImage();
|
|
245
|
+
} else {
|
|
246
|
+
data = tile.getData();
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const image = asImageLike(data);
|
|
250
|
+
if (image) {
|
|
239
251
|
const texture = gl.createTexture();
|
|
240
252
|
this.textures.push(texture);
|
|
241
253
|
this.bandCount = 4;
|
|
242
|
-
uploadImageTexture(gl, texture,
|
|
254
|
+
uploadImageTexture(gl, texture, image, tile.interpolate);
|
|
243
255
|
return;
|
|
244
256
|
}
|
|
245
257
|
|
|
246
|
-
|
|
258
|
+
data = asArrayLike(data);
|
|
259
|
+
|
|
260
|
+
const sourceTileSize = /** @type {DataTile} */ (tile).getSize();
|
|
247
261
|
const pixelSize = [
|
|
248
262
|
sourceTileSize[0] + 2 * this.gutter_,
|
|
249
263
|
sourceTileSize[1] + 2 * this.gutter_,
|
|
250
264
|
];
|
|
251
|
-
const data = tile.getData();
|
|
252
265
|
const isFloat = data instanceof Float32Array;
|
|
253
266
|
const pixelCount = pixelSize[0] * pixelSize[1];
|
|
254
267
|
const DataType = isFloat ? Float32Array : Uint8Array;
|
|
@@ -335,53 +348,22 @@ class TileTexture extends EventTarget {
|
|
|
335
348
|
}
|
|
336
349
|
|
|
337
350
|
/**
|
|
338
|
-
*
|
|
351
|
+
* @param {import("../DataTile.js").ImageLike} image The image.
|
|
339
352
|
* @param {number} renderCol The column index (in rendered tile space).
|
|
340
353
|
* @param {number} renderRow The row index (in rendered tile space).
|
|
341
|
-
* @return {
|
|
354
|
+
* @return {Uint8ClampedArray|null} The data.
|
|
355
|
+
* @private
|
|
342
356
|
*/
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
return null;
|
|
346
|
-
}
|
|
357
|
+
getImagePixelData_(image, renderCol, renderRow) {
|
|
358
|
+
const gutter = this.gutter_;
|
|
347
359
|
const renderWidth = this.renderSize_[0];
|
|
348
360
|
const renderHeight = this.renderSize_[1];
|
|
349
|
-
const gutter = this.gutter_;
|
|
350
|
-
|
|
351
|
-
if (this.tile instanceof DataTile) {
|
|
352
|
-
const sourceSize = this.tile.getSize();
|
|
353
|
-
|
|
354
|
-
const sourceWidthWithoutGutter = sourceSize[0];
|
|
355
|
-
const sourceHeightWithoutGutter = sourceSize[1];
|
|
356
|
-
const sourceWidth = sourceWidthWithoutGutter + 2 * gutter;
|
|
357
|
-
const sourceHeight = sourceHeightWithoutGutter + 2 * gutter;
|
|
358
|
-
|
|
359
|
-
const sourceCol =
|
|
360
|
-
gutter +
|
|
361
|
-
Math.floor(sourceWidthWithoutGutter * (renderCol / renderWidth));
|
|
362
|
-
|
|
363
|
-
const sourceRow =
|
|
364
|
-
gutter +
|
|
365
|
-
Math.floor(sourceHeightWithoutGutter * (renderRow / renderHeight));
|
|
366
|
-
|
|
367
|
-
const data = this.tile.getData();
|
|
368
|
-
if (data instanceof DataView) {
|
|
369
|
-
const bytesPerPixel = data.byteLength / (sourceWidth * sourceHeight);
|
|
370
|
-
const offset = bytesPerPixel * (sourceRow * sourceWidth + sourceCol);
|
|
371
|
-
const buffer = data.buffer.slice(offset, offset + bytesPerPixel);
|
|
372
|
-
return new DataView(buffer);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
const offset = this.bandCount * (sourceRow * sourceWidth + sourceCol);
|
|
376
|
-
return data.slice(offset, offset + this.bandCount);
|
|
377
|
-
}
|
|
378
361
|
|
|
379
362
|
if (!pixelContext) {
|
|
380
363
|
createPixelContext();
|
|
381
364
|
}
|
|
382
365
|
pixelContext.clearRect(0, 0, 1, 1);
|
|
383
366
|
|
|
384
|
-
const image = this.tile.getImage();
|
|
385
367
|
const sourceWidth = image.width;
|
|
386
368
|
const sourceHeight = image.height;
|
|
387
369
|
|
|
@@ -405,6 +387,71 @@ class TileTexture extends EventTarget {
|
|
|
405
387
|
}
|
|
406
388
|
return data;
|
|
407
389
|
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* @param {import("../DataTile.js").ArrayLike} data The data.
|
|
393
|
+
* @param {import("../size.js").Size} sourceSize The size.
|
|
394
|
+
* @param {number} renderCol The column index (in rendered tile space).
|
|
395
|
+
* @param {number} renderRow The row index (in rendered tile space).
|
|
396
|
+
* @return {import("../DataTile.js").ArrayLike|null} The data.
|
|
397
|
+
* @private
|
|
398
|
+
*/
|
|
399
|
+
getArrayPixelData_(data, sourceSize, renderCol, renderRow) {
|
|
400
|
+
const gutter = this.gutter_;
|
|
401
|
+
const renderWidth = this.renderSize_[0];
|
|
402
|
+
const renderHeight = this.renderSize_[1];
|
|
403
|
+
|
|
404
|
+
const sourceWidthWithoutGutter = sourceSize[0];
|
|
405
|
+
const sourceHeightWithoutGutter = sourceSize[1];
|
|
406
|
+
const sourceWidth = sourceWidthWithoutGutter + 2 * gutter;
|
|
407
|
+
const sourceHeight = sourceHeightWithoutGutter + 2 * gutter;
|
|
408
|
+
|
|
409
|
+
const sourceCol =
|
|
410
|
+
gutter + Math.floor(sourceWidthWithoutGutter * (renderCol / renderWidth));
|
|
411
|
+
|
|
412
|
+
const sourceRow =
|
|
413
|
+
gutter +
|
|
414
|
+
Math.floor(sourceHeightWithoutGutter * (renderRow / renderHeight));
|
|
415
|
+
|
|
416
|
+
if (data instanceof DataView) {
|
|
417
|
+
const bytesPerPixel = data.byteLength / (sourceWidth * sourceHeight);
|
|
418
|
+
const offset = bytesPerPixel * (sourceRow * sourceWidth + sourceCol);
|
|
419
|
+
const buffer = data.buffer.slice(offset, offset + bytesPerPixel);
|
|
420
|
+
return new DataView(buffer);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const offset = this.bandCount * (sourceRow * sourceWidth + sourceCol);
|
|
424
|
+
return data.slice(offset, offset + this.bandCount);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Get data for a pixel. If the tile is not loaded, null is returned.
|
|
429
|
+
* @param {number} renderCol The column index (in rendered tile space).
|
|
430
|
+
* @param {number} renderRow The row index (in rendered tile space).
|
|
431
|
+
* @return {import("../DataTile.js").ArrayLike|null} The data.
|
|
432
|
+
*/
|
|
433
|
+
getPixelData(renderCol, renderRow) {
|
|
434
|
+
if (!this.loaded) {
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
if (this.tile instanceof DataTile) {
|
|
439
|
+
const data = this.tile.getData();
|
|
440
|
+
const arrayData = asArrayLike(data);
|
|
441
|
+
if (arrayData) {
|
|
442
|
+
const sourceSize = this.tile.getSize();
|
|
443
|
+
return this.getArrayPixelData_(
|
|
444
|
+
arrayData,
|
|
445
|
+
sourceSize,
|
|
446
|
+
renderCol,
|
|
447
|
+
renderRow
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
return this.getImagePixelData_(asImageLike(data), renderCol, renderRow);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return this.getImagePixelData_(this.tile.getImage(), renderCol, renderRow);
|
|
454
|
+
}
|
|
408
455
|
}
|
|
409
456
|
|
|
410
457
|
export default TileTexture;
|