How to use the @here/harp-geoutils.ProjectionType 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-map-controls / lib / MapControls.ts View on Github external
const maxDistance = MapViewUtils.calculateDistanceToGroundFromZoomLevel(
            this.mapView,
            this.mapView.minZoomLevel
        );
        const minDistance = MapViewUtils.calculateDistanceToGroundFromZoomLevel(
            this.mapView,
            this.mapView.maxZoomLevel
        );
        this.m_currentViewDirection.multiplyScalar(amount);
        if (this.mapView.projection.type === geoUtils.ProjectionType.Planar) {
            this.camera.position.z += this.m_currentViewDirection.z;
            this.camera.position.z = Math.max(
                minDistance,
                Math.min(maxDistance, this.camera.position.z)
            );
        } else if (this.mapView.projection.type === geoUtils.ProjectionType.Spherical) {
            const zOnVertical =
                Math.cos(this.camera.position.angleTo(this.m_currentViewDirection)) *
                this.m_currentViewDirection.length();
            this.camera.position.setLength(
                Math.max(
                    minDistance + geoUtils.EarthConstants.EQUATORIAL_RADIUS,
                    Math.min(
                        maxDistance + geoUtils.EarthConstants.EQUATORIAL_RADIUS,
                        this.camera.position.length() + zOnVertical
                    )
                )
            );
        }

        // 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
github heremaps / harp.gl / @here / harp-map-controls / lib / MapControls.ts View on Github external
moveAlongTheViewDirection(amount: number) {
        if (amount === 0) {
            return;
        }
        this.camera.getWorldDirection(this.m_currentViewDirection);
        const maxDistance = MapViewUtils.calculateDistanceToGroundFromZoomLevel(
            this.mapView,
            this.mapView.minZoomLevel
        );
        const minDistance = MapViewUtils.calculateDistanceToGroundFromZoomLevel(
            this.mapView,
            this.mapView.maxZoomLevel
        );
        this.m_currentViewDirection.multiplyScalar(amount);
        if (this.mapView.projection.type === geoUtils.ProjectionType.Planar) {
            this.camera.position.z += this.m_currentViewDirection.z;
            this.camera.position.z = Math.max(
                minDistance,
                Math.min(maxDistance, this.camera.position.z)
            );
        } else if (this.mapView.projection.type === geoUtils.ProjectionType.Spherical) {
            const zOnVertical =
                Math.cos(this.camera.position.angleTo(this.m_currentViewDirection)) *
                this.m_currentViewDirection.length();
            this.camera.position.setLength(
                Math.max(
                    minDistance + geoUtils.EarthConstants.EQUATORIAL_RADIUS,
                    Math.min(
                        maxDistance + geoUtils.EarthConstants.EQUATORIAL_RADIUS,
                        this.camera.position.length() + zOnVertical
                    )