How to use the terriajs-cesium/Source/Core/Ellipsoid.WGS84 function in terriajs-cesium

To help you get started, we’ve selected a few terriajs-cesium 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 TerriaJS / terriajs / lib / ReactViews / Map / Navigation / ZoomControl.jsx View on Github external
getCameraFocus(scene) {
    const ray = new Ray(scene.camera.positionWC, scene.camera.directionWC);
    const intersections = IntersectionTests.rayEllipsoid(ray, Ellipsoid.WGS84);
    if (defined(intersections)) {
      return Ray.getPoint(ray, intersections.start);
    }
    // Camera direction is not pointing at the globe, so use the ellipsoid horizon point as
    // the focal point.
    return IntersectionTests.grazingAltitudeLocation(ray, Ellipsoid.WGS84);
  },
github TerriaJS / terriajs / lib / Models / Leaflet.js View on Github external
var mapInteractionModeStack = leaflet.terria.mapInteractionModeStack;
        if (defined(mapInteractionModeStack) && mapInteractionModeStack.length > 0) {
            mapInteractionModeStack[mapInteractionModeStack.length - 1].pickedFeatures.pickPosition = newPickLocation;
        } else {
            leaflet.terria.pickedFeatures.pickPosition = newPickLocation;
        }

        // Unset this so that the next click will start building features from scratch.
        leaflet._pickedFeatures = undefined;
    });

    var activeItems = leaflet.terria.nowViewing.items;
    tileCoordinates = defaultValue(tileCoordinates, {});

    var pickedLocation = Cartographic.fromDegrees(latlng.lng, latlng.lat);
    leaflet._pickedFeatures.pickPosition = Ellipsoid.WGS84.cartographicToCartesian(pickedLocation);

    // We want the all available promise to return after the cleanup one to make sure all vector click events have resolved.
    var promises = [cleanup].concat(activeItems.filter(function(item) {
        return item.isEnabled && item.isShown && defined(item.imageryLayer) && defined(item.imageryLayer.pickFeatures);
    }).map(function(item) {
        var imageryLayerUrl = item.imageryLayer.imageryProvider.url;
        var longRadians = CesiumMath.toRadians(latlng.lng);
        var latRadians = CesiumMath.toRadians(latlng.lat);

        return when(tileCoordinates[imageryLayerUrl] || item.imageryLayer.getFeaturePickingCoords(leaflet.map, longRadians, latRadians))
            .then(function(coords) {
                return item.imageryLayer.pickFeatures(coords.x, coords.y, coords.level, longRadians, latRadians).then(function(features) {
                    return {
                        features: features,
                        imageryLayer: item.imageryLayer,
                        coords: coords
github TerriaJS / terriajs / test / Models / CameraViewSpec.js View on Github external
it("can look straight down at a point on the equator", function() {
      jasmine.addMatchers(CustomMatchers);

      var view = CameraView.fromLookAt(
        Cartographic.fromDegrees(45, 0, 100),
        new HeadingPitchRange(0, CesiumMath.toRadians(90), 10000)
      );

      var cartographic = Ellipsoid.WGS84.cartesianToCartographic(view.position);
      expect(cartographic.longitude).toEqualEpsilon(
        CesiumMath.toRadians(45),
        1e-5
      );
      expect(cartographic.latitude).toEqualEpsilon(
        CesiumMath.toRadians(0),
        1e-5
      );
      expect(cartographic.height).toEqualEpsilon(10000 + 100, 1);

      var surfaceNormal = Ellipsoid.WGS84.geodeticSurfaceNormalCartographic(
        cartographic
      );
      expect(
        Cartesian3.equalsEpsilon(
          view.direction,
github TerriaJS / terriajs / lib / ViewModels / PointParameterEditor.js View on Github external
knockout.getObservable(pickPointMode, 'pickedFeatures').subscribe(function(pickedFeatures) {
        if (defined(pickedFeatures.pickPosition)) {
            that.parameterValues[that.parameter.id] = Ellipsoid.WGS84.cartesianToCartographic(pickedFeatures.pickPosition);
            terria.mapInteractionModeStack.pop();
            that.invokeFunctionPanel.isVisible = true;
        }
    });
github TerriaJS / terriajs / lib / ReactViews / Analytics / LineParameterEditor.jsx View on Github external
onPointClicked(pointEntities) {
    const pointEnts = pointEntities.entities.values;
    const pointsLongLats = [];
    for (let i = 0; i < pointEnts.length; i++) {
      const currentPoint = pointEnts[i];
      const currentPointPos = currentPoint.position.getValue(
        this.props.previewed.terria.clock.currentTime
      );
      const cartographic = Ellipsoid.WGS84.cartesianToCartographic(
        currentPointPos
      );
      const points = [];
      points.push(CesiumMath.toDegrees(cartographic.longitude));
      points.push(CesiumMath.toDegrees(cartographic.latitude));
      pointsLongLats.push(points);
    }
    this.props.parameter.value = pointsLongLats;
  },
github TerriaJS / terriajs / lib / ReactViews / Tools / DeltaTool / LocationPicker.jsx View on Github external
function cartesianToDegrees(cartesian) {
  const carto = Ellipsoid.WGS84.cartesianToCartographic(cartesian);
  return {
    longitude: CesiumMath.toDegrees(carto.longitude),
    latitude: CesiumMath.toDegrees(carto.latitude)
  };
}
github TerriaJS / terriajs / lib / ViewModels / TerriaViewer.js View on Github external
update : function(value) {
            scene.camera.position.x = CesiumMath.lerp(startPosition.x, endPosition.x, value.time);
            scene.camera.position.y = CesiumMath.lerp(startPosition.y, endPosition.y, value.time);
            scene.camera.position.z = CesiumMath.lerp(startPosition.z, endPosition.z, value.time);

            var enuToFixed = Transforms.eastNorthUpToFixedFrame(camera.position, Ellipsoid.WGS84);

            var enuToFixedRotation = new Matrix3();
            Matrix4.getRotation(enuToFixed, enuToFixedRotation);

            camera.up = Matrix3.multiplyByVector(enuToFixedRotation, initialEnuUp, camera.up);
            camera.right = Matrix3.multiplyByVector(enuToFixedRotation, initialEnuRight, camera.right);
            camera.direction = Matrix3.multiplyByVector(enuToFixedRotation, initialEnuDirection, camera.direction);
        },
        complete : function() {
github TerriaJS / terriajs / lib / Models / Cesium.js View on Github external
Cesium.prototype.pickFromScreenPosition = function(screenPosition) {
    var pickRay = this.scene.camera.getPickRay(screenPosition);
    var pickPosition = this.scene.globe.pick(pickRay, this.scene);
    var pickPositionCartographic = Ellipsoid.WGS84.cartesianToCartographic(pickPosition);

    var vectorFeatures = this.pickVectorFeatures(screenPosition);

    var providerCoords = this._attachProviderCoordHooks();
    var pickRasterPromise = this.scene.imageryLayers.pickImageryLayerFeatures(pickRay, this.scene);

    this.terria.pickedFeatures = this._buildPickedFeatures(providerCoords, pickPosition, vectorFeatures, [pickRasterPromise], undefined, pickPositionCartographic.height);
};
github TerriaJS / terriajs / lib / ReactViews / FeatureInfo / FeatureInfoPanel.jsx View on Github external
renderLocationItem(cartesianPosition) {
    const catographic = Ellipsoid.WGS84.cartesianToCartographic(
      cartesianPosition
    );
    const latitude = CesiumMath.toDegrees(catographic.latitude);
    const longitude = CesiumMath.toDegrees(catographic.longitude);
    const pretty = prettifyCoordinates(longitude, latitude);
    this.locationUpdated(longitude, latitude);

    const that = this;
    const pinClicked = function() {
      that.pinClicked(longitude, latitude);
    };

    const locationButtonStyle = markerVisible(this.props.terria)
      ? Styles.btnLocationSelected
      : Styles.btnLocation;
github TerriaJS / terriajs / lib / ReactViews / Analytics / PointParameterEditor.jsx View on Github external
.subscribe(function(pickedFeatures) {
      if (defined(pickedFeatures.pickPosition)) {
        const value = Ellipsoid.WGS84.cartesianToCartographic(
          pickedFeatures.pickPosition
        );
        terria.mapInteractionModeStack.pop();
        parameter.value = value;
        viewState.openAddData();
      }
    });

terriajs-cesium

Cesium for TerriaJS.

Apache-2.0
Latest version published 8 months ago

Package Health Score

68 / 100
Full package analysis