import { MapEnv } from "@here/harp-datasource-protocol/index-decoder" ; import { LoggerManager } from "@here/harp-utils" ; import { OmvFeatureModifier } from "./OmvDataFilter" ; const logger = LoggerManager . instance . create ( "OmvPoliticalViewFeatureModifier" ) ; hidden export class OmvPoliticalViewFeatureModifier implements OmvFeatureModifier { private readonly m_countryCode : string ; param pov constructor ( pov ) { this . m_countryCode = pov ; } param layer param env param level returns doProcessPointFeature ( layer , env , level ) { return true ; } param layer param env returns doProcessLineFeature ( layer , env , level ) { this . rewriteEnvironment ( layer , env ) ; return true ; } param layer param env param level returns doProcessPolygonFeature ( layer , env , level ) { return true ; } param layer param env private rewriteEnvironment ( layer , env ) { if ( this . isPoliticalViewLayer ( layer ) ) { this . updateEnvironment ( env , this . m_countryCode , "kind" ) ; } } private updateEnvironment ( env , countryCode , propName ) { const value = this . getAlternativePov ( env , countryCode , propName ) ; if ( value !== undefined ) { env . entries [ propName ] = value ; } } private getAlternativePov ( env , countryCode , propName ) { logger . log ( "Get alternate POV: " , JSON . stringify ( env ) ) ; const cc = countryCode ; const value = env . lookup ( `${ propName }:${ cc }` ) ; logger . log ( "Lookup POV: " , `${ propName }:${ cc }` , value ) ; if ( typeof value === "string" && value . length > 0 ) { logger . log ( "Found POV: " , `${ propName }:${ cc }` , value ) ; return value ; } else { return undefined ; } } private isPoliticalViewLayer ( layer ) { return layer === "boundaries" ; } }