New decluttering implementation

This commit is contained in:
Andreas Hocevar
2020-09-20 23:36:27 +02:00
parent 7a5e0db59f
commit 8e862766fc
22 changed files with 784 additions and 330 deletions

View File

@@ -91,6 +91,13 @@ class CanvasImageBuilder extends CanvasBuilder {
* @type {number|undefined}
*/
this.width_ = undefined;
/**
* Data shared with a text builder for combined decluttering.
* @private
* @type {Object}
*/
this.sharedData_ = undefined;
}
/**
@@ -125,6 +132,7 @@ class CanvasImageBuilder extends CanvasBuilder {
(this.scale_[1] * this.pixelRatio) / this.imagePixelRatio_,
],
Math.ceil(this.width_ * this.imagePixelRatio_),
this.sharedData_,
]);
this.hitDetectionInstructions.push([
CanvasInstruction.DRAW_IMAGE,
@@ -142,6 +150,7 @@ class CanvasImageBuilder extends CanvasBuilder {
this.rotation_,
this.scale_,
this.width_,
this.sharedData_,
]);
this.endGeometry(feature);
}
@@ -178,6 +187,7 @@ class CanvasImageBuilder extends CanvasBuilder {
(this.scale_[1] * this.pixelRatio) / this.imagePixelRatio_,
],
Math.ceil(this.width_ * this.imagePixelRatio_),
this.sharedData_,
]);
this.hitDetectionInstructions.push([
CanvasInstruction.DRAW_IMAGE,
@@ -195,12 +205,13 @@ class CanvasImageBuilder extends CanvasBuilder {
this.rotation_,
this.scale_,
this.width_,
this.sharedData_,
]);
this.endGeometry(feature);
}
/**
* @return {import("./Builder.js").SerializableInstructions} the serializable instructions.
* @return {import("../canvas.js").SerializableInstructions} the serializable instructions.
*/
finish() {
this.reverseHitDetectionInstructions();
@@ -223,8 +234,9 @@ class CanvasImageBuilder extends CanvasBuilder {
/**
* @param {import("../../style/Image.js").default} imageStyle Image style.
* @param {Object=} opt_sharedData Shared data.
*/
setImageStyle(imageStyle) {
setImageStyle(imageStyle, opt_sharedData) {
const anchor = imageStyle.getAnchor();
const size = imageStyle.getSize();
const hitDetectionImage = imageStyle.getHitDetectionImage();
@@ -243,6 +255,7 @@ class CanvasImageBuilder extends CanvasBuilder {
this.rotation_ = imageStyle.getRotation();
this.scale_ = imageStyle.getScaleArray();
this.width_ = size[0];
this.sharedData_ = opt_sharedData;
}
}