How to use the @here/harp-utils.MathUtils.isClamped 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 / TextElementsRenderer.ts View on Github external
}
                return false;
            }
            iconRejected = !iconSpaceAvailable;
        } else if (renderIcon && poiInfo!.isValid !== false) {
            // Ensure that text elements still loading icons get a chance to be rendered if
            // there's no text element updates in the next frames.
            this.m_forceNewLabelsPass = true;
        }

        // Check if label should be rendered at this zoomLevel
        const renderText =
            hasText &&
            (poiInfo === undefined ||
                this.m_viewState.zoomLevel === undefined ||
                MathUtils.isClamped(
                    this.m_viewState.zoomLevel,
                    poiInfo.iconMinZoomLevel,
                    poiInfo.iconMaxZoomLevel
                ));

        // Check if we should render the label's text.
        const doRenderText =
            // Render if between min/max zoom level
            renderText &&
            // Do not render if the distance is too great and distance shouldn't be ignored.
            (pointLabel.ignoreDistance === true ||
                labelState.viewDistance === undefined ||
                labelState.viewDistance < poiTextMaxDistance) &&
            // Do not render text if POI cannot be rendered and is not optional.
            (poiInfo === undefined || poiInfo.isValid === true || poiInfo.iconIsOptional !== false);
github heremaps / harp.gl / @here / harp-mapview / lib / text / TextElementsRenderer.ts View on Github external
textScale *= distanceScaleFactor;
        }
        const distanceFadeFactor = this.getDistanceFadingFactor(
            pointLabel,
            labelState,
            this.m_viewState.maxVisibilityDist
        );

        // Check if there is need to check for screen space for the label's icon.
        const poiInfo = pointLabel.poiInfo;
        let iconRejected = false;

        // Check if icon should be rendered at this zoomLevel
        const renderIcon =
            poiInfo !== undefined &&
            MathUtils.isClamped(
                this.m_viewState.zoomLevel,
                poiInfo.iconMinZoomLevel,
                poiInfo.iconMaxZoomLevel
            ) &&
            poiInfo!.isValid !== false;

        const iconReady =
            renderIcon && poiRenderer.prepareRender(pointLabel, this.m_viewState.zoomLevel);

        if (iconReady) {
            PoiRenderer.computeIconScreenBox(
                poiInfo!,
                tempPoiScreenPosition,
                distanceScaleFactor,
                this.m_viewState.zoomLevel,
                tempBox2D
github heremaps / harp.gl / @here / harp-mapview / lib / text / Placement.ts View on Github external
return { result: PrePlacementResult.Invisible, viewDistance };
    }

    // If a PoiTable is specified in the technique, the table is required to be
    // loaded before the POI can be rendered.
    if (!poiManager.updatePoiFromPoiTable(textElement)) {
        // PoiTable has not been loaded, but is required to determine
        // visibility.
        return { result: PrePlacementResult.NotReady, viewDistance };
    }

    // Text element visibility and zoom level ranges must be checked after calling
    // updatePoiFromPoiTable, since that function may change those values.
    if (
        !textElement.visible ||
        !MathUtils.isClamped(
            viewState.zoomLevel,
            textElement.minZoomLevel,
            textElement.maxZoomLevel
        )
    ) {
        return { result: PrePlacementResult.Invisible, viewDistance };
    }

    viewDistance =
        maxViewDistance === undefined
            ? computeViewDistance(viewState.worldCenter, textElement)
            : checkViewDistance(
                  viewState.worldCenter,
                  textElement,
                  projectionType,
                  viewCamera,