How to use @here/harp-datasource-protocol - 10 common examples

To help you get started, we’ve selected a few @here/harp-datasource-protocol 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
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
            };

            const themeRenderParams = this.getTextElementStyle(technique.style).renderParams;
            renderStyle = new TextRenderStyle({
                ...themeRenderParams,
                ...renderParams
            });
            this.m_textRenderStyleCache.set(cacheId, renderStyle);
        }

        return renderStyle;
    }
github heremaps / harp.gl / @here / harp-omv-datasource / lib / OmvDebugLabelsTile.ts View on Github external
indices.push(pointIndex - 4);
                            indices.push(pointIndex - 2);
                            indices.push(pointIndex - 1);

                            if (debugTextPathsFull) {
                                // give point index a label
                                const label: string =
                                    pathIndex % 5 === 0
                                        ? text + ":" + pathIndex
                                        : Number(pathIndex).toString();
                                const labelElement = new TextElement(
                                    ContextualArabicConverter.instance.convert(label),
                                    new THREE.Vector3(x + worldOffsetX, y, z),
                                    textRenderStyle,
                                    textLayoutStyle,
                                    getPropertyValue(technique.priority || 0, zoomLevel),
                                    technique.xOffset || 0.0,
                                    technique.yOffset || 0.0
                                );
                                labelElement.minZoomLevel = technique.minZoomLevel;
                                labelElement.mayOverlap = true;
                                labelElement.reserveSpace = false;
                                labelElement.alwaysOnTop = true;
                                labelElement.ignoreDistance = true;
                                this.addUserTextElement(labelElement);
                            }
                        }
                    }

                    // the lines of a path share a common geometry
                    const N = textPath.path.length / 3;
                    for (let i = 0; i < N; ++i) {
github heremaps / harp.gl / @here / harp-geojson-datasource / lib / GeoJsonTile.ts View on Github external
) {
        const label = DEFAULT_LABELED_ICON.label;
        const priority =
            technique.priority === undefined ? DEFAULT_LABELED_ICON.priority : technique.priority;
        const xOffset = getPropertyValue(technique.xOffset, zoomLevel);
        const yOffset = getPropertyValue(technique.yOffset, zoomLevel);

        const featureId = DEFAULT_LABELED_ICON.featureId;

        const styleCache = this.mapView.textElementsRenderer.styleCache;
        const textElement = new TextElement(
            ContextualArabicConverter.instance.convert(label),
            position,
            styleCache.getRenderStyle(this, technique),
            styleCache.getLayoutStyle(this, technique),
            getPropertyValue(priority, this.mapView.zoomLevel),
            xOffset === undefined ? DEFAULT_LABELED_ICON.xOffset : xOffset,
            yOffset === undefined ? DEFAULT_LABELED_ICON.yOffset : yOffset,
            featureId
        );

        // Set the userData of the TextElement to the geojsonProperties, then it will be available
        // for picking.
        if (geojsonProperties !== undefined) {
            textElement.userData = geojsonProperties;
        }

        const mayOverlap =
            technique.iconMayOverlap === undefined
                ? DEFAULT_LABELED_ICON.iconMayOverlap
                : technique.iconMayOverlap;
        const reserveSpace =
github heremaps / harp.gl / @here / harp-mapview / lib / poi / PoiManager.ts View on Github external
): TextElement {
        const textElementsRenderer = this.mapView.textElementsRenderer;
        const priority = technique.priority !== undefined ? technique.priority : 0;
        const positions = Array.isArray(x) ? (x as THREE.Vector3[]) : new THREE.Vector3(x, y, z);

        // The current zoomlevel of mapview. Since this method is called for all tiles in the
        // VisibleTileSet we can be sure that the current zoomlevel matches the zoomlevel where
        // the tile should be shown.
        const displayZoomLevel = this.mapView.zoomLevel;
        const fadeNear =
            technique.fadeNear !== undefined
                ? getPropertyValue(technique.fadeNear, displayZoomLevel)
                : technique.fadeNear;
        const fadeFar =
            technique.fadeFar !== undefined
                ? getPropertyValue(technique.fadeFar, displayZoomLevel)
                : technique.fadeFar;
        const xOffset = getPropertyValue(technique.xOffset, displayZoomLevel);
        const yOffset = getPropertyValue(technique.yOffset, displayZoomLevel);

        const textElement: TextElement = new TextElement(
            ContextualArabicConverter.instance.convert(text),
            positions,
            textElementsRenderer.styleCache.getRenderStyle(tile, technique),
            textElementsRenderer.styleCache.getLayoutStyle(tile, technique),
            getPropertyValue(priority, displayZoomLevel),
            xOffset !== undefined ? xOffset : 0.0,
            yOffset !== undefined ? yOffset : 0.0,
            featureId,
            technique.style,
            fadeNear,
            fadeFar
github heremaps / harp.gl / @here / harp-geojson-datasource / lib / GeoJsonTile.ts View on Github external
const priority =
            technique.priority === undefined ? DEFAULT_LABELED_ICON.priority : technique.priority;
        const xOffset =
            technique.xOffset === undefined ? DEFAULT_LABELED_ICON.xOffset : technique.xOffset;
        const yOffset =
            technique.yOffset === undefined ? DEFAULT_LABELED_ICON.yOffset : technique.yOffset;

        const featureId = DEFAULT_LABELED_ICON.featureId;

        const styleCache = this.mapView.textElementsRenderer.styleCache;
        const textElement = new TextElement(
            ContextualArabicConverter.instance.convert(text),
            position,
            styleCache.getRenderStyle(this, technique),
            styleCache.getLayoutStyle(this, technique),
            getPropertyValue(priority, this.mapView.zoomLevel),
            xOffset,
            yOffset,
            featureId
        );

        // Set the userData of the TextElement to the geojsonProperties, then it will be available
        // for picking.
        if (geojsonProperties !== undefined) {
            textElement.userData = geojsonProperties;
        }

        const mayOverlap =
            technique.mayOverlap === undefined
                ? DEFAULT_LABELED_ICON.iconMayOverlap
                : technique.mayOverlap;
        const distanceScale = DEFAULT_TEXT_DISTANCE_SCALE;
github heremaps / harp.gl / @here / harp-mapview / lib / geometry / TileGeometryCreator.ts View on Github external
)
                                );
                            }

                            if (outlineTechnique.secondaryWidth !== undefined) {
                                const techniqueLineWidth = getPropertyValue(
                                    outlineTechnique.lineWidth!,
                                    mapView.zoomLevel,
                                    mapView.pixelToWorld
                                );
                                const techniqueSecondaryWidth = getPropertyValue(
                                    outlineTechnique.secondaryWidth!,
                                    mapView.zoomLevel,
                                    mapView.pixelToWorld
                                );
                                const techniqueOpacity = getPropertyValue(
                                    outlineTechnique.opacity,
                                    mapView.zoomLevel
                                );
                                // hide outline when it's equal or smaller then line to avoid subpixel contour
                                const lineWidth =
                                    techniqueSecondaryWidth <= techniqueLineWidth &&
                                    (techniqueOpacity === undefined || techniqueOpacity === 1)
                                        ? 0
                                        : techniqueSecondaryWidth;
                                lineMaterial.lineWidth = lineWidth * unitFactor * 0.5;
                            }
                        }
                    );
