import { LoggerManager } from "@here/harp-utils" ; import { Env } from "./Env" ; import { Expr , ExprScope , Value } from "./Expr" ; import { Pixels } from "./Pixels" ; import { RGBA } from "./RGBA" ; import { parseStringEncodedNumeral } from "./StringEncodedNumeral" ; const logger = LoggerManager . instance . create ( "PropertyValue" ) ; param property param env - The  Env used to evaluate the property
 *  param cache export function getPropertyValue ( property , env , cache ? ) { if ( Expr . isExpr ( property ) ) { try { let r = property . evaluate ( env , ExprScope . Dynamic , cache ) ; if ( typeof r === "string" ) { r = RGBA . parse ( r ) ?? Pixels . parse ( r ) ?? r ; } if ( r instanceof RGBA ) { return r . getHex ( ) ; } else if ( r instanceof Pixels ) { return r . value * ( Number ( env . lookup ( "$pixelToMeters" ) ) ?? 1 ) ; } return r ; } catch ( error ) { logger . error ( "failed to evaluate expression" , JSON . stringify ( property ) , "error" , String ( error ) ) ; return null ; } } if ( property === null || typeof property === "undefined" ) { return null ; } else if ( typeof property !== "string" ) { return property ; } else { const pixelToMeters = ( env . lookup ( "$pixelToMeters" ) as number ) || 1 ; const value = parseStringEncodedNumeral ( property , pixelToMeters ) ; return value !== undefined ? value : property ; } }