How to use the @here/harp-utils.getOptionValue function in @here/harp-utils

To help you get started, we’ve selected a few @here/harp-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heremaps / harp.gl / @here / harp-mapview / lib / text / TextStyleCache.ts View on Github external
},
                fontStyle:
                    technique.fontStyle === "Regular" ||
                    technique.fontStyle === "Bold" ||
                    technique.fontStyle === "Italic" ||
                    technique.fontStyle === "BoldItalic"
                        ? FontStyle[technique.fontStyle]
                        : defaultRenderParams.fontStyle,
                fontVariant:
                    technique.fontVariant === "Regular" ||
                    technique.fontVariant === "AllCaps" ||
                    technique.fontVariant === "SmallCaps"
                        ? FontVariant[technique.fontVariant]
                        : defaultRenderParams.fontVariant,
                rotation: getOptionValue(technique.rotation, defaultRenderParams.rotation),
                color: getOptionValue(this.m_colorMap.get(cacheId), defaultRenderParams.color),
                backgroundColor: getOptionValue(
                    this.m_colorMap.get(cacheId + "_bg"),
                    defaultRenderParams.backgroundColor
                ),
                opacity:
                    technique.opacity !== undefined
                        ? getPropertyValue(technique.opacity, Math.floor(zoomLevel))
                        : defaultRenderParams.opacity,
                backgroundOpacity:
                    technique.backgroundOpacity !== undefined
                        ? getPropertyValue(technique.backgroundOpacity, Math.floor(zoomLevel))
                        : technique.backgroundColor !== undefined &&
                          technique.backgroundSize !== undefined &&
                          getPropertyValue(technique.backgroundSize, Math.floor(zoomLevel)) > 0
                        ? 1.0 // make label opaque when backgroundColor and backgroundSize are set
                        : defaultRenderParams.backgroundOpacity
