All files / app/codeCharta/util/algorithm/streetLayout house.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 3/3
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2717x     17x   17x   8x       6x 6x 6x       6x           6x      
import BoundingBox from "./boundingBox"
import { CodeMapNode } from "../../../codeCharta.model"
import { Vector2 } from "three"
import { StreetViewHelper } from "./streetViewHelper"
 
export default class House extends BoundingBox {
    constructor(node: CodeMapNode) {
        super(node)
    }
 
    calculateDimension(metricName: string): void {
        this.metricValue = StreetViewHelper.calculateSize(this.mapNode, metricName)
        const size = Math.sqrt(this.metricValue)
        this.width = this.height = size
    }
 
    layout(_, origin: Vector2): CodeMapNode[] {
        const layoutNode: CodeMapNode = {
            ...this.mapNode,
            value: this.metricValue,
            rect: this.createMarginatedRectangle(origin),
            zOffset: 0
        }
        return [layoutNode]
    }
}