How to use the @here/harp-datasource-protocol.getFeatureId function in @here/harp-datasource-protocol

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 / geometry / TileDataAccessor.ts View on Github external
protected visitObject(object: THREE.Object3D): void {
        const featureData: TileFeatureData | undefined =
            object.userData !== undefined
                ? (object.userData.feature as TileFeatureData)
                : undefined;

        // early opt out if there is no feature data, or if the feature data has only a single id
        // and the visitor wants to ignore that featureId
        if (
            featureData === undefined ||
            (featureData.objInfos !== undefined &&
                featureData.objInfos.length === 1 &&
                !this.visitor.wantsFeature(getFeatureId(featureData.objInfos[0])))
        ) {
            return;
        }

        const geometryType = featureData.geometryType;
        if (geometryType === undefined) {
            logger.warn("#visitObject: visiting object failed, no geometryType", object);
            return;
        }

        assert(featureData.objInfos !== undefined, "featureData.ids missing");
        assert(featureData.starts !== undefined, "featureData.starts missing");
        assert(Array.isArray(featureData.starts), "featureData.starts is not an array");
        if (featureData.objInfos !== undefined && featureData.starts !== undefined) {
            assert(
                featureData.objInfos.length === featureData.starts.length,
github heremaps / harp.gl / @here / harp-mapview / lib / geometry / TileGeometryCreator.ts View on Github external
technique.fadeFar !== undefined
                        ? getPropertyValue(technique.fadeFar, displayZoomLevel)
                        : technique.fadeFar;

                for (let i = 0; i < numPositions; ++i) {
                    const x = positions.getX(i) + worldOffsetX;
                    const y = positions.getY(i);
                    const z = positions.getZ(i);
                    const label = text.stringCatalog[text.texts[i]];
                    if (label === undefined) {
                        // skip missing labels
                        continue;
                    }

                    const userData = text.objInfos !== undefined ? text.objInfos[i] : undefined;
                    const featureId = getFeatureId(userData);

                    const textElement = new TextElement(
                        ContextualArabicConverter.instance.convert(label!),
                        new THREE.Vector3(x, y, z),
                        textElementsRenderer.styleCache.getRenderStyle(tile, technique),
                        textElementsRenderer.styleCache.getLayoutStyle(tile, technique),
                        priority,
                        technique.xOffset || 0.0,
                        technique.yOffset || 0.0,
                        featureId,
                        technique.style
                    );

                    textElement.minZoomLevel =
                        technique.minZoomLevel !== undefined
                            ? technique.minZoomLevel
github heremaps / harp.gl / @here / harp-mapview / lib / poi / PoiManager.ts View on Github external
const poiTechnique = technique as PoiTechnique;
        const poiTableName = poiTechnique.poiTable;
        let poiName = poiTechnique.poiName;

        for (let i = 0; i < positions.count; ++i) {
            const x = positions.getX(i) + worldOffsetX;
            const y = positions.getY(i);
            const z = positions.getZ(i);

            assert(poiGeometry.texts.length > i);
            let imageTextureName = techniqueTextureName;
            const text: string = poiGeometry.stringCatalog[poiGeometry.texts[i]] || "";
            const userData =
                poiGeometry.objInfos !== undefined ? poiGeometry.objInfos[i] : undefined;
            const featureId = getFeatureId(userData);
            if (poiGeometry.imageTextures !== undefined && poiGeometry.imageTextures[i] >= 0) {
                assert(poiGeometry.imageTextures.length > i);
                imageTextureName = poiGeometry.stringCatalog[poiGeometry.imageTextures[i]];
            }
            if (poiTableName !== undefined) {
                // The POI name to be used is taken from the data, since it will
                // specify the name of the texture to use.

                // The POI name in the technique may override the POI name from the
                // data.
                poiName =
                    poiTechnique.poiName === undefined ? imageTextureName : poiTechnique.poiName;

                imageTextureName = undefined;
            }
github heremaps / harp.gl / @here / harp-omv-datasource / lib / OmvDecodedTileEmitter.ts View on Github external
}

                if (isTextTechnique(technique)) {
                    if (text === undefined) {
                        continue;
                    }
                    for (const path of validLines) {
                        const pathLengthSqr = Math2D.computeSquaredLineLength(path);
                        this.m_textPathGeometries.push({
                            technique: techniqueIndex,
                            path,
                            pathLengthSqr,
                            text: String(text),
                            objInfos: this.m_gatherFeatureAttributes
                                ? env.entries
                                : getFeatureId(env.entries)
                        });
                    }
                } else {
                    const lineMarkerTechnique = technique as LineMarkerTechnique;

                    let imageTexture = evaluateTechniqueAttr(
                        context,
                        lineMarkerTechnique.imageTexture
                    );

                    // TODO: `imageTextureField` and `imageTexturePrefix` and `imageTexturePostfix`
                    // are now deprecated

                    // TODO: Move to decoder independent parts of code.
                    if (typeof lineMarkerTechnique.imageTextureField === "string") {
                        const imageTextureValue = env.lookup(lineMarkerTechnique.imageTextureField);
github heremaps / harp.gl / @here / harp-omv-datasource / lib / OmvDecodedTileEmitter.ts View on Github external
texts.push(meshBuffers.addText(text));
                    } else {
                        texts.push(INVALID_ARRAY_INDEX);
                    }
                }

                // Always store the position, otherwise the following POIs will be
                // misplaced.
                if (shouldCreateTextGeometries) {
                    webMercatorTile2TargetWorld(extents, this.m_decodeInfo, pos, tmpV3);
                } else {
                    webMercatorTile2TargetTile(extents, this.m_decodeInfo, pos, tmpV3);
                }
                positions.push(tmpV3.x, tmpV3.y, tmpV3.z);
                objInfos.push(
                    this.m_gatherFeatureAttributes ? env.entries : getFeatureId(env.entries)
                );

                if (wantsPoi) {
                    if (imageTexture === undefined) {
                        imageTextures.push(INVALID_ARRAY_INDEX);
                    } else {
                        imageTextures.push(meshBuffers.addText(imageTexture));
                    }
                }
            }
        }
    }
github heremaps / harp.gl / @here / harp-mapview / lib / geometry / TileDataAccessor.ts View on Github external
protected visitMesh(meshObject: THREE.Mesh, featureData: TileFeatureData): void {
        const { objInfos, starts } = featureData;
        const geometryType = featureData.geometryType;

        // make linter happy: we already know that these both are valid
        if (objInfos === undefined || starts === undefined || geometryType === undefined) {
            return;
        }

        let geometryAccessor: IGeometryAccessor | undefined;

        for (let featureIndex = 0; featureIndex < objInfos.length; featureIndex++) {
            const featureId = getFeatureId(objInfos[featureIndex]);

            if (!this.visitor.wantsFeature(featureId)) {
                continue;
            }

            const featureStart = starts[featureIndex];
            let featureEnd: number = -1;

            // lazy creation of accessor, in case featureId was not wanted...
            if (geometryAccessor === undefined) {
                const bufferGeometry = this.getBufferGeometry(meshObject);
                if (bufferGeometry === undefined) {
                    continue;
                }

                if (bufferGeometry.index !== null) {
github heremaps / harp.gl / @here / harp-mapview / lib / PickHandler.ts View on Github external
if (
                intersect.object.userData === undefined ||
                intersect.object.userData.feature === undefined
            ) {
                pickResults.push(pickResult);
                continue;
            }

            const featureData: TileFeatureData = intersect.object.userData.feature;

            this.addObjInfo(featureData, intersect, pickResult);

            if (featureData.objInfos !== undefined) {
                const featureId =
                    featureData.objInfos.length === 1
                        ? getFeatureId(featureData.objInfos[0])
                        : undefined;
                pickResult.featureId = featureId;
            }

            let pickObjectType: PickObjectType;

            switch (featureData.geometryType) {
                case GeometryType.Point:
                case GeometryType.Text:
                    pickObjectType = PickObjectType.Point;
                    break;
                case GeometryType.Line:
                case GeometryType.ExtrudedLine:
                case GeometryType.SolidLine:
                case GeometryType.TextPath:
                    pickObjectType = PickObjectType.Line;
github heremaps / harp.gl / @here / harp-omv-datasource / lib / OmvDecodedTileEmitter.ts View on Github external
localLines.forEach(aLine => {
                    triangulateLine(aLine, lineWidth, positions, indices, addCircle);
                    featureStarts.push(start);
                    objInfos.push(
                        this.m_gatherFeatureAttributes ? env.entries : getFeatureId(env.entries)
                    );
                });
github heremaps / harp.gl / @here / harp-mapview / lib / geometry / TileGeometryCreator.ts View on Github external
(technique.priority !== undefined
                        ? getPropertyValue(technique.priority, displayZoomLevel)
                        : 0) +
                    (maxPathLengthSqr > 0
                        ? (SORT_WEIGHT_PATH_LENGTH * textPath.pathLengthSqr) / maxPathLengthSqr
                        : 0);
                const fadeNear =
                    technique.fadeNear !== undefined
                        ? getPropertyValue(technique.fadeNear, displayZoomLevel)
                        : technique.fadeNear;
                const fadeFar =
                    technique.fadeFar !== undefined
                        ? getPropertyValue(technique.fadeFar, displayZoomLevel)
                        : technique.fadeFar;
                const userData = textPath.objInfos;
                const featureId = getFeatureId(userData);
                const textElement = new TextElement(
                    ContextualArabicConverter.instance.convert(textPath.text),
                    path,
                    textElementsRenderer.styleCache.getRenderStyle(tile, technique),
                    textElementsRenderer.styleCache.getLayoutStyle(tile, technique),
                    priority,
                    technique.xOffset !== undefined ? technique.xOffset : 0.0,
                    technique.yOffset !== undefined ? technique.yOffset : 0.0,
                    featureId,
                    technique.style,
                    fadeNear,
                    fadeFar
                );
                textElement.minZoomLevel =
                    technique.minZoomLevel !== undefined
                        ? technique.minZoomLevel