@deck.gl/aggregation-layers 9.0.0-alpha.7 → 9.0.0-beta.2
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/dist/dist.dev.js +3345 -340
- package/dist/es5/aggregation-layer.js +3 -1
- package/dist/es5/aggregation-layer.js.map +1 -1
- package/dist/es5/contour-layer/contour-layer.js +2 -2
- package/dist/es5/contour-layer/contour-layer.js.map +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js +1 -1
- package/dist/es5/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/es5/grid-layer/grid-layer.js +2 -2
- package/dist/es5/grid-layer/grid-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js +0 -15
- package/dist/es5/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/es5/heatmap-layer/heatmap-layer.js +103 -97
- package/dist/es5/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/max-vs.glsl.js +1 -1
- package/dist/es5/heatmap-layer/triangle-layer-fragment.glsl.js +1 -1
- package/dist/es5/heatmap-layer/triangle-layer.js +26 -27
- package/dist/es5/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/es5/heatmap-layer/weights-vs.glsl.js +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer.js +1 -1
- package/dist/es5/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/dist/es5/utils/cpu-aggregator.js.map +1 -1
- package/dist/es5/utils/resource-utils.js +0 -2
- package/dist/es5/utils/resource-utils.js.map +1 -1
- package/dist/esm/aggregation-layer.js +3 -1
- package/dist/esm/aggregation-layer.js.map +1 -1
- package/dist/esm/contour-layer/contour-layer.js +2 -2
- package/dist/esm/contour-layer/contour-layer.js.map +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js +1 -1
- package/dist/esm/gpu-grid-layer/gpu-grid-layer.js.map +1 -1
- package/dist/esm/grid-layer/grid-layer.js +2 -2
- package/dist/esm/grid-layer/grid-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer-utils.js +0 -13
- package/dist/esm/heatmap-layer/heatmap-layer-utils.js.map +1 -1
- package/dist/esm/heatmap-layer/heatmap-layer.js +99 -87
- package/dist/esm/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/max-vs.glsl.js +11 -5
- package/dist/esm/heatmap-layer/max-vs.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js +2 -2
- package/dist/esm/heatmap-layer/triangle-layer-fragment.glsl.js.map +1 -1
- package/dist/esm/heatmap-layer/triangle-layer.js +21 -23
- package/dist/esm/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/esm/heatmap-layer/weights-vs.glsl.js +4 -2
- package/dist/esm/heatmap-layer/weights-vs.glsl.js.map +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer.js +1 -1
- package/dist/esm/screen-grid-layer/screen-grid-layer.js.map +1 -1
- package/dist/esm/utils/cpu-aggregator.js.map +1 -1
- package/dist/esm/utils/resource-utils.js +0 -1
- package/dist/esm/utils/resource-utils.js.map +1 -1
- package/dist.min.js +85 -75
- package/package.json +7 -7
- package/src/aggregation-layer.ts +3 -1
- package/src/contour-layer/contour-layer.ts +3 -3
- package/src/gpu-grid-layer/gpu-grid-layer.ts +1 -1
- package/src/grid-layer/grid-layer.ts +4 -2
- package/src/heatmap-layer/heatmap-layer-utils.ts +0 -23
- package/src/heatmap-layer/heatmap-layer.ts +87 -105
- package/src/heatmap-layer/max-vs.glsl.ts +11 -5
- package/src/heatmap-layer/triangle-layer-fragment.glsl.ts +2 -2
- package/src/heatmap-layer/triangle-layer.ts +17 -24
- package/src/heatmap-layer/weights-vs.glsl.ts +4 -2
- package/src/screen-grid-layer/screen-grid-layer.ts +1 -1
- package/src/utils/cpu-aggregator.ts +1 -1
- package/src/utils/resource-utils.ts +2 -8
- package/typed/aggregation-layer.d.ts.map +1 -1
- package/typed/contour-layer/contour-layer.d.ts.map +1 -1
- package/typed/grid-layer/grid-layer.d.ts.map +1 -1
- package/typed/heatmap-layer/heatmap-layer-utils.d.ts +0 -9
- package/typed/heatmap-layer/heatmap-layer-utils.d.ts.map +1 -1
- package/typed/heatmap-layer/heatmap-layer.d.ts +4 -4
- package/typed/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/typed/heatmap-layer/max-vs.glsl.d.ts +1 -1
- package/typed/heatmap-layer/max-vs.glsl.d.ts.map +1 -1
- package/typed/heatmap-layer/triangle-layer-fragment.glsl.d.ts +1 -1
- package/typed/heatmap-layer/triangle-layer.d.ts +10 -2
- package/typed/heatmap-layer/triangle-layer.d.ts.map +1 -1
- package/typed/heatmap-layer/weights-vs.glsl.d.ts +1 -1
- package/typed/heatmap-layer/weights-vs.glsl.d.ts.map +1 -1
- package/typed/utils/resource-utils.d.ts.map +1 -1
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { getBounds, boundsContain, packVertices, scaleToAspectRatio, getTextureCoordinates
|
|
1
|
+
import { getBounds, boundsContain, packVertices, scaleToAspectRatio, getTextureCoordinates } from './heatmap-layer-utils';
|
|
2
2
|
import { GL } from '@luma.gl/constants';
|
|
3
3
|
import { TextureTransform } from '@luma.gl/engine';
|
|
4
|
-
import { withGLParameters } from '@luma.gl/webgl';
|
|
5
4
|
import { AttributeManager, COORDINATE_SYSTEM, log } from '@deck.gl/core';
|
|
6
5
|
import TriangleLayer from './triangle-layer';
|
|
7
6
|
import AggregationLayer from '../aggregation-layer';
|
|
8
7
|
import { defaultColorRange, colorRangeToFlatArray } from '../utils/color-utils';
|
|
9
8
|
import weightsVs from './weights-vs.glsl';
|
|
10
9
|
import weightsFs from './weights-fs.glsl';
|
|
11
|
-
import
|
|
12
|
-
import
|
|
10
|
+
import maxVs from './max-vs.glsl';
|
|
11
|
+
import maxFs from './max-fs.glsl';
|
|
13
12
|
const RESOLUTION = 2;
|
|
14
13
|
const TEXTURE_PROPS = {
|
|
15
14
|
format: 'rgba8unorm',
|
|
16
15
|
mipmaps: false,
|
|
17
16
|
sampler: {
|
|
18
|
-
minFilter: '
|
|
19
|
-
magFilter: '
|
|
17
|
+
minFilter: 'linear',
|
|
18
|
+
magFilter: 'linear',
|
|
20
19
|
addressModeU: 'clamp-to-edge',
|
|
21
20
|
addressModeV: 'clamp-to-edge'
|
|
22
21
|
}
|
|
@@ -194,7 +193,7 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
194
193
|
maxTexture: maxWeightsTexture,
|
|
195
194
|
colorTexture,
|
|
196
195
|
aggregationMode: AGGREGATION_MODE[aggregation] || 0,
|
|
197
|
-
|
|
196
|
+
weightsTexture,
|
|
198
197
|
intensity,
|
|
199
198
|
threshold,
|
|
200
199
|
colorDomain
|
|
@@ -257,21 +256,18 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
257
256
|
_createTextures() {
|
|
258
257
|
const {
|
|
259
258
|
textureSize,
|
|
260
|
-
format
|
|
261
|
-
type
|
|
259
|
+
format
|
|
262
260
|
} = this.state;
|
|
263
261
|
this.setState({
|
|
264
|
-
weightsTexture: this.context.device.createTexture({
|
|
262
|
+
weightsTexture: this.context.device.createTexture({ ...TEXTURE_PROPS,
|
|
265
263
|
width: textureSize,
|
|
266
264
|
height: textureSize,
|
|
267
|
-
format
|
|
268
|
-
type,
|
|
269
|
-
...TEXTURE_PROPS
|
|
265
|
+
format
|
|
270
266
|
}),
|
|
271
|
-
maxWeightsTexture: this.context.device.createTexture({
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
267
|
+
maxWeightsTexture: this.context.device.createTexture({ ...TEXTURE_PROPS,
|
|
268
|
+
width: 1,
|
|
269
|
+
height: 1,
|
|
270
|
+
format
|
|
275
271
|
})
|
|
276
272
|
});
|
|
277
273
|
}
|
|
@@ -303,48 +299,44 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
303
299
|
} = this.props;
|
|
304
300
|
const textureSize = Math.min(weightsTextureSize, device.limits.maxTextureDimension2D);
|
|
305
301
|
const floatTargetSupport = FLOAT_TARGET_FEATURES.every(feature => device.features.has(feature));
|
|
306
|
-
const
|
|
307
|
-
format,
|
|
308
|
-
type
|
|
309
|
-
} = getTextureParams({
|
|
310
|
-
device,
|
|
311
|
-
floatTargetSupport
|
|
312
|
-
});
|
|
302
|
+
const format = floatTargetSupport ? 'rgba32float' : 'rgba8unorm';
|
|
313
303
|
const weightsScale = floatTargetSupport ? 1 : 1 / 255;
|
|
314
304
|
this.setState({
|
|
315
305
|
textureSize,
|
|
316
306
|
format,
|
|
317
|
-
type,
|
|
318
307
|
weightsScale
|
|
319
308
|
});
|
|
320
309
|
|
|
321
310
|
if (!floatTargetSupport) {
|
|
322
|
-
log.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported,
|
|
311
|
+
log.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)();
|
|
323
312
|
}
|
|
324
313
|
}
|
|
325
314
|
|
|
326
|
-
|
|
327
|
-
return super.getShaders(type === 'max-weights-transform' ? {
|
|
328
|
-
vs: vsMax,
|
|
329
|
-
_fs: fsMax
|
|
330
|
-
} : {
|
|
331
|
-
vs: weightsVs,
|
|
332
|
-
_fs: weightsFs
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
_createWeightsTransform(shaders = {}) {
|
|
315
|
+
_createWeightsTransform(shaders) {
|
|
337
316
|
var _weightsTransform;
|
|
338
317
|
|
|
339
318
|
let {
|
|
340
319
|
weightsTransform
|
|
341
320
|
} = this.state;
|
|
342
|
-
|
|
321
|
+
const {
|
|
322
|
+
weightsTexture
|
|
323
|
+
} = this.state;
|
|
324
|
+
const attributeManager = this.getAttributeManager();
|
|
325
|
+
(_weightsTransform = weightsTransform) === null || _weightsTransform === void 0 ? void 0 : _weightsTransform.destroy();
|
|
343
326
|
weightsTransform = new TextureTransform(this.context.device, {
|
|
344
327
|
id: `${this.id}-weights-transform`,
|
|
328
|
+
bufferLayout: attributeManager.getBufferLayouts(),
|
|
345
329
|
vertexCount: 1,
|
|
346
|
-
targetTexture:
|
|
347
|
-
|
|
330
|
+
targetTexture: weightsTexture,
|
|
331
|
+
parameters: {
|
|
332
|
+
depthWriteEnabled: false,
|
|
333
|
+
blendColorOperation: 'add',
|
|
334
|
+
blendColorSrcFactor: 'one',
|
|
335
|
+
blendColorDstFactor: 'one',
|
|
336
|
+
blendAlphaSrcFactor: 'one',
|
|
337
|
+
blendAlphaDstFactor: 'one'
|
|
338
|
+
},
|
|
339
|
+
topology: 'point-list',
|
|
348
340
|
...shaders
|
|
349
341
|
});
|
|
350
342
|
this.setState({
|
|
@@ -355,61 +347,79 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
355
347
|
_setupResources() {
|
|
356
348
|
this._createTextures();
|
|
357
349
|
|
|
350
|
+
const {
|
|
351
|
+
device
|
|
352
|
+
} = this.context;
|
|
358
353
|
const {
|
|
359
354
|
textureSize,
|
|
360
355
|
weightsTexture,
|
|
361
356
|
maxWeightsTexture
|
|
362
357
|
} = this.state;
|
|
363
|
-
const weightsTransformShaders = this.getShaders(
|
|
358
|
+
const weightsTransformShaders = this.getShaders({
|
|
359
|
+
vs: weightsVs,
|
|
360
|
+
fs: weightsFs
|
|
361
|
+
});
|
|
364
362
|
|
|
365
363
|
this._createWeightsTransform(weightsTransformShaders);
|
|
366
364
|
|
|
367
|
-
const maxWeightsTransformShaders = this.getShaders(
|
|
368
|
-
|
|
365
|
+
const maxWeightsTransformShaders = this.getShaders({
|
|
366
|
+
vs: maxVs,
|
|
367
|
+
fs: maxFs
|
|
368
|
+
});
|
|
369
|
+
const maxWeightTransform = new TextureTransform(device, {
|
|
369
370
|
id: `${this.id}-max-weights-transform`,
|
|
370
|
-
|
|
371
|
+
bindings: {
|
|
371
372
|
inTexture: weightsTexture
|
|
372
373
|
},
|
|
373
|
-
|
|
374
|
-
|
|
374
|
+
uniforms: {
|
|
375
|
+
textureSize
|
|
376
|
+
},
|
|
377
|
+
targetTexture: maxWeightsTexture,
|
|
375
378
|
...maxWeightsTransformShaders,
|
|
376
|
-
|
|
379
|
+
vertexCount: textureSize * textureSize,
|
|
380
|
+
topology: 'point-list',
|
|
381
|
+
parameters: {
|
|
382
|
+
depthWriteEnabled: false,
|
|
383
|
+
blendColorOperation: 'max',
|
|
384
|
+
blendAlphaOperation: 'max',
|
|
385
|
+
blendColorSrcFactor: 'one',
|
|
386
|
+
blendColorDstFactor: 'one',
|
|
387
|
+
blendAlphaSrcFactor: 'one',
|
|
388
|
+
blendAlphaDstFactor: 'one'
|
|
389
|
+
}
|
|
377
390
|
});
|
|
378
391
|
this.setState({
|
|
379
392
|
weightsTexture,
|
|
380
393
|
maxWeightsTexture,
|
|
381
394
|
maxWeightTransform,
|
|
382
395
|
zoom: null,
|
|
383
|
-
triPositionBuffer:
|
|
384
|
-
byteLength: 48
|
|
385
|
-
accessor: {
|
|
386
|
-
size: 3
|
|
387
|
-
}
|
|
396
|
+
triPositionBuffer: device.createBuffer({
|
|
397
|
+
byteLength: 48
|
|
388
398
|
}),
|
|
389
|
-
triTexCoordBuffer:
|
|
390
|
-
byteLength: 48
|
|
391
|
-
accessor: {
|
|
392
|
-
size: 2
|
|
393
|
-
}
|
|
399
|
+
triTexCoordBuffer: device.createBuffer({
|
|
400
|
+
byteLength: 48
|
|
394
401
|
})
|
|
395
402
|
});
|
|
396
403
|
}
|
|
397
404
|
|
|
398
405
|
updateShaders(shaderOptions) {
|
|
399
|
-
this._createWeightsTransform(
|
|
406
|
+
this._createWeightsTransform({
|
|
407
|
+
vs: weightsVs,
|
|
408
|
+
fs: weightsFs,
|
|
409
|
+
...shaderOptions
|
|
410
|
+
});
|
|
400
411
|
}
|
|
401
412
|
|
|
402
413
|
_updateMaxWeightValue() {
|
|
403
414
|
const {
|
|
404
|
-
maxWeightTransform
|
|
415
|
+
maxWeightTransform,
|
|
416
|
+
textureSize
|
|
405
417
|
} = this.state;
|
|
406
418
|
maxWeightTransform.run({
|
|
407
419
|
parameters: {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
blendEquation: 32776
|
|
412
|
-
}
|
|
420
|
+
viewport: [0, 0, 1, 1]
|
|
421
|
+
},
|
|
422
|
+
clearColor: [0, 0, 0, 0]
|
|
413
423
|
});
|
|
414
424
|
}
|
|
415
425
|
|
|
@@ -464,6 +474,8 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
464
474
|
}
|
|
465
475
|
|
|
466
476
|
_updateColorTexture(opts) {
|
|
477
|
+
var _colorTexture;
|
|
478
|
+
|
|
467
479
|
const {
|
|
468
480
|
colorRange
|
|
469
481
|
} = opts.props;
|
|
@@ -472,17 +484,18 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
472
484
|
} = this.state;
|
|
473
485
|
const colors = colorRangeToFlatArray(colorRange, false, Uint8Array);
|
|
474
486
|
|
|
475
|
-
if (colorTexture) {
|
|
476
|
-
colorTexture.
|
|
477
|
-
data: colors
|
|
478
|
-
width: colorRange.length
|
|
487
|
+
if (colorTexture && ((_colorTexture = colorTexture) === null || _colorTexture === void 0 ? void 0 : _colorTexture.width) === colorRange.length) {
|
|
488
|
+
colorTexture.setSubImageData({
|
|
489
|
+
data: colors
|
|
479
490
|
});
|
|
480
491
|
} else {
|
|
481
|
-
|
|
492
|
+
var _colorTexture2;
|
|
493
|
+
|
|
494
|
+
(_colorTexture2 = colorTexture) === null || _colorTexture2 === void 0 ? void 0 : _colorTexture2.destroy();
|
|
495
|
+
colorTexture = this.context.device.createTexture({ ...TEXTURE_PROPS,
|
|
482
496
|
data: colors,
|
|
483
497
|
width: colorRange.length,
|
|
484
|
-
height: 1
|
|
485
|
-
...TEXTURE_PROPS
|
|
498
|
+
height: 1
|
|
486
499
|
});
|
|
487
500
|
}
|
|
488
501
|
|
|
@@ -519,30 +532,29 @@ export default class HeatmapLayer extends AggregationLayer {
|
|
|
519
532
|
this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;
|
|
520
533
|
}
|
|
521
534
|
|
|
535
|
+
const attributeManager = this.getAttributeManager();
|
|
536
|
+
const attributes = attributeManager.getAttributes();
|
|
537
|
+
const moduleSettings = this.getModuleSettings();
|
|
538
|
+
const positions = attributes.positions.buffer;
|
|
522
539
|
const uniforms = {
|
|
523
540
|
radiusPixels,
|
|
524
541
|
commonBounds,
|
|
525
542
|
textureWidth: textureSize,
|
|
526
543
|
weightsScale
|
|
527
544
|
};
|
|
528
|
-
|
|
529
|
-
|
|
545
|
+
const weights = attributes.weights.buffer;
|
|
546
|
+
weightsTransform.model.setAttributes({
|
|
547
|
+
positions,
|
|
548
|
+
weights
|
|
530
549
|
});
|
|
531
|
-
|
|
550
|
+
weightsTransform.model.setVertexCount(this.getNumInstances());
|
|
551
|
+
weightsTransform.model.setUniforms(uniforms);
|
|
552
|
+
weightsTransform.model.updateModuleSettings(moduleSettings);
|
|
553
|
+
weightsTransform.run({
|
|
554
|
+
parameters: {
|
|
555
|
+
viewport: [0, 0, textureSize, textureSize]
|
|
556
|
+
},
|
|
532
557
|
clearColor: [0, 0, 0, 0]
|
|
533
|
-
}, () => {
|
|
534
|
-
weightsTransform.run({
|
|
535
|
-
uniforms,
|
|
536
|
-
parameters: {
|
|
537
|
-
blend: true,
|
|
538
|
-
depthTest: false,
|
|
539
|
-
blendFunc: [1, 1],
|
|
540
|
-
blendEquation: 32774
|
|
541
|
-
},
|
|
542
|
-
clearRenderTarget: true,
|
|
543
|
-
attributes: this.getAttributes(),
|
|
544
|
-
moduleSettings: this.getModuleSettings()
|
|
545
|
-
});
|
|
546
558
|
});
|
|
547
559
|
|
|
548
560
|
this._updateMaxWeightValue();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/heatmap-layer/heatmap-layer.ts"],"names":["getBounds","boundsContain","packVertices","scaleToAspectRatio","getTextureCoordinates","getTextureParams","GL","TextureTransform","withGLParameters","AttributeManager","COORDINATE_SYSTEM","log","TriangleLayer","AggregationLayer","defaultColorRange","colorRangeToFlatArray","weightsVs","weightsFs","vsMax","fsMax","RESOLUTION","TEXTURE_PROPS","format","mipmaps","sampler","minFilter","magFilter","addressModeU","addressModeV","DEFAULT_COLOR_DOMAIN","AGGREGATION_MODE","SUM","MEAN","defaultProps","getPosition","type","value","x","position","getWeight","intensity","min","radiusPixels","max","colorRange","threshold","colorDomain","optional","aggregation","weightsTextureSize","debounceTimeout","REQUIRED_FEATURES","FLOAT_TARGET_FEATURES","DIMENSIONS","data","props","HeatmapLayer","state","initializeState","every","feature","context","device","features","has","setState","supported","error","id","initializeAggregationLayer","_setupTextureParams","_setupAttributes","_setupResources","shouldUpdateState","changeFlags","somethingChanged","updateState","opts","_updateHeatmapState","oldProps","_getChangeFlags","dataChanged","viewportChanged","boundsChanged","_updateBounds","_updateTextureRenderingBounds","clearTimeout","updateTimer","isWeightMapDirty","viewportZoomChanged","_debouncedUpdateWeightmap","_updateColorTexture","_updateWeightmap","zoom","viewport","renderLayers","weightsTexture","triPositionBuffer","triTexCoordBuffer","maxWeightsTexture","colorTexture","updateTriggers","TriangleLayerClass","getSubLayerClass","getSubLayerProps","coordinateSystem","DEFAULT","attributes","positions","texCoords","vertexCount","maxTexture","aggregationMode","texture","finalizeState","weightsTransform","maxWeightTransform","destroy","_getAttributeManager","stats","dimensions","isAttributeChanged","isAggregationDirty","compareAll","dimension","_createTextures","textureSize","createTexture","width","height","attributeManager","getAttributeManager","add","size","accessor","weights","positionAttributeName","Math","limits","maxTextureDimension2D","floatTargetSupport","weightsScale","warn","getShaders","vs","_fs","_createWeightsTransform","shaders","delete","targetTexture","targetTextureVarying","weightsTransformShaders","maxWeightsTransformShaders","_sourceTextures","inTexture","_targetTexture","_targetTextureVarying","elementCount","createBuffer","byteLength","updateShaders","shaderOptions","_updateMaxWeightValue","run","parameters","blend","depthTest","blendFunc","blendEquation","forceUpdate","viewportCorners","unproject","map","p","fround","visibleWorldBounds","newState","worldBounds","scaledCommonBounds","_worldToCommonBounds","_commonToWorldBounds","LNGLAT","normalizedCommonBounds","write","textureBounds","projectPosition","colors","Uint8Array","setImageData","length","commonBounds","useLayerCoordinateSystem","metersPerPixel","distanceScales","metersPerUnit","uniforms","textureWidth","update","getNumInstances","gl","clearColor","clearRenderTarget","getAttributes","moduleSettings","getModuleSettings","fromTimer","setTimeout","bind","minLong","minLat","maxLong","maxLat","offsetMode","LNGLAT_OFFSETS","METER_OFFSETS","offsetOriginCommon","coordinateOrigin","scale","bottomLeftCommon","topRightCommon","xMin","yMin","xMax","yMax","bottomLeftWorld","unprojectPosition","topRightWorld","slice","concat","layerName"],"mappings":"AAqBA,SACEA,SADF,EAEEC,aAFF,EAGEC,YAHF,EAIEC,kBAJF,EAKEC,qBALF,EAMEC,gBANF,QAOO,uBAPP;AASA,SAAQC,EAAR,QAAiB,oBAAjB;AACA,SAAQC,gBAAR,QAAsD,iBAAtD;AACA,SAAQC,gBAAR,QAA+B,gBAA/B;AACA,SAGEC,gBAHF,EAMEC,iBANF,EAUEC,GAVF,QAcO,eAdP;AAeA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,gBAAP,MAAsD,sBAAtD;AACA,SAAQC,iBAAR,EAA2BC,qBAA3B,QAAuD,sBAAvD;AACA,OAAOC,SAAP,MAAsB,mBAAtB;AACA,OAAOC,SAAP,MAAsB,mBAAtB;AACA,OAAOC,KAAP,MAAkB,eAAlB;AACA,OAAOC,KAAP,MAAkB,eAAlB;AAEA,MAAMC,UAAU,GAAG,CAAnB;AACA,MAAMC,aAA2B,GAAG;AAClCC,EAAAA,MAAM,EAAE,YAD0B;AAElCC,EAAAA,OAAO,EAAE,KAFyB;AAGlCC,EAAAA,OAAO,EAAE;AACPC,IAAAA,SAAS,EAAE,SADJ;AAEPC,IAAAA,SAAS,EAAE,SAFJ;AAGPC,IAAAA,YAAY,EAAE,eAHP;AAIPC,IAAAA,YAAY,EAAE;AAJP;AAHyB,CAApC;AAUA,MAAMC,oBAAoB,GAAG,CA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esContent":["// Copyright (c) 2015 - 2019 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n/* global setTimeout clearTimeout */\nimport {\n getBounds,\n boundsContain,\n packVertices,\n scaleToAspectRatio,\n getTextureCoordinates,\n getTextureParams\n} from './heatmap-layer-utils';\nimport {Buffer, DeviceFeature, Texture, TextureProps, TextureFormat} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {TextureTransform, TextureTransformProps} from '@luma.gl/engine';\nimport {withGLParameters} from '@luma.gl/webgl';\nimport {\n Accessor,\n AccessorFunction,\n AttributeManager,\n ChangeFlags,\n Color,\n COORDINATE_SYSTEM,\n Layer,\n LayerContext,\n LayersList,\n log,\n Position,\n UpdateParameters,\n DefaultProps\n} from '@deck.gl/core';\nimport TriangleLayer from './triangle-layer';\nimport AggregationLayer, {AggregationLayerProps} from '../aggregation-layer';\nimport {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';\nimport weightsVs from './weights-vs.glsl';\nimport weightsFs from './weights-fs.glsl';\nimport vsMax from './max-vs.glsl';\nimport fsMax from './max-fs.glsl';\n\nconst RESOLUTION = 2; // (number of common space pixels) / (number texels)\nconst TEXTURE_PROPS: TextureProps = {\n format: 'rgba8unorm',\n mipmaps: false,\n sampler: {\n minFilter: 'nearest',\n magFilter: 'nearest',\n addressModeU: 'clamp-to-edge',\n addressModeV: 'clamp-to-edge'\n }\n};\nconst DEFAULT_COLOR_DOMAIN = [0, 0];\nconst AGGREGATION_MODE = {\n SUM: 0,\n MEAN: 1\n};\n\nconst defaultProps: DefaultProps<HeatmapLayerProps> = {\n getPosition: {type: 'accessor', value: (x: any) => x.position},\n getWeight: {type: 'accessor', value: 1},\n intensity: {type: 'number', min: 0, value: 1},\n radiusPixels: {type: 'number', min: 1, max: 100, value: 50},\n colorRange: defaultColorRange,\n threshold: {type: 'number', min: 0, max: 1, value: 0.05},\n colorDomain: {type: 'array', value: null, optional: true},\n // 'SUM' or 'MEAN'\n aggregation: 'SUM',\n weightsTextureSize: {type: 'number', min: 128, max: 2048, value: 2048},\n debounceTimeout: {type: 'number', min: 0, max: 1000, value: 500}\n};\n\nconst REQUIRED_FEATURES: DeviceFeature[] = [\n 'blend-minmax-webgl1', // max weight calculation\n 'texture-formats-float32-webgl1' // weight-map as texture\n];\n\nconst FLOAT_TARGET_FEATURES: DeviceFeature[] = [\n 'texture-renderable-float32-webgl', // ability to render to float texture\n 'texture-blend-float-webgl1' // ability to blend when rendering to float texture\n];\n\nconst DIMENSIONS = {\n data: {\n props: ['radiusPixels']\n }\n};\n\nexport type HeatmapLayerProps<DataT = unknown> = _HeatmapLayerProps<DataT> &\n AggregationLayerProps<DataT>;\n\ntype _HeatmapLayerProps<DataT> = {\n /**\n * Radius of the circle in pixels, to which the weight of an object is distributed.\n *\n * @default 30\n */\n radiusPixels?: number;\n\n /**\n * Specified as an array of colors [color1, color2, ...].\n *\n * @default `6-class YlOrRd` - [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6)\n */\n colorRange?: Color[];\n\n /**\n * Value that is multiplied with the total weight at a pixel to obtain the final weight.\n *\n * @default 1\n */\n intensity?: number;\n\n /**\n * Ratio of the fading weight to the max weight, between `0` and `1`.\n *\n * For example, `0.1` affects all pixels with weight under 10% of the max.\n *\n * Ignored when `colorDomain` is specified.\n * @default 0.05\n */\n threshold?: number;\n\n /**\n * Controls how weight values are mapped to the `colorRange`, as an array of two numbers [`minValue`, `maxValue`].\n *\n * @default null\n */\n colorDomain?: [number, number] | null;\n\n /**\n * Defines the type of aggregation operation\n *\n * V valid values are 'SUM', 'MEAN'.\n *\n * @default 'SUM'\n */\n aggregation?: 'SUM' | 'MEAN';\n\n /**\n * Specifies the size of weight texture.\n * @default 2048\n */\n weightsTextureSize?: number;\n\n /**\n * Interval in milliseconds during which changes to the viewport don't trigger aggregation.\n *\n * @default 500\n */\n debounceTimeout?: number;\n\n /**\n * Method called to retrieve the position of each object.\n *\n * @default d => d.position\n */\n getPosition?: AccessorFunction<DataT, Position>;\n\n /**\n * The weight of each object.\n *\n * @default 1\n */\n getWeight?: Accessor<DataT, number>;\n};\n\n/** Visualizes the spatial distribution of data. */\nexport default class HeatmapLayer<\n DataT = any,\n ExtraPropsT extends {} = {}\n> extends AggregationLayer<DataT, ExtraPropsT & Required<_HeatmapLayerProps<DataT>>> {\n static layerName = 'HeatmapLayer';\n static defaultProps = defaultProps;\n\n state!: AggregationLayer<DataT>['state'] & {\n supported: boolean;\n colorDomain?: number[];\n isWeightMapDirty?: boolean;\n weightsTexture?: Texture;\n maxWeightsTexture?: Texture;\n colorTexture?: Texture;\n zoom?: number;\n worldBounds?: number[];\n normalizedCommonBounds?: number[];\n updateTimer?: any;\n triPositionBuffer?: Buffer;\n triTexCoordBuffer?: Buffer;\n weightsTransform?: TextureTransform;\n maxWeightTransform?: TextureTransform;\n textureSize: number;\n format: TextureFormat;\n type: GL;\n weightsScale: number;\n visibleWorldBounds: number[];\n viewportCorners: number[][];\n };\n\n initializeState() {\n if (!REQUIRED_FEATURES.every(feature => this.context.device.features.has(feature))) {\n this.setState({supported: false});\n log.error(`HeatmapLayer: ${this.id} is not supported on this browser`)();\n return;\n }\n super.initializeAggregationLayer(DIMENSIONS);\n this.setState({supported: true, colorDomain: DEFAULT_COLOR_DOMAIN});\n this._setupTextureParams();\n this._setupAttributes();\n this._setupResources();\n }\n\n shouldUpdateState({changeFlags}: UpdateParameters<this>) {\n // Need to be updated when viewport changes\n return changeFlags.somethingChanged;\n }\n\n /* eslint-disable max-statements,complexity */\n updateState(opts: UpdateParameters<this>) {\n if (!this.state.supported) {\n return;\n }\n super.updateState(opts);\n this._updateHeatmapState(opts);\n }\n\n _updateHeatmapState(opts: UpdateParameters<this>) {\n const {props, oldProps} = opts;\n const changeFlags = this._getChangeFlags(opts);\n\n if (changeFlags.dataChanged || changeFlags.viewportChanged) {\n // if data is changed, do not debounce and immediately update the weight map\n changeFlags.boundsChanged = this._updateBounds(changeFlags.dataChanged);\n this._updateTextureRenderingBounds();\n }\n\n if (changeFlags.dataChanged || changeFlags.boundsChanged) {\n // Update weight map immediately\n clearTimeout(this.state.updateTimer);\n this.setState({isWeightMapDirty: true});\n } else if (changeFlags.viewportZoomChanged) {\n // Update weight map when zoom stops\n this._debouncedUpdateWeightmap();\n }\n\n if (props.colorRange !== oldProps.colorRange) {\n this._updateColorTexture(opts);\n }\n\n if (this.state.isWeightMapDirty) {\n this._updateWeightmap();\n }\n\n this.setState({zoom: opts.context.viewport.zoom});\n }\n\n renderLayers(): LayersList | Layer {\n if (!this.state.supported) {\n return [];\n }\n const {\n weightsTexture,\n triPositionBuffer,\n triTexCoordBuffer,\n maxWeightsTexture,\n colorTexture,\n colorDomain\n } = this.state;\n const {updateTriggers, intensity, threshold, aggregation} = this.props;\n\n const TriangleLayerClass = this.getSubLayerClass('triangle', TriangleLayer);\n\n return new TriangleLayerClass(\n this.getSubLayerProps({\n id: 'triangle-layer',\n updateTriggers\n }),\n {\n // position buffer is filled with world coordinates generated from viewport.unproject\n // i.e. LNGLAT if geospatial, CARTESIAN otherwise\n coordinateSystem: COORDINATE_SYSTEM.DEFAULT,\n data: {\n attributes: {\n positions: triPositionBuffer,\n texCoords: triTexCoordBuffer\n }\n },\n vertexCount: 4,\n maxTexture: maxWeightsTexture,\n colorTexture,\n aggregationMode: AGGREGATION_MODE[aggregation] || 0,\n texture: weightsTexture,\n intensity,\n threshold,\n colorDomain\n }\n );\n }\n\n finalizeState(context: LayerContext) {\n super.finalizeState(context);\n const {\n weightsTransform,\n weightsTexture,\n maxWeightTransform,\n maxWeightsTexture,\n triPositionBuffer,\n triTexCoordBuffer,\n colorTexture,\n updateTimer\n } = this.state;\n weightsTransform?.destroy();\n weightsTexture?.destroy();\n maxWeightTransform?.destroy();\n maxWeightsTexture?.destroy();\n triPositionBuffer?.destroy();\n triTexCoordBuffer?.destroy();\n colorTexture?.destroy();\n if (updateTimer) {\n clearTimeout(updateTimer);\n }\n }\n\n // PRIVATE\n\n // override Composite layer private method to create AttributeManager instance\n _getAttributeManager() {\n return new AttributeManager(this.context.device, {\n id: this.props.id,\n stats: this.context.stats\n });\n }\n\n _getChangeFlags(opts: UpdateParameters<this>) {\n const changeFlags: Partial<ChangeFlags> & {\n boundsChanged?: boolean;\n viewportZoomChanged?: boolean;\n } = {};\n const {dimensions} = this.state;\n changeFlags.dataChanged =\n (this.isAttributeChanged() && 'attribute changed') || // if any attribute is changed\n (this.isAggregationDirty(opts, {\n compareAll: true,\n dimension: dimensions.data\n }) &&\n 'aggregation is dirty');\n changeFlags.viewportChanged = opts.changeFlags.viewportChanged;\n\n const {zoom} = this.state;\n if (!opts.context.viewport || opts.context.viewport.zoom !== zoom) {\n changeFlags.viewportZoomChanged = true;\n }\n\n return changeFlags;\n }\n\n _createTextures() {\n const {textureSize, format, type} = this.state;\n\n this.setState({\n weightsTexture: this.context.device.createTexture({\n width: textureSize,\n height: textureSize,\n format,\n type,\n ...TEXTURE_PROPS\n }),\n maxWeightsTexture: this.context.device.createTexture({format, type, ...TEXTURE_PROPS}) // 1 X 1 texture,\n });\n }\n\n _setupAttributes() {\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n positions: {size: 3, type: GL.DOUBLE, accessor: 'getPosition'},\n weights: {size: 1, accessor: 'getWeight'}\n });\n this.setState({positionAttributeName: 'positions'});\n }\n\n _setupTextureParams() {\n const {device} = this.context;\n const {weightsTextureSize} = this.props;\n\n const textureSize = Math.min(weightsTextureSize, device.limits.maxTextureDimension2D as number);\n const floatTargetSupport = FLOAT_TARGET_FEATURES.every(feature => device.features.has(feature));\n const {format, type} = getTextureParams({device, floatTargetSupport});\n const weightsScale = floatTargetSupport ? 1 : 1 / 255;\n this.setState({textureSize, format, type, weightsScale});\n if (!floatTargetSupport) {\n log.warn(\n `HeatmapLayer: ${this.id} rendering to float texture not supported, fallingback to low precession format`\n )();\n }\n }\n\n getShaders(type) {\n return super.getShaders(\n type === 'max-weights-transform'\n ? {\n vs: vsMax,\n _fs: fsMax\n }\n : {\n vs: weightsVs,\n _fs: weightsFs\n }\n );\n }\n\n _createWeightsTransform(shaders = {}) {\n let {weightsTransform} = this.state;\n weightsTransform?.delete();\n\n weightsTransform = new TextureTransform(this.context.device, {\n id: `${this.id}-weights-transform`,\n vertexCount: 1,\n targetTexture: this.state.weightsTexture!,\n targetTextureVarying: 'weightsTexture',\n ...shaders\n } as TextureTransformProps);\n this.setState({weightsTransform});\n }\n\n _setupResources() {\n this._createTextures();\n const {textureSize, weightsTexture, maxWeightsTexture} = this.state;\n\n const weightsTransformShaders = this.getShaders('weights-transform');\n this._createWeightsTransform(weightsTransformShaders);\n\n const maxWeightsTransformShaders = this.getShaders('max-weights-transform');\n const maxWeightTransform = new TextureTransform(this.context.device, {\n id: `${this.id}-max-weights-transform`,\n _sourceTextures: {\n inTexture: weightsTexture\n },\n _targetTexture: maxWeightsTexture,\n _targetTextureVarying: 'outTexture',\n ...maxWeightsTransformShaders,\n elementCount: textureSize * textureSize\n });\n\n this.setState({\n weightsTexture,\n maxWeightsTexture,\n maxWeightTransform,\n zoom: null,\n triPositionBuffer: this.context.device.createBuffer({\n byteLength: 48,\n // @ts-expect-error\n accessor: {size: 3}\n }),\n triTexCoordBuffer: this.context.device.createBuffer({\n byteLength: 48,\n // @ts-expect-error\n accessor: {size: 2}\n })\n });\n }\n\n // overwrite super class method to update transform model\n updateShaders(shaderOptions) {\n // sahder params (modules, injects) changed, update model object\n this._createWeightsTransform(shaderOptions);\n }\n\n _updateMaxWeightValue() {\n const {maxWeightTransform} = this.state;\n maxWeightTransform!.run({\n parameters: {\n // @ts-expect-error TODO(v9): Resolve errors.\n blend: true,\n depthTest: false,\n blendFunc: [GL.ONE, GL.ONE],\n blendEquation: GL.MAX\n }\n });\n }\n\n // Computes world bounds area that needs to be processed for generate heatmap\n _updateBounds(forceUpdate: any = false): boolean {\n const {viewport} = this.context;\n\n // Unproject all 4 corners of the current screen coordinates into world coordinates (lng/lat)\n // Takes care of viewport has non zero bearing/pitch (i.e axis not aligned with world coordiante system)\n const viewportCorners = [\n viewport.unproject([0, 0]),\n viewport.unproject([viewport.width, 0]),\n viewport.unproject([viewport.width, viewport.height]),\n viewport.unproject([0, viewport.height])\n ].map(p => p.map(Math.fround));\n\n // #1: get world bounds for current viewport extends\n const visibleWorldBounds = getBounds(viewportCorners); // TODO: Change to visible bounds\n\n const newState: Partial<HeatmapLayer['state']> = {visibleWorldBounds, viewportCorners};\n let boundsChanged = false;\n\n if (\n forceUpdate ||\n !this.state.worldBounds ||\n !boundsContain(this.state.worldBounds, visibleWorldBounds)\n ) {\n // #2 : convert world bounds to common (Flat) bounds\n // #3 : extend common bounds to match aspect ratio with viewport\n const scaledCommonBounds = this._worldToCommonBounds(visibleWorldBounds);\n\n // #4 :convert aligned common bounds to world bounds\n const worldBounds = this._commonToWorldBounds(scaledCommonBounds);\n\n // Clip webmercator projection limits\n if (this.props.coordinateSystem === COORDINATE_SYSTEM.LNGLAT) {\n worldBounds[1] = Math.max(worldBounds[1], -85.051129);\n worldBounds[3] = Math.min(worldBounds[3], 85.051129);\n worldBounds[0] = Math.max(worldBounds[0], -360);\n worldBounds[2] = Math.min(worldBounds[2], 360);\n }\n\n // #5: now convert world bounds to common using Layer's coordiante system and origin\n const normalizedCommonBounds = this._worldToCommonBounds(worldBounds);\n\n newState.worldBounds = worldBounds;\n newState.normalizedCommonBounds = normalizedCommonBounds;\n\n boundsChanged = true;\n }\n this.setState(newState);\n return boundsChanged;\n }\n\n _updateTextureRenderingBounds() {\n // Just render visible portion of the texture\n const {triPositionBuffer, triTexCoordBuffer, normalizedCommonBounds, viewportCorners} =\n this.state;\n\n const {viewport} = this.context;\n\n triPositionBuffer!.write(packVertices(viewportCorners, 3));\n\n const textureBounds = viewportCorners.map(p =>\n getTextureCoordinates(viewport.projectPosition(p), normalizedCommonBounds!)\n );\n triTexCoordBuffer!.write(packVertices(textureBounds, 2));\n }\n\n _updateColorTexture(opts) {\n const {colorRange} = opts.props;\n let {colorTexture} = this.state;\n const colors = colorRangeToFlatArray(colorRange, false, Uint8Array as any);\n\n if (colorTexture) {\n // @ts-expect-error TODO - no longer supported in v9?\n colorTexture.setImageData({\n data: colors,\n width: colorRange.length\n });\n } else {\n colorTexture = this.context.device.createTexture({\n data: colors,\n width: colorRange.length,\n height: 1,\n ...TEXTURE_PROPS\n });\n }\n this.setState({colorTexture});\n }\n\n _updateWeightmap() {\n const {radiusPixels, colorDomain, aggregation} = this.props;\n const {worldBounds, textureSize, weightsScale} = this.state;\n const weightsTransform = this.state.weightsTransform!;\n this.state.isWeightMapDirty = false;\n\n // convert world bounds to common using Layer's coordiante system and origin\n const commonBounds = this._worldToCommonBounds(worldBounds, {\n useLayerCoordinateSystem: true\n });\n\n if (colorDomain && aggregation === 'SUM') {\n // scale color domain to weight per pixel\n const {viewport} = this.context;\n const metersPerPixel =\n (viewport.distanceScales.metersPerUnit[2] * (commonBounds[2] - commonBounds[0])) /\n textureSize;\n this.state.colorDomain = colorDomain.map(x => x * metersPerPixel * weightsScale);\n } else {\n this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;\n }\n\n const uniforms = {\n radiusPixels,\n commonBounds,\n textureWidth: textureSize,\n weightsScale\n };\n // Attribute manager sets data array count as instaceCount on model\n // we need to set that as elementCount on 'weightsTransform'\n weightsTransform.update({\n elementCount: this.getNumInstances()\n });\n // Need to explictly specify clearColor as external context may have modified it\n withGLParameters(this.context.gl, {clearColor: [0, 0, 0, 0]}, () => {\n weightsTransform.run({\n uniforms,\n parameters: {\n // @ts-expect-error TODO(v9): Resolve errors.\n blend: true,\n depthTest: false,\n blendFunc: [GL.ONE, GL.ONE],\n blendEquation: GL.FUNC_ADD\n },\n clearRenderTarget: true,\n attributes: this.getAttributes(),\n moduleSettings: this.getModuleSettings()\n });\n });\n this._updateMaxWeightValue();\n\n // reset filtering parameters (TODO: remove once luma issue#1193 is fixed)\n // TODO v9 sampler support in luma.gl needs to improve\n // weightsTexture.setSampler({\n // magFilter: 'linear',\n // minFilter: 'linear'\n // });\n }\n\n _debouncedUpdateWeightmap(fromTimer = false) {\n let {updateTimer} = this.state;\n const {debounceTimeout} = this.props;\n\n if (fromTimer) {\n updateTimer = null;\n // update\n this._updateBounds(true);\n this._updateTextureRenderingBounds();\n this.setState({isWeightMapDirty: true});\n } else {\n this.setState({isWeightMapDirty: false});\n clearTimeout(updateTimer);\n updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);\n }\n\n this.setState({updateTimer});\n }\n\n // input: worldBounds: [minLong, minLat, maxLong, maxLat]\n // input: opts.useLayerCoordinateSystem : layers coordiante system is used\n // optput: commonBounds: [minX, minY, maxX, maxY] scaled to fit the current texture\n _worldToCommonBounds(worldBounds, opts: {useLayerCoordinateSystem?: boolean} = {}) {\n const {useLayerCoordinateSystem = false} = opts;\n const [minLong, minLat, maxLong, maxLat] = worldBounds;\n const {viewport} = this.context;\n const {textureSize} = this.state;\n const {coordinateSystem} = this.props;\n\n const offsetMode =\n useLayerCoordinateSystem &&\n (coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS ||\n coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS);\n const offsetOriginCommon = offsetMode\n ? viewport.projectPosition(this.props.coordinateOrigin)\n : [0, 0];\n const size = (textureSize * RESOLUTION) / viewport.scale;\n\n let bottomLeftCommon;\n let topRightCommon;\n\n // Y-axis is flipped between World and Common bounds\n if (useLayerCoordinateSystem && !offsetMode) {\n bottomLeftCommon = this.projectPosition([minLong, minLat, 0]);\n topRightCommon = this.projectPosition([maxLong, maxLat, 0]);\n } else {\n bottomLeftCommon = viewport.projectPosition([minLong, minLat, 0]);\n topRightCommon = viewport.projectPosition([maxLong, maxLat, 0]);\n }\n // Ignore z component\n return scaleToAspectRatio(\n [\n bottomLeftCommon[0] - offsetOriginCommon[0],\n bottomLeftCommon[1] - offsetOriginCommon[1],\n topRightCommon[0] - offsetOriginCommon[0],\n topRightCommon[1] - offsetOriginCommon[1]\n ],\n size,\n size\n );\n }\n\n // input commonBounds: [xMin, yMin, xMax, yMax]\n // output worldBounds: [minLong, minLat, maxLong, maxLat]\n _commonToWorldBounds(commonBounds) {\n const [xMin, yMin, xMax, yMax] = commonBounds;\n const {viewport} = this.context;\n const bottomLeftWorld = viewport.unprojectPosition([xMin, yMin]);\n const topRightWorld = viewport.unprojectPosition([xMax, yMax]);\n\n return bottomLeftWorld.slice(0, 2).concat(topRightWorld.slice(0, 2));\n }\n}\n"],"file":"heatmap-layer.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/heatmap-layer/heatmap-layer.ts"],"names":["getBounds","boundsContain","packVertices","scaleToAspectRatio","getTextureCoordinates","GL","TextureTransform","AttributeManager","COORDINATE_SYSTEM","log","TriangleLayer","AggregationLayer","defaultColorRange","colorRangeToFlatArray","weightsVs","weightsFs","maxVs","maxFs","RESOLUTION","TEXTURE_PROPS","format","mipmaps","sampler","minFilter","magFilter","addressModeU","addressModeV","DEFAULT_COLOR_DOMAIN","AGGREGATION_MODE","SUM","MEAN","defaultProps","getPosition","type","value","x","position","getWeight","intensity","min","radiusPixels","max","colorRange","threshold","colorDomain","optional","aggregation","weightsTextureSize","debounceTimeout","REQUIRED_FEATURES","FLOAT_TARGET_FEATURES","DIMENSIONS","data","props","HeatmapLayer","state","initializeState","every","feature","context","device","features","has","setState","supported","error","id","initializeAggregationLayer","_setupTextureParams","_setupAttributes","_setupResources","shouldUpdateState","changeFlags","somethingChanged","updateState","opts","_updateHeatmapState","oldProps","_getChangeFlags","dataChanged","viewportChanged","boundsChanged","_updateBounds","_updateTextureRenderingBounds","clearTimeout","updateTimer","isWeightMapDirty","viewportZoomChanged","_debouncedUpdateWeightmap","_updateColorTexture","_updateWeightmap","zoom","viewport","renderLayers","weightsTexture","triPositionBuffer","triTexCoordBuffer","maxWeightsTexture","colorTexture","updateTriggers","TriangleLayerClass","getSubLayerClass","getSubLayerProps","coordinateSystem","DEFAULT","attributes","positions","texCoords","vertexCount","maxTexture","aggregationMode","finalizeState","weightsTransform","maxWeightTransform","destroy","_getAttributeManager","stats","dimensions","isAttributeChanged","isAggregationDirty","compareAll","dimension","_createTextures","textureSize","createTexture","width","height","attributeManager","getAttributeManager","add","size","accessor","weights","positionAttributeName","Math","limits","maxTextureDimension2D","floatTargetSupport","weightsScale","warn","_createWeightsTransform","shaders","bufferLayout","getBufferLayouts","targetTexture","parameters","depthWriteEnabled","blendColorOperation","blendColorSrcFactor","blendColorDstFactor","blendAlphaSrcFactor","blendAlphaDstFactor","topology","weightsTransformShaders","getShaders","vs","fs","maxWeightsTransformShaders","bindings","inTexture","uniforms","blendAlphaOperation","createBuffer","byteLength","updateShaders","shaderOptions","_updateMaxWeightValue","run","clearColor","forceUpdate","viewportCorners","unproject","map","p","fround","visibleWorldBounds","newState","worldBounds","scaledCommonBounds","_worldToCommonBounds","_commonToWorldBounds","LNGLAT","normalizedCommonBounds","write","textureBounds","projectPosition","colors","Uint8Array","length","setSubImageData","commonBounds","useLayerCoordinateSystem","metersPerPixel","distanceScales","metersPerUnit","getAttributes","moduleSettings","getModuleSettings","buffer","textureWidth","model","setAttributes","setVertexCount","getNumInstances","setUniforms","updateModuleSettings","fromTimer","setTimeout","bind","minLong","minLat","maxLong","maxLat","offsetMode","LNGLAT_OFFSETS","METER_OFFSETS","offsetOriginCommon","coordinateOrigin","scale","bottomLeftCommon","topRightCommon","xMin","yMin","xMax","yMax","bottomLeftWorld","unprojectPosition","topRightWorld","slice","concat","layerName"],"mappings":"AAqBA,SACEA,SADF,EAEEC,aAFF,EAGEC,YAHF,EAIEC,kBAJF,EAKEC,qBALF,QAMO,uBANP;AAQA,SAAQC,EAAR,QAAiB,oBAAjB;AACA,SAAQC,gBAAR,QAAsD,iBAAtD;AACA,SAGEC,gBAHF,EAMEC,iBANF,EAUEC,GAVF,QAcO,eAdP;AAeA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,gBAAP,MAAsD,sBAAtD;AACA,SAAQC,iBAAR,EAA2BC,qBAA3B,QAAuD,sBAAvD;AACA,OAAOC,SAAP,MAAsB,mBAAtB;AACA,OAAOC,SAAP,MAAsB,mBAAtB;AACA,OAAOC,KAAP,MAAkB,eAAlB;AACA,OAAOC,KAAP,MAAkB,eAAlB;AAEA,MAAMC,UAAU,GAAG,CAAnB;AACA,MAAMC,aAA2B,GAAG;AAClCC,EAAAA,MAAM,EAAE,YAD0B;AAElCC,EAAAA,OAAO,EAAE,KAFyB;AAGlCC,EAAAA,OAAO,EAAE;AACPC,IAAAA,SAAS,EAAE,QADJ;AAEPC,IAAAA,SAAS,EAAE,QAFJ;AAGPC,IAAAA,YAAY,EAAE,eAHP;AAIPC,IAAAA,YAAY,EAAE;AAJP;AAHyB,CAApC;AAUA,MAAMC,oBAAoB,GAAG,CAAC,CAAD,EAAI,CAAJ,CAA7B;AACA,MAAMC,gBAAgB,GAAG;AACvBC,EAAAA,GAAG,EAAE,CADkB;AAEvBC,EAAAA,IAAI,EAAE;AAFiB,CAAzB;AAKA,MAAMC,YA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AAD,CAJxC,CADuB,EAOvBtF,IAPuB,EAQvBA,IARuB,CAAzB;AAUD;;AAIDkD,EAAAA,oBAAoB,CAACU,YAAD,EAAe;AACjC,UAAM,CAAC+B,IAAD,EAAOC,IAAP,EAAaC,IAAb,EAAmBC,IAAnB,IAA2BlC,YAAjC;AACA,UAAM;AAAClG,MAAAA;AAAD,QAAa,KAAKjC,OAAxB;AACA,UAAMsK,eAAe,GAAGrI,QAAQ,CAACsI,iBAAT,CAA2B,CAACL,IAAD,EAAOC,IAAP,CAA3B,CAAxB;AACA,UAAMK,aAAa,GAAGvI,QAAQ,CAACsI,iBAAT,CAA2B,CAACH,IAAD,EAAOC,IAAP,CAA3B,CAAtB;AAEA,WAAOC,eAAe,CAACG,KAAhB,CAAsB,CAAtB,EAAyB,CAAzB,EAA4BC,MAA5B,CAAmCF,aAAa,CAACC,KAAd,CAAoB,CAApB,EAAuB,CAAvB,CAAnC,CAAP;AACD;;AA9fkF;AAHhE9K,Y,CAIZgL,S,GAAY,c;AAJAhL,Y,CAKZvB,Y,GAAeA,Y","sourcesContent":["// Copyright (c) 2015 - 2019 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n/* global setTimeout clearTimeout */\nimport {\n getBounds,\n boundsContain,\n packVertices,\n scaleToAspectRatio,\n getTextureCoordinates\n} from './heatmap-layer-utils';\nimport {Buffer, DeviceFeature, Texture, TextureProps, TextureFormat} from '@luma.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {TextureTransform, TextureTransformProps} from '@luma.gl/engine';\nimport {\n Accessor,\n AccessorFunction,\n AttributeManager,\n ChangeFlags,\n Color,\n COORDINATE_SYSTEM,\n Layer,\n LayerContext,\n LayersList,\n log,\n Position,\n UpdateParameters,\n DefaultProps\n} from '@deck.gl/core';\nimport TriangleLayer from './triangle-layer';\nimport AggregationLayer, {AggregationLayerProps} from '../aggregation-layer';\nimport {defaultColorRange, colorRangeToFlatArray} from '../utils/color-utils';\nimport weightsVs from './weights-vs.glsl';\nimport weightsFs from './weights-fs.glsl';\nimport maxVs from './max-vs.glsl';\nimport maxFs from './max-fs.glsl';\n\nconst RESOLUTION = 2; // (number of common space pixels) / (number texels)\nconst TEXTURE_PROPS: TextureProps = {\n format: 'rgba8unorm',\n mipmaps: false,\n sampler: {\n minFilter: 'linear',\n magFilter: 'linear',\n addressModeU: 'clamp-to-edge',\n addressModeV: 'clamp-to-edge'\n }\n};\nconst DEFAULT_COLOR_DOMAIN = [0, 0];\nconst AGGREGATION_MODE = {\n SUM: 0,\n MEAN: 1\n};\n\nconst defaultProps: DefaultProps<HeatmapLayerProps> = {\n getPosition: {type: 'accessor', value: (x: any) => x.position},\n getWeight: {type: 'accessor', value: 1},\n intensity: {type: 'number', min: 0, value: 1},\n radiusPixels: {type: 'number', min: 1, max: 100, value: 50},\n colorRange: defaultColorRange,\n threshold: {type: 'number', min: 0, max: 1, value: 0.05},\n colorDomain: {type: 'array', value: null, optional: true},\n // 'SUM' or 'MEAN'\n aggregation: 'SUM',\n weightsTextureSize: {type: 'number', min: 128, max: 2048, value: 2048},\n debounceTimeout: {type: 'number', min: 0, max: 1000, value: 500}\n};\n\nconst REQUIRED_FEATURES: DeviceFeature[] = [\n 'blend-minmax-webgl1', // max weight calculation\n 'texture-formats-float32-webgl1' // weight-map as texture\n];\n\nconst FLOAT_TARGET_FEATURES: DeviceFeature[] = [\n 'texture-renderable-float32-webgl', // ability to render to float texture\n 'texture-blend-float-webgl1' // ability to blend when rendering to float texture\n];\n\nconst DIMENSIONS = {\n data: {\n props: ['radiusPixels']\n }\n};\n\nexport type HeatmapLayerProps<DataT = unknown> = _HeatmapLayerProps<DataT> &\n AggregationLayerProps<DataT>;\n\ntype _HeatmapLayerProps<DataT> = {\n /**\n * Radius of the circle in pixels, to which the weight of an object is distributed.\n *\n * @default 30\n */\n radiusPixels?: number;\n\n /**\n * Specified as an array of colors [color1, color2, ...].\n *\n * @default `6-class YlOrRd` - [colorbrewer](http://colorbrewer2.org/#type=sequential&scheme=YlOrRd&n=6)\n */\n colorRange?: Color[];\n\n /**\n * Value that is multiplied with the total weight at a pixel to obtain the final weight.\n *\n * @default 1\n */\n intensity?: number;\n\n /**\n * Ratio of the fading weight to the max weight, between `0` and `1`.\n *\n * For example, `0.1` affects all pixels with weight under 10% of the max.\n *\n * Ignored when `colorDomain` is specified.\n * @default 0.05\n */\n threshold?: number;\n\n /**\n * Controls how weight values are mapped to the `colorRange`, as an array of two numbers [`minValue`, `maxValue`].\n *\n * @default null\n */\n colorDomain?: [number, number] | null;\n\n /**\n * Defines the type of aggregation operation\n *\n * V valid values are 'SUM', 'MEAN'.\n *\n * @default 'SUM'\n */\n aggregation?: 'SUM' | 'MEAN';\n\n /**\n * Specifies the size of weight texture.\n * @default 2048\n */\n weightsTextureSize?: number;\n\n /**\n * Interval in milliseconds during which changes to the viewport don't trigger aggregation.\n *\n * @default 500\n */\n debounceTimeout?: number;\n\n /**\n * Method called to retrieve the position of each object.\n *\n * @default d => d.position\n */\n getPosition?: AccessorFunction<DataT, Position>;\n\n /**\n * The weight of each object.\n *\n * @default 1\n */\n getWeight?: Accessor<DataT, number>;\n};\n\n/** Visualizes the spatial distribution of data. */\nexport default class HeatmapLayer<\n DataT = any,\n ExtraPropsT extends {} = {}\n> extends AggregationLayer<DataT, ExtraPropsT & Required<_HeatmapLayerProps<DataT>>> {\n static layerName = 'HeatmapLayer';\n static defaultProps = defaultProps;\n\n state!: AggregationLayer<DataT>['state'] & {\n supported: boolean;\n colorDomain?: number[];\n isWeightMapDirty?: boolean;\n weightsTexture?: Texture;\n maxWeightsTexture?: Texture;\n colorTexture?: Texture;\n zoom?: number;\n worldBounds?: number[];\n normalizedCommonBounds?: number[];\n updateTimer?: any;\n triPositionBuffer?: Buffer;\n triTexCoordBuffer?: Buffer;\n weightsTransform?: TextureTransform;\n maxWeightTransform?: TextureTransform;\n textureSize: number;\n format: TextureFormat;\n weightsScale: number;\n visibleWorldBounds: number[];\n viewportCorners: number[][];\n };\n\n initializeState() {\n if (!REQUIRED_FEATURES.every(feature => this.context.device.features.has(feature))) {\n this.setState({supported: false});\n log.error(`HeatmapLayer: ${this.id} is not supported on this browser`)();\n return;\n }\n super.initializeAggregationLayer(DIMENSIONS);\n this.setState({supported: true, colorDomain: DEFAULT_COLOR_DOMAIN});\n this._setupTextureParams();\n this._setupAttributes();\n this._setupResources();\n }\n\n shouldUpdateState({changeFlags}: UpdateParameters<this>) {\n // Need to be updated when viewport changes\n return changeFlags.somethingChanged;\n }\n\n /* eslint-disable max-statements,complexity */\n updateState(opts: UpdateParameters<this>) {\n if (!this.state.supported) {\n return;\n }\n super.updateState(opts);\n this._updateHeatmapState(opts);\n }\n\n _updateHeatmapState(opts: UpdateParameters<this>) {\n const {props, oldProps} = opts;\n const changeFlags = this._getChangeFlags(opts);\n\n if (changeFlags.dataChanged || changeFlags.viewportChanged) {\n // if data is changed, do not debounce and immediately update the weight map\n changeFlags.boundsChanged = this._updateBounds(changeFlags.dataChanged);\n this._updateTextureRenderingBounds();\n }\n\n if (changeFlags.dataChanged || changeFlags.boundsChanged) {\n // Update weight map immediately\n clearTimeout(this.state.updateTimer);\n this.setState({isWeightMapDirty: true});\n } else if (changeFlags.viewportZoomChanged) {\n // Update weight map when zoom stops\n this._debouncedUpdateWeightmap();\n }\n\n if (props.colorRange !== oldProps.colorRange) {\n this._updateColorTexture(opts);\n }\n\n if (this.state.isWeightMapDirty) {\n this._updateWeightmap();\n }\n\n this.setState({zoom: opts.context.viewport.zoom});\n }\n\n renderLayers(): LayersList | Layer {\n if (!this.state.supported) {\n return [];\n }\n const {\n weightsTexture,\n triPositionBuffer,\n triTexCoordBuffer,\n maxWeightsTexture,\n colorTexture,\n colorDomain\n } = this.state;\n const {updateTriggers, intensity, threshold, aggregation} = this.props;\n\n const TriangleLayerClass = this.getSubLayerClass('triangle', TriangleLayer);\n\n return new TriangleLayerClass(\n this.getSubLayerProps({\n id: 'triangle-layer',\n updateTriggers\n }),\n {\n // position buffer is filled with world coordinates generated from viewport.unproject\n // i.e. LNGLAT if geospatial, CARTESIAN otherwise\n coordinateSystem: COORDINATE_SYSTEM.DEFAULT,\n data: {\n attributes: {\n positions: triPositionBuffer,\n texCoords: triTexCoordBuffer\n }\n },\n vertexCount: 4,\n maxTexture: maxWeightsTexture,\n colorTexture,\n aggregationMode: AGGREGATION_MODE[aggregation] || 0,\n weightsTexture,\n intensity,\n threshold,\n colorDomain\n }\n );\n }\n\n finalizeState(context: LayerContext) {\n super.finalizeState(context);\n const {\n weightsTransform,\n weightsTexture,\n maxWeightTransform,\n maxWeightsTexture,\n triPositionBuffer,\n triTexCoordBuffer,\n colorTexture,\n updateTimer\n } = this.state;\n weightsTransform?.destroy();\n weightsTexture?.destroy();\n maxWeightTransform?.destroy();\n maxWeightsTexture?.destroy();\n triPositionBuffer?.destroy();\n triTexCoordBuffer?.destroy();\n colorTexture?.destroy();\n if (updateTimer) {\n clearTimeout(updateTimer);\n }\n }\n\n // PRIVATE\n\n // override Composite layer private method to create AttributeManager instance\n _getAttributeManager() {\n return new AttributeManager(this.context.device, {\n id: this.props.id,\n stats: this.context.stats\n });\n }\n\n _getChangeFlags(opts: UpdateParameters<this>) {\n const changeFlags: Partial<ChangeFlags> & {\n boundsChanged?: boolean;\n viewportZoomChanged?: boolean;\n } = {};\n const {dimensions} = this.state;\n changeFlags.dataChanged =\n (this.isAttributeChanged() && 'attribute changed') || // if any attribute is changed\n (this.isAggregationDirty(opts, {\n compareAll: true,\n dimension: dimensions.data\n }) &&\n 'aggregation is dirty');\n changeFlags.viewportChanged = opts.changeFlags.viewportChanged;\n\n const {zoom} = this.state;\n if (!opts.context.viewport || opts.context.viewport.zoom !== zoom) {\n changeFlags.viewportZoomChanged = true;\n }\n\n return changeFlags;\n }\n\n _createTextures() {\n const {textureSize, format} = this.state;\n\n this.setState({\n weightsTexture: this.context.device.createTexture({\n ...TEXTURE_PROPS,\n width: textureSize,\n height: textureSize,\n format\n }),\n maxWeightsTexture: this.context.device.createTexture({\n ...TEXTURE_PROPS,\n width: 1,\n height: 1,\n format\n })\n });\n }\n\n _setupAttributes() {\n const attributeManager = this.getAttributeManager()!;\n attributeManager.add({\n positions: {size: 3, type: GL.DOUBLE, accessor: 'getPosition'},\n weights: {size: 1, accessor: 'getWeight'}\n });\n this.setState({positionAttributeName: 'positions'});\n }\n\n _setupTextureParams() {\n const {device} = this.context;\n const {weightsTextureSize} = this.props;\n\n const textureSize = Math.min(weightsTextureSize, device.limits.maxTextureDimension2D as number);\n const floatTargetSupport = FLOAT_TARGET_FEATURES.every(feature => device.features.has(feature));\n const format: TextureFormat = floatTargetSupport ? 'rgba32float' : 'rgba8unorm';\n const weightsScale = floatTargetSupport ? 1 : 1 / 255;\n this.setState({textureSize, format, weightsScale});\n if (!floatTargetSupport) {\n log.warn(\n `HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`\n )();\n }\n }\n\n _createWeightsTransform(shaders: {vs: string; fs?: string}) {\n let {weightsTransform} = this.state;\n const {weightsTexture} = this.state;\n const attributeManager = this.getAttributeManager()!;\n\n weightsTransform?.destroy();\n weightsTransform = new TextureTransform(this.context.device, {\n id: `${this.id}-weights-transform`,\n bufferLayout: attributeManager.getBufferLayouts(),\n vertexCount: 1,\n targetTexture: weightsTexture!,\n parameters: {\n depthWriteEnabled: false,\n blendColorOperation: 'add',\n blendColorSrcFactor: 'one',\n blendColorDstFactor: 'one',\n blendAlphaSrcFactor: 'one',\n blendAlphaDstFactor: 'one'\n },\n topology: 'point-list',\n ...shaders\n } as TextureTransformProps);\n\n this.setState({weightsTransform});\n }\n\n _setupResources() {\n this._createTextures();\n const {device} = this.context;\n const {textureSize, weightsTexture, maxWeightsTexture} = this.state;\n\n const weightsTransformShaders = this.getShaders({\n vs: weightsVs,\n fs: weightsFs\n });\n this._createWeightsTransform(weightsTransformShaders);\n\n const maxWeightsTransformShaders = this.getShaders({vs: maxVs, fs: maxFs});\n const maxWeightTransform = new TextureTransform(device, {\n id: `${this.id}-max-weights-transform`,\n bindings: {inTexture: weightsTexture},\n uniforms: {textureSize},\n targetTexture: maxWeightsTexture,\n ...maxWeightsTransformShaders,\n vertexCount: textureSize * textureSize,\n topology: 'point-list',\n parameters: {\n depthWriteEnabled: false,\n blendColorOperation: 'max',\n blendAlphaOperation: 'max',\n blendColorSrcFactor: 'one',\n blendColorDstFactor: 'one',\n blendAlphaSrcFactor: 'one',\n blendAlphaDstFactor: 'one'\n }\n });\n\n this.setState({\n weightsTexture,\n maxWeightsTexture,\n maxWeightTransform,\n zoom: null,\n triPositionBuffer: device.createBuffer({byteLength: 48}),\n triTexCoordBuffer: device.createBuffer({byteLength: 48})\n });\n }\n\n // overwrite super class method to update transform model\n updateShaders(shaderOptions) {\n // shader params (modules, injects) changed, update model object\n this._createWeightsTransform({\n vs: weightsVs,\n fs: weightsFs,\n ...shaderOptions\n });\n }\n\n _updateMaxWeightValue() {\n const {maxWeightTransform, textureSize} = this.state;\n\n maxWeightTransform!.run({\n parameters: {viewport: [0, 0, 1, 1]},\n clearColor: [0, 0, 0, 0]\n });\n }\n\n // Computes world bounds area that needs to be processed for generate heatmap\n _updateBounds(forceUpdate: any = false): boolean {\n const {viewport} = this.context;\n\n // Unproject all 4 corners of the current screen coordinates into world coordinates (lng/lat)\n // Takes care of viewport has non zero bearing/pitch (i.e axis not aligned with world coordiante system)\n const viewportCorners = [\n viewport.unproject([0, 0]),\n viewport.unproject([viewport.width, 0]),\n viewport.unproject([viewport.width, viewport.height]),\n viewport.unproject([0, viewport.height])\n ].map(p => p.map(Math.fround));\n\n // #1: get world bounds for current viewport extends\n const visibleWorldBounds = getBounds(viewportCorners); // TODO: Change to visible bounds\n\n const newState: Partial<HeatmapLayer['state']> = {visibleWorldBounds, viewportCorners};\n let boundsChanged = false;\n\n if (\n forceUpdate ||\n !this.state.worldBounds ||\n !boundsContain(this.state.worldBounds, visibleWorldBounds)\n ) {\n // #2 : convert world bounds to common (Flat) bounds\n // #3 : extend common bounds to match aspect ratio with viewport\n const scaledCommonBounds = this._worldToCommonBounds(visibleWorldBounds);\n\n // #4 :convert aligned common bounds to world bounds\n const worldBounds = this._commonToWorldBounds(scaledCommonBounds);\n\n // Clip webmercator projection limits\n if (this.props.coordinateSystem === COORDINATE_SYSTEM.LNGLAT) {\n worldBounds[1] = Math.max(worldBounds[1], -85.051129);\n worldBounds[3] = Math.min(worldBounds[3], 85.051129);\n worldBounds[0] = Math.max(worldBounds[0], -360);\n worldBounds[2] = Math.min(worldBounds[2], 360);\n }\n\n // #5: now convert world bounds to common using Layer's coordiante system and origin\n const normalizedCommonBounds = this._worldToCommonBounds(worldBounds);\n\n newState.worldBounds = worldBounds;\n newState.normalizedCommonBounds = normalizedCommonBounds;\n\n boundsChanged = true;\n }\n this.setState(newState);\n return boundsChanged;\n }\n\n _updateTextureRenderingBounds() {\n // Just render visible portion of the texture\n const {triPositionBuffer, triTexCoordBuffer, normalizedCommonBounds, viewportCorners} =\n this.state;\n\n const {viewport} = this.context;\n\n triPositionBuffer!.write(packVertices(viewportCorners, 3));\n\n const textureBounds = viewportCorners.map(p =>\n getTextureCoordinates(viewport.projectPosition(p), normalizedCommonBounds!)\n );\n triTexCoordBuffer!.write(packVertices(textureBounds, 2));\n }\n\n _updateColorTexture(opts) {\n const {colorRange} = opts.props;\n let {colorTexture} = this.state;\n const colors = colorRangeToFlatArray(colorRange, false, Uint8Array as any);\n\n if (colorTexture && colorTexture?.width === colorRange.length) {\n // TODO(v9): Unclear whether `setSubImageData` is a public API, or what to use if not.\n (colorTexture as any).setSubImageData({data: colors});\n } else {\n colorTexture?.destroy();\n colorTexture = this.context.device.createTexture({\n ...TEXTURE_PROPS,\n data: colors,\n width: colorRange.length,\n height: 1\n });\n }\n this.setState({colorTexture});\n }\n\n _updateWeightmap() {\n const {radiusPixels, colorDomain, aggregation} = this.props;\n const {worldBounds, textureSize, weightsScale} = this.state;\n const weightsTransform = this.state.weightsTransform!;\n this.state.isWeightMapDirty = false;\n\n // convert world bounds to common using Layer's coordiante system and origin\n const commonBounds = this._worldToCommonBounds(worldBounds, {\n useLayerCoordinateSystem: true\n });\n\n if (colorDomain && aggregation === 'SUM') {\n // scale color domain to weight per pixel\n const {viewport} = this.context;\n const metersPerPixel =\n (viewport.distanceScales.metersPerUnit[2] * (commonBounds[2] - commonBounds[0])) /\n textureSize;\n this.state.colorDomain = colorDomain.map(x => x * metersPerPixel * weightsScale);\n } else {\n this.state.colorDomain = colorDomain || DEFAULT_COLOR_DOMAIN;\n }\n\n const attributeManager = this.getAttributeManager()!;\n const attributes = attributeManager.getAttributes();\n const moduleSettings = this.getModuleSettings();\n const positions = attributes.positions.buffer;\n const uniforms = {radiusPixels, commonBounds, textureWidth: textureSize, weightsScale};\n const weights = attributes.weights.buffer;\n weightsTransform.model.setAttributes({positions, weights});\n weightsTransform.model.setVertexCount(this.getNumInstances());\n weightsTransform.model.setUniforms(uniforms);\n weightsTransform.model.updateModuleSettings(moduleSettings);\n weightsTransform.run({\n parameters: {viewport: [0, 0, textureSize, textureSize]},\n clearColor: [0, 0, 0, 0]\n });\n\n this._updateMaxWeightValue();\n }\n\n _debouncedUpdateWeightmap(fromTimer = false) {\n let {updateTimer} = this.state;\n const {debounceTimeout} = this.props;\n\n if (fromTimer) {\n updateTimer = null;\n // update\n this._updateBounds(true);\n this._updateTextureRenderingBounds();\n this.setState({isWeightMapDirty: true});\n } else {\n this.setState({isWeightMapDirty: false});\n clearTimeout(updateTimer);\n updateTimer = setTimeout(this._debouncedUpdateWeightmap.bind(this, true), debounceTimeout);\n }\n\n this.setState({updateTimer});\n }\n\n // input: worldBounds: [minLong, minLat, maxLong, maxLat]\n // input: opts.useLayerCoordinateSystem : layers coordiante system is used\n // optput: commonBounds: [minX, minY, maxX, maxY] scaled to fit the current texture\n _worldToCommonBounds(worldBounds, opts: {useLayerCoordinateSystem?: boolean} = {}) {\n const {useLayerCoordinateSystem = false} = opts;\n const [minLong, minLat, maxLong, maxLat] = worldBounds;\n const {viewport} = this.context;\n const {textureSize} = this.state;\n const {coordinateSystem} = this.props;\n\n const offsetMode =\n useLayerCoordinateSystem &&\n (coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS ||\n coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS);\n const offsetOriginCommon = offsetMode\n ? viewport.projectPosition(this.props.coordinateOrigin)\n : [0, 0];\n const size = (textureSize * RESOLUTION) / viewport.scale;\n\n let bottomLeftCommon;\n let topRightCommon;\n\n // Y-axis is flipped between World and Common bounds\n if (useLayerCoordinateSystem && !offsetMode) {\n bottomLeftCommon = this.projectPosition([minLong, minLat, 0]);\n topRightCommon = this.projectPosition([maxLong, maxLat, 0]);\n } else {\n bottomLeftCommon = viewport.projectPosition([minLong, minLat, 0]);\n topRightCommon = viewport.projectPosition([maxLong, maxLat, 0]);\n }\n // Ignore z component\n return scaleToAspectRatio(\n [\n bottomLeftCommon[0] - offsetOriginCommon[0],\n bottomLeftCommon[1] - offsetOriginCommon[1],\n topRightCommon[0] - offsetOriginCommon[0],\n topRightCommon[1] - offsetOriginCommon[1]\n ],\n size,\n size\n );\n }\n\n // input commonBounds: [xMin, yMin, xMax, yMax]\n // output worldBounds: [minLong, minLat, maxLong, maxLat]\n _commonToWorldBounds(commonBounds) {\n const [xMin, yMin, xMax, yMax] = commonBounds;\n const {viewport} = this.context;\n const bottomLeftWorld = viewport.unprojectPosition([xMin, yMin]);\n const topRightWorld = viewport.unprojectPosition([xMax, yMax]);\n\n return bottomLeftWorld.slice(0, 2).concat(topRightWorld.slice(0, 2));\n }\n}\n"],"file":"heatmap-layer.js"}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
export default `\
|
|
2
2
|
#version 300 es
|
|
3
|
-
|
|
3
|
+
uniform sampler2D inTexture;
|
|
4
|
+
uniform float textureSize;
|
|
4
5
|
out vec4 outTexture;
|
|
5
6
|
|
|
6
7
|
void main()
|
|
7
8
|
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
// Sample every pixel in texture
|
|
10
|
+
int yIndex = gl_VertexID / int(textureSize);
|
|
11
|
+
int xIndex = gl_VertexID - (yIndex * int(textureSize));
|
|
12
|
+
vec2 uv = (0.5 + vec2(float(xIndex), float(yIndex))) / textureSize;
|
|
13
|
+
outTexture = texture(inTexture, uv);
|
|
14
|
+
|
|
15
|
+
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
|
|
16
|
+
// Enforce default value for ANGLE issue (https://bugs.chromium.org/p/angleproject/issues/detail?id=3941)
|
|
17
|
+
gl_PointSize = 1.0;
|
|
12
18
|
}
|
|
13
19
|
`;
|
|
14
20
|
//# sourceMappingURL=max-vs.glsl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/heatmap-layer/max-vs.glsl.ts"],"names":[],"mappings":"AAAA,eAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,
|
|
1
|
+
{"version":3,"sources":["../../../src/heatmap-layer/max-vs.glsl.ts"],"names":[],"mappings":"AAAA,eAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAlBA","sourcesContent":["export default `\\\n#version 300 es\nuniform sampler2D inTexture;\nuniform float textureSize;\nout vec4 outTexture;\n\nvoid main()\n{\n // Sample every pixel in texture\n int yIndex = gl_VertexID / int(textureSize);\n int xIndex = gl_VertexID - (yIndex * int(textureSize));\n vec2 uv = (0.5 + vec2(float(xIndex), float(yIndex))) / textureSize;\n outTexture = texture(inTexture, uv);\n\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n // Enforce default value for ANGLE issue (https://bugs.chromium.org/p/angleproject/issues/detail?id=3941)\n gl_PointSize = 1.0;\n}\n`;\n"],"file":"max-vs.glsl.js"}
|
|
@@ -5,7 +5,7 @@ export default `\
|
|
|
5
5
|
precision highp float;
|
|
6
6
|
|
|
7
7
|
uniform float opacity;
|
|
8
|
-
uniform sampler2D
|
|
8
|
+
uniform sampler2D weightsTexture;
|
|
9
9
|
uniform sampler2D colorTexture;
|
|
10
10
|
uniform float aggregationMode;
|
|
11
11
|
|
|
@@ -23,7 +23,7 @@ vec4 getLinearColor(float value) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
void main(void) {
|
|
26
|
-
vec4 weights = texture(
|
|
26
|
+
vec4 weights = texture(weightsTexture, vTexCoords);
|
|
27
27
|
float weight = weights.r;
|
|
28
28
|
|
|
29
29
|
if (aggregationMode > 0.5) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/heatmap-layer/triangle-layer-fragment.glsl.ts"],"names":[],"mappings":"AAoBA,eAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAzCA","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nexport default `\\\n#version 300 es\n#define SHADER_NAME triangle-layer-fragment-shader\n\nprecision highp float;\n\nuniform float opacity;\nuniform sampler2D
|
|
1
|
+
{"version":3,"sources":["../../../src/heatmap-layer/triangle-layer-fragment.glsl.ts"],"names":[],"mappings":"AAoBA,eAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAzCA","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nexport default `\\\n#version 300 es\n#define SHADER_NAME triangle-layer-fragment-shader\n\nprecision highp float;\n\nuniform float opacity;\nuniform sampler2D weightsTexture;\nuniform sampler2D colorTexture;\nuniform float aggregationMode;\n\nin vec2 vTexCoords;\nin float vIntensityMin;\nin float vIntensityMax;\n\nout vec4 fragColor;\n\nvec4 getLinearColor(float value) {\n float factor = clamp(value * vIntensityMax, 0., 1.);\n vec4 color = texture(colorTexture, vec2(factor, 0.5));\n color.a *= min(value * vIntensityMin, 1.0);\n return color;\n}\n\nvoid main(void) {\n vec4 weights = texture(weightsTexture, vTexCoords);\n float weight = weights.r;\n\n if (aggregationMode > 0.5) {\n weight /= max(1.0, weights.a);\n }\n\n // discard pixels with 0 weight.\n if (weight <= 0.) {\n discard;\n }\n\n vec4 linearColor = getLinearColor(weight);\n linearColor.a *= opacity;\n fragColor = linearColor;\n}\n`;\n"],"file":"triangle-layer-fragment.glsl.js"}
|