How to use the terriajs-cesium/Source/Core/Math.toRadians 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 / test / Models / UserDrawingSpec.js View on Github external
it("polygon is only drawn once", function() {
    var options = { terria: terria };
    var userDrawing = new UserDrawing(options);
    userDrawing.enterDrawMode();
    var pickedFeatures = new PickedFeatures();

    // First point
    // Points around Parliament house
    var pt1Position = new Cartographic(
      CesiumMath.toRadians(149.121),
      CesiumMath.toRadians(-35.309),
      CesiumMath.toRadians(0)
    );
    var pt1CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(
      pt1Position
    );
    pickedFeatures.pickPosition = pt1CartesianPosition;
    pickedFeatures.allFeaturesAvailablePromise = true;
    userDrawing.terria.mapInteractionModeStack[0].pickedFeatures = pickedFeatures;

    // Second point
    var pt2Position = new Cartographic(
      CesiumMath.toRadians(149.124),
      CesiumMath.toRadians(-35.311),
      CesiumMath.toRadians(0)
    );
    var pt2CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(
github TerriaJS / terriajs / test / Models / UserDrawingSpec.js View on Github external
expect(userDrawing.otherEntities.entities.values.length).toEqual(1);

    // Now pick the first point
    pickedFeatures.pickPosition = pt1CartesianPosition;
    pickedFeatures.allFeaturesAvailablePromise = true;
    // If in the UI the user clicks on a point, it returns that entity, so we're pulling it out of userDrawing and
    // pretending the user actually clicked on it.
    var pt1Entity = userDrawing.pointEntities.entities.values[0];
    pickedFeatures.features = [pt1Entity];
    userDrawing.terria.mapInteractionModeStack[0].pickedFeatures = pickedFeatures;
    expect(userDrawing.closeLoop).toBeTruthy();
    expect(userDrawing.otherEntities.entities.values.length).toEqual(2);

    // Another point. Polygon is still closed.
    var newPtPosition = new Cartographic(
      CesiumMath.toRadians(149.0),
      CesiumMath.toRadians(-35.0),
      CesiumMath.toRadians(0)
    );
    var newPtCartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(
      newPtPosition
    );
    pickedFeatures.pickPosition = newPtCartesianPosition;
    userDrawing.terria.mapInteractionModeStack[0].pickedFeatures = pickedFeatures;

    expect(userDrawing.closeLoop).toBeTruthy();
    expect(userDrawing.otherEntities.entities.values.length).toEqual(2);
  });
github TerriaJS / terriajs / test / Models / UserDrawingSpec.js View on Github external
// Points around Parliament house
    var pt1Position = new Cartographic(
      CesiumMath.toRadians(149.121),
      CesiumMath.toRadians(-35.309),
      CesiumMath.toRadians(0)
    );
    var pt1CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(
      pt1Position
    );
    pickedFeatures.pickPosition = pt1CartesianPosition;
    pickedFeatures.allFeaturesAvailablePromise = true;
    userDrawing.terria.mapInteractionModeStack[0].pickedFeatures = pickedFeatures;

    // Second point
    var pt2Position = new Cartographic(
      CesiumMath.toRadians(149.124),
      CesiumMath.toRadians(-35.311),
      CesiumMath.toRadians(0)
    );
    var pt2CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(
      pt2Position
    );
    pickedFeatures.pickPosition = pt2CartesianPosition;
    userDrawing.terria.mapInteractionModeStack[0].pickedFeatures = pickedFeatures;

    // Third point
    var pt3Position = new Cartographic(
      CesiumMath.toRadians(149.127),
      CesiumMath.toRadians(-35.308),
      CesiumMath.toRadians(0)
    );
    var pt3CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(
github TerriaJS / terriajs / test / ReactViews / MeasureToolSpec.jsx View on Github external
it("measures distance accurately with geoscience australia test", function() {
    const measureTool = <MeasureTool terria={terria} />;
    const instance = getMountedInstance(measureTool);

    const pointEntities = new CustomDataSource();

    const flindersPeakPosition = new Cartographic(
      CesiumMath.toRadians(144.424868),
      CesiumMath.toRadians(-37.951033),
      CesiumMath.toRadians(0)
    );
    const flindersPeakCartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(
      flindersPeakPosition
    );
    const buninyongPosition = new Cartographic(
      CesiumMath.toRadians(143.926496),
      CesiumMath.toRadians(-37.652821),
      CesiumMath.toRadians(0)
    );
    const buninyongCartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(
      buninyongPosition
    );

    pointEntities.entities.add(
      new Entity({
        name: "Flinder's Peak",
        position: new ConstantPositionProperty(flindersPeakCartesianPosition)
      })
    );

    pointEntities.entities.add(
      new Entity({
github TerriaJS / terriajs / test / ReactViews / MeasureTool.jsx View on Github external
it('measures area correctly compared to hand-calculated area', function() {
        const measureTool = <MeasureTool terria={terria}/>;
        const renderer = ReactTestUtils.createRenderer();
        renderer.render(measureTool);
        const instance = getMountedInstance(renderer);

        const pointEntities = new CustomDataSource();
        const pt1Position = new Cartographic(CesiumMath.toRadians(149.121), CesiumMath.toRadians(-35.309), CesiumMath.toRadians(0));
        const pt1CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(pt1Position);
        const pt2Position = new Cartographic(CesiumMath.toRadians(149.124), CesiumMath.toRadians(-35.311), CesiumMath.toRadians(0));
        const pt2CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(pt2Position);
        const pt3Position = new Cartographic(CesiumMath.toRadians(149.127), CesiumMath.toRadians(-35.308), CesiumMath.toRadians(0));
        const pt3CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(pt3Position);
        const pt4Position = new Cartographic(CesiumMath.toRadians(149.124), CesiumMath.toRadians(-35.306), CesiumMath.toRadians(0));
        const pt4CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(pt4Position);

        pointEntities.entities.add(new Entity({
                            name: "Parliament house Pt 1",
                            position: new ConstantPositionProperty(pt1CartesianPosition)
                        }));
        instance.updateDistance(pointEntities);

        pointEntities.entities.add(new Entity({
                            name: "Parliament house Pt 2",
                            position: new ConstantPositionProperty(pt2CartesianPosition)
                        }));
github TerriaJS / terriajs / test / Models / CameraViewSpec.js View on Github external
it("can look north at a point on the equator", function() {
      jasmine.addMatchers(CustomMatchers);

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

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

      var surfaceNormal = Ellipsoid.WGS84.geodeticSurfaceNormalCartographic(
        cartographic
      );
      expect(Cartesian3.equalsEpsilon(view.up, surfaceNormal, 1e-2)).toBe(true);
      expect(
        Cartesian3.equalsEpsilon(view.direction, Cartesian3.UNIT_Z, 1e-7)
      ).toBe(true);
    });
github TerriaJS / terriajs / test / ReactViews / MeasureTool.jsx View on Github external
it('measures area correctly compared to hand-calculated area', function() {
        const measureTool = <MeasureTool terria={terria}/>;
        const renderer = ReactTestUtils.createRenderer();
        renderer.render(measureTool);
        const instance = getMountedInstance(renderer);

        const pointEntities = new CustomDataSource();
        const pt1Position = new Cartographic(CesiumMath.toRadians(149.121), CesiumMath.toRadians(-35.309), CesiumMath.toRadians(0));
        const pt1CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(pt1Position);
        const pt2Position = new Cartographic(CesiumMath.toRadians(149.124), CesiumMath.toRadians(-35.311), CesiumMath.toRadians(0));
        const pt2CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(pt2Position);
        const pt3Position = new Cartographic(CesiumMath.toRadians(149.127), CesiumMath.toRadians(-35.308), CesiumMath.toRadians(0));
        const pt3CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(pt3Position);
        const pt4Position = new Cartographic(CesiumMath.toRadians(149.124), CesiumMath.toRadians(-35.306), CesiumMath.toRadians(0));
        const pt4CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(pt4Position);

        pointEntities.entities.add(new Entity({
                            name: "Parliament house Pt 1",
                            position: new ConstantPositionProperty(pt1CartesianPosition)
                        }));
        instance.updateDistance(pointEntities);

        pointEntities.entities.add(new Entity({
                            name: "Parliament house Pt 2",
github TerriaJS / terriajs / test / Models / LeafletSpec.js View on Github external
it("calls pickFeatures for all enabled and shown layers", function() {
          expect(
            terria.nowViewing.items[0].imageryLayer.imageryProvider.pickFeatures
          ).toHaveBeenCalledWith(
            1,
            2,
            DEFAULT_ZOOM_LEVEL,
            CesiumMath.toRadians(50),
            CesiumMath.toRadians(50)
          );
          expect(
            terria.nowViewing.items[1].imageryLayer.imageryProvider.pickFeatures
          ).toHaveBeenCalledWith(
            4,
            5,
            DEFAULT_ZOOM_LEVEL,
            CesiumMath.toRadians(50),
            CesiumMath.toRadians(50)
          );
          expect(
            terria.nowViewing.items[2].imageryLayer.imageryProvider.pickFeatures
          ).not.toHaveBeenCalled();
          expect(
            terria.nowViewing.items[3].imageryLayer.imageryProvider.pickFeatures
github TerriaJS / terriajs / test / ReactViews / MeasureToolSpec.jsx View on Github external
CesiumMath.toRadians(-35.311),
      CesiumMath.toRadians(0)
    );
    const pt2CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(
      pt2Position
    );
    const pt3Position = new Cartographic(
      CesiumMath.toRadians(149.127),
      CesiumMath.toRadians(-35.308),
      CesiumMath.toRadians(0)
    );
    const pt3CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(
      pt3Position
    );
    const pt4Position = new Cartographic(
      CesiumMath.toRadians(149.124),
      CesiumMath.toRadians(-35.306),
      CesiumMath.toRadians(0)
    );
    const pt4CartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(
      pt4Position
    );

    pointEntities.entities.add(
      new Entity({
        name: "Parliament house Pt 1",
        position: new ConstantPositionProperty(pt1CartesianPosition)
      })
    );
    instance.updateDistance(pointEntities);

    pointEntities.entities.add(
github TerriaJS / terriajs / lib / Models / Leaflet.js View on Github external
.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,

terriajs-cesium

Cesium for TerriaJS.

Apache-2.0
Latest version published 8 months ago

Package Health Score

68 / 100
Full package analysis