How to use the @here/harp-datasource-protocol/index-decoder.MapEnv 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-examples / decoder / custom_decoder.ts View on Github external
private processLineFeatures(
        data: ArrayBufferLike | {},
        tileKey: TileKey,
        styleSetEvaluator: StyleSetEvaluator,
        projection: Projection,
        geometries: Geometry[]
    ) {
        // Setup an environment for this "layer". This does normaly come from the data and should
        // contain all the attributes of a specific feature, so that it can be styled properly.
        const env = new MapEnv({ layer: "line-layer" });

        const techniques = styleSetEvaluator.getMatchingTechniques(env);

        const geoCenter = webMercatorTilingScheme.getGeoBox(tileKey).center;
        const worldCenter = projection.projectPoint(geoCenter, new Vector3());

        // Convert the input coordinates to local world coord coordinates (i.e. projected world
        // coordinates relative to the tile center in world coordinates)
        const worldPoints = this.convertToLocalWorldCoordinates(
            data,
            geoCenter,
            projection,
            worldCenter
        );

        // Create actual line-geometry out of the data.
github heremaps / harp.gl / @here / harp-examples / decoder / custom_decoder.ts View on Github external
private processMeshFeatures(
        tileKey: TileKey,
        styleSetEvaluator: StyleSetEvaluator,
        geometries: Geometry[]
    ) {
        const env = new MapEnv({ layer: "mesh-layer" });
        const techniques = styleSetEvaluator.getMatchingTechniques(env);

        // Scale the mesh so that its size is relative to the tile size.
        // tslint:disable-next-line: no-bitwise
        const scale = (1 << 20) / (1 << tileKey.level);
        const boxGeometry = new BoxBufferGeometry(1.0 * scale, 5.0 * scale, 5.0 * scale);
        const matrix = new Matrix4();
        matrix.makeTranslation(2.0 * scale, 1.0 * scale, 0);
        boxGeometry.applyMatrix(matrix);

        for (const technique of techniques) {
            const geometry = ThreeBufferUtils.fromThreeBufferGeometry(
                boxGeometry,
                technique._index
            );
            geometries.push(geometry);
github heremaps / harp.gl / @here / harp-omv-datasource / lib / OmvData.ts View on Github external
$level: storageLevel,
        $zoom: Math.max(0, storageLevel - (storageLevelOffset || 0)),
        $geometryType: geometryType
    };

    // Some sources serve `id` directly as `IFeature` property ...
    if (feature.id !== undefined) {
        const featureId = decodeFeatureId(feature, logger);
        if (featureId !== undefined) {
            attributes.$id = featureId;
        }
    }

    readAttributes(layer, feature, attributes);

    return new MapEnv(attributes, parent);
}
github heremaps / harp.gl / @here / harp-geojson-datasource / lib / GeoJsonParser.ts View on Github external
private static findTechniqueIndices(
        feature: Feature,
        envType: Value,
        styleSetEvaluator: StyleSetEvaluator
    ): number[] {
        const featureDetails: FeatureDetails = Flattener.flatten(feature.properties, "properties");
        featureDetails.featureId = feature.id;
        const env = new MapEnv({ type: envType, ...(featureDetails as ValueMap) });
        const techniques = styleSetEvaluator.getMatchingTechniques(env);
        return techniques.map(technique => {
            return technique._index;
        });
    }
github heremaps / harp.gl / @here / harp-mapview / lib / PolarTileDataSource.ts View on Github external
createMaterial(kind: string, styleSetEvaluator: StyleSetEvaluator): THREE.Material | undefined {
        const env = new MapEnv({
            $geometryType: "polygon",
            $layer: "earth",
            kind
        });

        const techniques = styleSetEvaluator.getMatchingTechniques(env);

        return techniques.length !== 0
            ? createMaterial({ technique: techniques[0], level: 1 })
            : undefined;
    }
github heremaps / harp.gl / @here / harp-omv-datasource / lib / VTJsonDataAdapter.ts View on Github external
process(tile: VTJsonTileInterface, tileKey: TileKey, geoBox: GeoBox) {
        for (const feature of tile.features) {
            const env = new MapEnv({
                $layer: tile.layer,
                $geometryType: this.convertGeometryType(feature.type),
                $level: tileKey.level,
                $zoom: Math.max(0, tileKey.level - (this.m_processor.storageLevelOffset || 0)),
                $id: feature.id,
                ...feature.tags
            });

            switch (feature.type) {
                case VTJsonGeometryType.Point: {
                    for (const pointGeometry of feature.geometry) {
                        const x = (pointGeometry as VTJsonPosition)[0];
                        const y = (pointGeometry as VTJsonPosition)[1];

                        const position = new Vector2(x, y);