From d55b652b0edb2341ce2cd2ada6627fe1c76392e1 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 24 Mar 2023 15:49:33 -0700 Subject: [PATCH 1/2] avoid extra loops when terrain does not exist --- src/symbol/placement.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/symbol/placement.ts b/src/symbol/placement.ts index 0e86e93e93e..03f4f6c8a4f 100644 --- a/src/symbol/placement.ts +++ b/src/symbol/placement.ts @@ -460,6 +460,9 @@ export class Placement { bucket.deserializeCollisionBoxes(collisionBoxArray); } + const tileID = this.retainedQueryData[bucket.bucketInstanceId].tileID; + const getElevation = this.terrain ? (x: number, y: number) => this.terrain.getElevation(tileID, x, y) : null; + const placeSymbol = (symbolInstance: SymbolInstance, collisionArrays: CollisionArrays) => { if (seenCrossTileIDs[symbolInstance.crossTileID]) return; if (holdingForFade) { @@ -494,11 +497,13 @@ export class Placement { } // update elevation of collisionArrays - const tileID = this.retainedQueryData[bucket.bucketInstanceId].tileID; - const getElevation = this.terrain ? (x: number, y: number) => this.terrain.getElevation(tileID, x, y) : null; - for (const boxType of ['textBox', 'verticalTextBox', 'iconBox', 'verticalIconBox']) { - const box = collisionArrays[boxType]; - if (box) box.elevation = getElevation ? getElevation(box.anchorPointX, box.anchorPointY) : 0; + if (getElevation) { + for (const boxType of ['textBox', 'verticalTextBox', 'iconBox', 'verticalIconBox']) { + const box = collisionArrays[boxType]; + if (box) { + box.elevation = getElevation(box.anchorPointX, box.anchorPointY); + } + } } const textBox = collisionArrays.textBox; From ccba4a1a8460c95dd40bb969fb0a05b0b8d8eaa0 Mon Sep 17 00:00:00 2001 From: "Yi Zhang (BING)" Date: Tue, 28 Mar 2023 09:13:47 -0700 Subject: [PATCH 2/2] removed the block according to PR feedback --- src/symbol/placement.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/symbol/placement.ts b/src/symbol/placement.ts index 03f4f6c8a4f..62ba3ef3c95 100644 --- a/src/symbol/placement.ts +++ b/src/symbol/placement.ts @@ -496,16 +496,6 @@ export class Placement { verticalTextFeatureIndex = collisionArrays.verticalTextFeatureIndex; } - // update elevation of collisionArrays - if (getElevation) { - for (const boxType of ['textBox', 'verticalTextBox', 'iconBox', 'verticalIconBox']) { - const box = collisionArrays[boxType]; - if (box) { - box.elevation = getElevation(box.anchorPointX, box.anchorPointY); - } - } - } - const textBox = collisionArrays.textBox; if (textBox) {