UNPKG

s2maps-gpu

Version:

S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.

25 lines (24 loc) 1 kB
import type { NestedKey } from './style.spec.js'; import type { Properties } from 'gis-tools/index.js'; /** * Coalesce text layout property "field" * * examples: * * ```ts * // example 1 * const properties = { abbr: 'U.S.', name: 'United States', ... } * const field = ["\"", "?abbr,?name", "\""] // here we coallese to abbr if the property exists, otherwise we fallback on name * cooalesceField(field) // returns "U.S." or "United States" depending on whether abbr exists * * // example 2 * const properties = { type: 'airplane', ... } * const field = ["?type", "-16"] * cooalesceField(field) // 'airplane-16' * ``` * @param field - string field, array of string fields, or nested key * @param properties - properties to coalesce * @param fieldIsKey - whether the field is the key in properties or a value to coalesce * @returns the coalesced field */ export default function coalesceField(field: string | string[] | NestedKey, properties: Properties, fieldIsKey?: boolean): string;