github heremaps / harp.gl / @here / harp-mapview / lib / ConcurrentWorkerSet.ts View on Github external
start(options?: ConcurrentWorkerSetOptions) {
        if (options !== undefined) {
            this.m_options = options;
        }
        if (!this.m_stopped) {
            throw new Error("ConcurrentWorker set already started");
        }

        this.m_workerCount = getOptionValue(
            this.m_options.workerCount,
            typeof navigator !== "undefined" && navigator.hardwareConcurrency !== undefined
                ? // We need to have at least one worker
                  THREE.Math.clamp(navigator.hardwareConcurrency - 1, 1, 2)
                : undefined,
            DEFAULT_WORKER_COUNT
        );

        // Initialize the workers. The workers now have an ID to identify specific workers and
        // handle their busy state.
        const timeout = getOptionValue(
            this.m_options.workerConnectionTimeout,
            DEFAULT_WORKER_INITIALIZATION_TIMEOUT
        );
        for (let workerId = 0; workerId < this.m_workerCount; ++workerId) {
            const workerPromise = WorkerLoader.startWorker(this.m_options.scriptUrl, timeout).then(
github heremaps / harp.gl / @here / harp-omv-datasource / lib / OmvDecodedTileEmitter.ts View on Github external
? styleSetDefaultHeight
                    : 0;
        }

        if (floorHeight === undefined) {
            const featureMinHeight = context.env.lookup("min_height") as number;
            floorHeight = featureMinHeight !== undefined && !isFilled ? featureMinHeight : 0;
        }

        // Prevent that extruded buildings are completely flat (can introduce errors in normal
        // computation and extrusion).
        if (height === floorHeight) {
            height += MIN_BUILDING_HEIGHT;
        }

        const styleSetConstantHeight = getOptionValue(
            extrudedPolygonTechnique.constantHeight,
            false
        );

        this.m_decodeInfo.tileBounds.getCenter(tempTileOrigin);

        const {
            positions,
            normals,
            textureCoordinates,
            colors,
            extrusionAxis,
            indices,
            edgeIndices,
            groups
        } = meshBuffers;
github heremaps / harp.gl / @here / harp-mapview / lib / ConcurrentWorkerSet.ts View on Github external
if (!this.m_stopped) {
            throw new Error("ConcurrentWorker set already started");
        }

        this.m_workerCount = getOptionValue(
            this.m_options.workerCount,
            typeof navigator !== "undefined" && navigator.hardwareConcurrency !== undefined
                ? // We need to have at least one worker
                  THREE.Math.clamp(navigator.hardwareConcurrency - 1, 1, 2)
                : undefined,
            DEFAULT_WORKER_COUNT
        );

        // Initialize the workers. The workers now have an ID to identify specific workers and
        // handle their busy state.
        const timeout = getOptionValue(
            this.m_options.workerConnectionTimeout,
            DEFAULT_WORKER_INITIALIZATION_TIMEOUT
        );
        for (let workerId = 0; workerId < this.m_workerCount; ++workerId) {
            const workerPromise = WorkerLoader.startWorker(this.m_options.scriptUrl, timeout).then(
                worker => {
                    const listener = (evt: Event): void => {
                        this.onWorkerMessage(workerId, evt as MessageEvent);
                    };

                    worker.addEventListener("message", listener);
                    this.m_workers.push(worker);
                    this.m_availableWorkers.push(worker);
                    return {
                        worker,
                        listener
github heremaps / harp.gl / @here / harp-omv-datasource / lib / OmvDecodedTileEmitter.ts View on Github external
} = meshBuffers;

        const featureStride = texCoordType !== undefined ? 4 : 2;
        const vertexStride = featureStride + 2;
        const isSpherical = this.m_decodeInfo.targetProjection.type === ProjectionType.Spherical;

        const edgeWidth = isExtruded
            ? extrudedPolygonTechnique.lineWidth || 0.0
            : isFilled
            ? fillTechnique.lineWidth || 0.0
            : 0.0;
        const hasEdges = edgeWidth > 0.0;

        let color: THREE.Color | undefined;
        if (isExtrudedPolygonTechnique(technique)) {
            if (getOptionValue(technique.vertexColors, false)) {
                let colorValue = evaluateTechniqueAttr(context, technique.color);
                if (colorValue === undefined) {
                    const featureColor = context.env.lookup("color");
                    if (this.isColorStringValid(featureColor)) {
                        colorValue = String(featureColor);
                    }
                }
                if (colorValue === undefined) {
                    colorValue = evaluateTechniqueAttr(
                        context,
                        technique.defaultColor,
                        0x000000
                    );
                }

                if (colorValue === undefined) {
github heremaps / harp.gl / @here / harp-mapview / lib / copyrights / CopyrightInfo.ts View on Github external
continue;
            }

            for (const sourceInfo of source) {
                const existingInfo = result.find(
                    findItem =>
                        findItem.id === sourceInfo.id ||
                        (findItem.label !== undefined && findItem.label === sourceInfo.label)
                );

                if (existingInfo === undefined) {
                    result.push({ ...sourceInfo });
                } else {
                    existingInfo.year = MathUtils.max2(sourceInfo.year, existingInfo.year);
                    existingInfo.label = getOptionValue(sourceInfo.label, existingInfo.label);
                    existingInfo.link = getOptionValue(sourceInfo.link, existingInfo.link);
                }
            }
        }
        return result;
    }
github heremaps / harp.gl / @here / harp-mapview / lib / ThemeLoader.ts View on Github external
static async resolveBaseTheme(theme: Theme, options?: ThemeLoadOptions): Promise {
        options = options || {};
        if (theme.extends === undefined) {
            return theme;
        }

        const maxInheritanceDepth = getOptionValue(
            options.maxInheritanceDepth,
            DEFAULT_MAX_THEME_INTHERITANCE_DEPTH
        );
        if (maxInheritanceDepth <= 0) {
            throw new Error(`maxInheritanceDepth reached when attempting to load base theme`);
        }

        const baseTheme = theme.extends;
        delete theme.extends;

        const actualBaseTheme = await ThemeLoader.load(baseTheme, {
            ...options,
            resolveDefinitions: false,
            maxInheritanceDepth: maxInheritanceDepth - 1
        });
github heremaps / harp.gl / @here / harp-mapview / lib / text / TextStyleCache.ts View on Github external
| undefined;

            const horizontalAlignment: HorizontalAlignment | undefined =
                hAlignment === "Left" || hAlignment === "Center" || hAlignment === "Right"
                    ? HorizontalAlignment[hAlignment]
                    : defaultLayoutParams.horizontalAlignment;

            const verticalAlignment: VerticalAlignment | undefined =
                vAlignment === "Above" || vAlignment === "Center" || vAlignment === "Below"
                    ? VerticalAlignment[vAlignment]
                    : defaultLayoutParams.verticalAlignment;

            const layoutParams = {
                tracking: getOptionValue(technique.tracking, defaultLayoutParams.tracking),
                leading: getOptionValue(technique.leading, defaultLayoutParams.leading),
                maxLines: getOptionValue(technique.maxLines, defaultLayoutParams.maxLines),
                lineWidth: getOptionValue(technique.lineWidth, defaultLayoutParams.lineWidth),
                canvasRotation: getOptionValue(
                    technique.canvasRotation,
                    defaultLayoutParams.canvasRotation
                ),
                lineRotation: getOptionValue(
                    technique.lineRotation,
                    defaultLayoutParams.lineRotation
                ),
                wrappingMode:
                    technique.wrappingMode === "None" ||
                    technique.wrappingMode === "Character" ||
                    technique.wrappingMode === "Word"
                        ? WrappingMode[technique.wrappingMode]
                        : defaultLayoutParams.wrappingMode,
                horizontalAlignment,
github heremaps / harp.gl / @here / harp-mapview / lib / text / TextStyleCache.ts View on Github external
private createTextElementStyle(
        style: TextStyleDefinition,
        styleName: string
    ): TextElementStyle {
        return {
            name: styleName,
            fontCatalog: getOptionValue(style.fontCatalogName, this.m_defaultStyle.fontCatalog),
            renderParams: {
                fontName: style.fontName,
                fontSize: {
                    unit: FontUnit.Pixel,
                    size: 32,
                    backgroundSize: style.backgroundSize || 8
                },
                fontStyle:
                    style.fontStyle === "Regular" ||
                    style.fontStyle === "Bold" ||
                    style.fontStyle === "Italic" ||
                    style.fontStyle === "BoldItalic"
                        ? FontStyle[style.fontStyle]
                        : undefined,
                fontVariant:
                    style.fontVariant === "Regular" ||