Add types and comments to make combined image+text decluttering clearer

This commit is contained in:
Andreas Hocevar
2020-10-05 15:21:40 +02:00
parent 187a216379
commit c9ebf79df5
6 changed files with 48 additions and 33 deletions
+10 -8
View File
@@ -346,10 +346,11 @@ function renderPointGeometry(
) {
const imageStyle = style.getImage();
const textStyle = style.getText();
let sharedData;
/** @type {import("../render/canvas.js").DeclutterImageWithText} */
let declutterImageWithText;
if (opt_declutterBuilderGroup) {
builderGroup = opt_declutterBuilderGroup;
sharedData =
declutterImageWithText =
imageStyle && textStyle && textStyle.getText() ? {} : undefined;
}
if (imageStyle) {
@@ -360,7 +361,7 @@ function renderPointGeometry(
style.getZIndex(),
BuilderType.IMAGE
);
imageReplay.setImageStyle(imageStyle, sharedData);
imageReplay.setImageStyle(imageStyle, declutterImageWithText);
imageReplay.drawPoint(geometry, feature);
}
if (textStyle && textStyle.getText()) {
@@ -368,7 +369,7 @@ function renderPointGeometry(
style.getZIndex(),
BuilderType.TEXT
);
textReplay.setTextStyle(textStyle, sharedData);
textReplay.setTextStyle(textStyle, declutterImageWithText);
textReplay.drawText(geometry, feature);
}
}
@@ -389,10 +390,11 @@ function renderMultiPointGeometry(
) {
const imageStyle = style.getImage();
const textStyle = style.getText();
let sharedData;
/** @type {import("../render/canvas.js").DeclutterImageWithText} */
let declutterImageWithText;
if (opt_declutterBuilderGroup) {
builderGroup = opt_declutterBuilderGroup;
sharedData =
declutterImageWithText =
imageStyle && textStyle && textStyle.getText() ? {} : undefined;
}
if (imageStyle) {
@@ -403,7 +405,7 @@ function renderMultiPointGeometry(
style.getZIndex(),
BuilderType.IMAGE
);
imageReplay.setImageStyle(imageStyle, sharedData);
imageReplay.setImageStyle(imageStyle, declutterImageWithText);
imageReplay.drawMultiPoint(geometry, feature);
}
if (textStyle && textStyle.getText()) {
@@ -411,7 +413,7 @@ function renderMultiPointGeometry(
style.getZIndex(),
BuilderType.TEXT
);
textReplay.setTextStyle(textStyle, sharedData);
textReplay.setTextStyle(textStyle, declutterImageWithText);
textReplay.drawText(geometry, feature);
}
}