How to use the @here/harp-geoutils/lib/projection/EarthConstants.EarthConstants.EQUATORIAL_RADIUS 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 / Utils.ts View on Github external
if (deltaPitchDeg === 0) {
            return;
        }
        const pitch = MapViewUtils.extractAttitude(mapView, mapView.camera).pitch;
        // `maxTiltAngle` is equivalent to a `maxPitchAngle` in flat projections.
        let newPitch = THREE.Math.clamp(
            pitch + THREE.Math.degToRad(deltaPitchDeg),
            0,
            maxTiltAngleRad
        );
        // In sphere projection, the value of a maximum pitch is smaller than the value of the
        // maximum tilt, as the curvature of the surface adds up to it.
        if (mapView.projection.type === ProjectionType.Spherical) {
            // Deduce max pitch from max tilt. To this end the sine law of triangles is used below.
            const maxPitch = Math.asin(
                (EarthConstants.EQUATORIAL_RADIUS * Math.sin(Math.PI - maxTiltAngleRad)) /
                    mapView.camera.position.length()
            );
            newPitch = Math.min(newPitch, maxPitch);
        }
        mapView.camera.rotateX(newPitch - pitch);
    }
github heremaps / harp.gl / @here / harp-mapview / lib / Utils.ts View on Github external
zoomLevel: number,
        maxTiltAngle: number = Math.PI / 2
    ): void {
        // Get current target position in world space before we zoom.
        const targetPosition = rayCastWorldCoordinates(
            mapView,
            targetPositionOnScreenXinNDC,
            targetPositionOnScreenYinNDC
        );
        const zoomDistance = calculateDistanceToGroundFromZoomLevel(mapView, zoomLevel);

        // Set the cameras height according to the given zoom level.
        if (mapView.projection.type === ProjectionType.Planar) {
            mapView.camera.position.setZ(zoomDistance);
        } else if (mapView.projection.type === ProjectionType.Spherical) {
            mapView.camera.position.setLength(EarthConstants.EQUATORIAL_RADIUS + zoomDistance);
        }

        // In sphere, we may have to also orbit the camera around the position located at the
        // center of the screen, in order to limit the tilt to `maxTiltAngle`, as we change
        // this tilt by changing the camera's height above.
        if (mapView.projection.type === ProjectionType.Spherical) {
            const centerScreenTarget = rayCastWorldCoordinates(mapView, 0, 0);
            if (centerScreenTarget !== null) {
                const tilt = extractSphericalCoordinatesFromLocation(
                    mapView,
                    mapView.camera,
                    mapView.projection.unprojectPoint(centerScreenTarget)
                ).tilt;
                const deltaTilt = tilt - maxTiltAngle;
                if (deltaTilt > 0) {
                    orbitFocusPoint(mapView, 0, deltaTilt, maxTiltAngle);
github heremaps / harp.gl / @here / harp-mapview / lib / Utils.ts View on Github external
import { MapView } from "./MapView";
import { getFeatureDataSize, TileFeatureData } from "./Tile";

const logger = LoggerManager.instance.create("MapViewUtils");

// Estimation of the size of an Object3D with all the simple properties, like matrices and flags.
// There may be cases where it is possible to construct Object3Ds with considerable less memory
// consumption, but this value is used to simplify the estimation.
const MINIMUM_OBJECT3D_SIZE_ESTIMATION = 1000;

const MINIMUM_ATTRIBUTE_SIZE_ESTIMATION = 56;

// Caching those for performance reasons.
const groundNormalPlanarProj = new THREE.Vector3(0, 0, 1);
const groundPlane = new THREE.Plane(groundNormalPlanarProj.clone());
const groundSphere = new THREE.Sphere(undefined, EarthConstants.EQUATORIAL_RADIUS);
const rayCaster = new THREE.Raycaster();

/**
 * Cached ThreeJS instances for realtime maths.
 */
const space = {
    x: new THREE.Vector3(),
    y: new THREE.Vector3(),
    z: new THREE.Vector3()
};
const tangentSpace = {
    x: new THREE.Vector3(),
    y: new THREE.Vector3(),
    z: new THREE.Vector3()
};
const cache = {