github heremaps / harp.gl / @here / harp-mapview / lib / geometry / TileGeometryCreator.ts View on Github external
| MapMeshStandardMaterial
                                          | MapMeshBasicMaterial;

                                      extrudedMaterial.color.set(
                                          getPropertyValue(technique.color!, mapView.zoomLevel)
                                      );
                                  }
                                : undefined
                        );
                    }
                }

                this.addFeatureData(srcGeometry, technique, object);
                this.addGeometryObjInfos(tile, srcGeometry, technique, object);

                if (isExtrudedPolygonTechnique(technique) || isFillTechnique(technique)) {
                    // filled polygons are normal meshes, and need transparency only when fading or
                    // dynamic properties is defined.
                    const hasDynamicColor =
                        (technique.color !== undefined && Expr.isExpr(technique.color)) ||
                        (isExtrudedPolygonTechnique(technique) && Expr.isExpr(technique.emissive));
                    if (technique.fadeFar !== undefined || hasDynamicColor) {
                        const fadingParams = this.getFadingParams(displayZoomLevel, technique);
                        FadingFeature.addRenderHelper(
                            object,
                            viewRanges,
                            fadingParams.fadeNear,
                            fadingParams.fadeFar,
                            true,
                            hasDynamicColor
                                ? (renderer, mat) => {
                                      const polygonMaterial = mat as
github heremaps / harp.gl / @here / harp-mapview / lib / geometry / TileGeometryCreator.ts View on Github external
if (extrusionAnimationEnabled) {
                        extrudedObjects.push({
                            object: depthPassMesh,
                            materialFeature: true
                        });
                    }

                    setDepthPrePassStencil(depthPassMesh, object as THREE.Mesh);
                }

                this.registerTileObject(tile, object, technique.kind);
                objects.push(object);

                // Add the extruded building edges as a separate geometry.
                if (isExtrudedPolygonTechnique(technique) && srcGeometry.edgeIndex !== undefined) {
                    const edgeGeometry = new THREE.BufferGeometry();
                    edgeGeometry.setAttribute("position", bufferGeometry.getAttribute("position"));

                    const colorAttribute = bufferGeometry.getAttribute("color");
                    if (colorAttribute !== undefined) {
                        edgeGeometry.setAttribute("color", colorAttribute);
                    }

                    const extrusionAttribute = bufferGeometry.getAttribute("extrusionAxis");
                    if (extrusionAttribute !== undefined) {
                        edgeGeometry.setAttribute("extrusionAxis", extrusionAttribute);
                    }

                    const normalAttribute = bufferGeometry.getAttribute("normal");
                    if (normalAttribute !== undefined) {
                        edgeGeometry.setAttribute("normal", normalAttribute);
github heremaps / harp.gl / @here / harp-omv-datasource / lib / OmvDecodedTileEmitter.ts View on Github external
private getTextureCoordinateType(technique: Technique): TextureCoordinateType | undefined {
        // Set TileSpace coordinate type to generate texture coordinates for the displacement map
        // used in elevation overlay.
        if (
            (isFillTechnique(technique) ||
                isSolidLineTechnique(technique) ||
                isExtrudedPolygonTechnique(technique)) &&
            this.m_enableElevationOverlay
        ) {
            return TextureCoordinateType.TileSpace;
        }

        return textureCoordinateType(technique);
    }
github heremaps / harp.gl / @here / harp-mapview / lib / geometry / TileGeometryLoader.ts View on Github external
export function setDefaultGeometryKind(technique: Technique): GeometryKind | GeometryKindSet {
        let geometryKind = technique.kind;

        // Set default kind based on technique.
        if (geometryKind === undefined) {
            if (isFillTechnique(technique)) {
                geometryKind = GeometryKind.Area;
            } else if (
                isLineTechnique(technique) ||
                isSolidLineTechnique(technique) ||
                isSegmentsTechnique(technique) ||
                isExtrudedLineTechnique(technique)
            ) {
                geometryKind = GeometryKind.Line;
            } else if (isExtrudedPolygonTechnique(technique)) {
                geometryKind = GeometryKind.Building;
            } else if (
                isPoiTechnique(technique) ||
                isLineMarkerTechnique(technique) ||
                isTextTechnique(technique)
            ) {
                geometryKind = GeometryKind.Label;
            } else {
                geometryKind = GeometryKind.All;
            }