How to use the @here/harp-geoutils.TileKey.fromMortonCode function in @here/harp-geoutils

To help you get started, we’ve selected a few @here/harp-geoutils 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 / VisibleTileSet.ts View on Github external
private findDown(
        tileKeyCode: number,
        displayZoomLevel: number,
        renderedTiles: Map,
        dataSource: DataSource
    ) {
        const { offset, mortonCode } = TileOffsetUtils.extractOffsetAndMortonKeyFromKey(
            tileKeyCode
        );
        const tileKey = TileKey.fromMortonCode(mortonCode);

        const tilingScheme = dataSource.getTilingScheme();
        for (const childTileKey of tilingScheme.getSubTileKeys(tileKey)) {
            const childTileCode = TileOffsetUtils.getKeyForTileKeyAndOffset(childTileKey, offset);
            const childTile = this.m_dataSourceCache.get(
                childTileKey.mortonCode(),
                offset,
                dataSource
            );

            const nextLevelDiff = Math.abs(childTileKey.level - displayZoomLevel);
            if (childTile !== undefined && childTile.hasGeometry) {
                // childTile has geometry, so can be reused as fallback
                renderedTiles.set(childTileCode, childTile);
                childTile.levelOffset = nextLevelDiff;
                continue;
github heremaps / harp.gl / @here / harp-mapview / lib / VisibleTileSet.ts View on Github external
checkedTiles: Map,
        dataSource: DataSource
    ): boolean {
        const parentCode = TileOffsetUtils.getParentKeyFromKey(tileKeyCode);
        // Check if another sibling has already added the parent.
        if (renderedTiles.get(parentCode) !== undefined) {
            return true;
        }
        const exists = checkedTiles.get(parentCode)!;
        if (exists !== undefined) {
            return exists;
        }

        const { offset, mortonCode } = TileOffsetUtils.extractOffsetAndMortonKeyFromKey(parentCode);
        const parentTile = this.m_dataSourceCache.get(mortonCode, offset, dataSource);
        const parentTileKey = parentTile ? parentTile.tileKey : TileKey.fromMortonCode(mortonCode);
        const nextLevelDiff = Math.abs(displayZoomLevel - parentTileKey.level);
        if (parentTile !== undefined && parentTile.hasGeometry) {
            checkedTiles.set(parentCode, true);
            // parentTile has geometry, so can be reused as fallback
            renderedTiles.set(parentCode, parentTile);

            // We want to have parent tiles as -ve, hence the minus.
            parentTile.levelOffset = -nextLevelDiff;

            return true;
        } else {
            checkedTiles.set(parentCode, false);
        }

        // Recurse up until the max distance is reached or we go to the parent of all parents.
        if (nextLevelDiff < this.options.quadTreeSearchDistanceUp && parentTileKey.level !== 0) {
github heremaps / harp.gl / @here / harp-mapview-decoder / lib / TileDecoderService.ts View on Github external
private handleTileInfoRequest(
        request: WorkerDecoderProtocol.TileInfoRequest
    ): Promise {
        const tileKey = TileKey.fromMortonCode(request.tileKey);
        const projection = getProjection(request.projection);

        return this.m_decoder.getTileInfo(request.data, tileKey, projection).then(tileInfo => {
            const transferList: ArrayBuffer[] =
                tileInfo !== undefined && tileInfo.transferList !== undefined
                    ? tileInfo.transferList
                    : [];
            return {
                response: tileInfo,
                transferList
            };
        });
    }
github heremaps / harp.gl / @here / harp-mapview / lib / Utils.ts View on Github external
export function getParentKeyFromKey(calculatedKey: number, bitshift: number = 4) {
        const { offset, mortonCode } = extractOffsetAndMortonKeyFromKey(calculatedKey, bitshift);
        const parentTileKey = TileKey.fromMortonCode(TileKey.parentMortonCode(mortonCode));
        return getKeyForTileKeyAndOffset(parentTileKey, offset, bitshift);
    }
github heremaps / harp.gl / @here / harp-mapview-decoder / lib / TileDecoderService.ts View on Github external
private handleDecodeTileRequest(
        request: WorkerDecoderProtocol.DecodeTileRequest
    ): Promise {
        const tileKey = TileKey.fromMortonCode(request.tileKey);
        const projection = getProjection(request.projection);

        return this.m_decoder.decodeTile(request.data, tileKey, projection).then(decodedTile => {
            const transferList: ArrayBuffer[] = [];
            decodedTile.geometries.forEach(geom => {
                geom.vertexAttributes.forEach(attr => {
                    if (attr.buffer instanceof ArrayBuffer) {
                        transferList.push(attr.buffer);
                    }
                });

                if (geom.index && geom.index.buffer instanceof ArrayBuffer) {
                    transferList.push(geom.index.buffer);
                }

                if (
github heremaps / harp.gl / @here / harp-mapview-decoder / lib / TilerService.ts View on Github external
private async handleTileRequest(
        request: WorkerTilerProtocol.TileRequest
    ): Promise {
        const tileKey = TileKey.fromMortonCode(request.tileKey);
        const tile = await this.tiler.getTile(request.index, tileKey);

        return { response: tile || {} };
    }