How to use the terriajs-cesium/Source/Core/Math.toDegrees 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 / Models / REpresentationalStateTransferCatalogFunction.js View on Github external
functionParameterToInput: function(catalogFunction, parameter, value) {
            var bboxMinCoord1, bboxMinCoord2, bboxMaxCoord1, bboxMaxCoord2, urn;
            // We only support CRS84 and EPSG:4326
            if (parameter.crs.indexOf('crs84') !== -1) {
                // CRS84 uses long, lat rather that lat, long order.
                bboxMinCoord1 = CesiumMath.toDegrees(value.west);
                bboxMinCoord2 = CesiumMath.toDegrees(value.south);
                bboxMaxCoord1 = CesiumMath.toDegrees(value.east);
                bboxMaxCoord2 = CesiumMath.toDegrees(value.north);
                // Comfortingly known as WGS 84 longitude-latitude according to Table 3 in OGC 07-092r1.
                urn = 'urn:ogc:def:crs:OGC:1.3:CRS84';

            } else {
                // The URN value urn:ogc:def:crs:EPSG:6.6:4326 shall mean the Coordinate Reference System (CRS) with code
                // 4326 specified in version 6.6 of the EPSG database available at http://www.epsg.org/. That CRS specifies
                // the axis order as Latitude followed by Longitude.
                // We don't know about other URN versions, so are going to return 6.6 regardless of what was requested.
                bboxMinCoord1 = CesiumMath.toDegrees(value.south);
                bboxMinCoord2 = CesiumMath.toDegrees(value.west);
                bboxMaxCoord1 = CesiumMath.toDegrees(value.north);
                bboxMaxCoord2 = CesiumMath.toDegrees(value.east);
                urn = 'urn:ogc:def:crs:EPSG:6.6:4326';
            }
github TerriaJS / terriajs / lib / ReactViews / Map / Panels / SharePanel / BuildShareLink.js View on Github external
function addLocationMarker(terria, initSources) {
  if (defined(terria.locationMarker)) {
    const position = terria.locationMarker.entities.values[0].position.getValue();
    const positionDegrees = Ellipsoid.WGS84.cartesianToCartographic(position);

    initSources.push({
      locationMarker: {
        name: terria.locationMarker.entities.values[0].name,
        latitude: CesiumMath.toDegrees(positionDegrees.latitude),
        longitude: CesiumMath.toDegrees(positionDegrees.longitude)
      }
    });
  }
}
github TerriaJS / terriajs / lib / Models / PointParameter.js View on Github external
PointParameter.prototype.getGeoJsonFeature = function(value) {
  value = defaultValue(value, this.value);
  if (!defined(value) || value === "") {
    return undefined;
  }

  var coordinates = [
    CesiumMath.toDegrees(value.longitude),
    CesiumMath.toDegrees(value.latitude)
  ];

  if (defined(value.height)) {
    coordinates.push(value.height);
  }

  return {
    type: "Feature",
    geometry: {
      type: "Point",
      coordinates: coordinates
    }
  };
};
github TerriaJS / terriajs / lib / ViewModels / SharePopupViewModel.js View on Github external
south: CesiumMath.toDegrees(cameraExtent.south),
        east: CesiumMath.toDegrees(cameraExtent.east),
        north: CesiumMath.toDegrees(cameraExtent.north),
    };

    if (defined( this.terria.cesium)) {
        var cesiumCamera =  this.terria.cesium.scene.camera;
        initialCamera.position = cesiumCamera.positionWC;
        initialCamera.direction = cesiumCamera.directionWC;
        initialCamera.up = cesiumCamera.upWC;
    }

    var homeCamera = {
        west: CesiumMath.toDegrees( this.terria.homeView.rectangle.west),
        south: CesiumMath.toDegrees( this.terria.homeView.rectangle.south),
        east: CesiumMath.toDegrees( this.terria.homeView.rectangle.east),
        north: CesiumMath.toDegrees( this.terria.homeView.rectangle.north),
        position:  this.terria.homeView.position,
        direction:  this.terria.homeView.direction,
        up:  this.terria.homeView.up
    };

    initSources.push({
        initialCamera: initialCamera,
        homeCamera: homeCamera,
        baseMapName: this.terria.baseMap.name,
        viewerMode: this.terria.leaflet ? '2d' : '3d'
    });

    this.itemsSkippedBecauseTheyHaveLocalData.push.apply(this.itemsSkippedBecauseTheyHaveLocalData, userDataSerializeOptions.itemsSkippedBecauseTheyHaveLocalData);

    var uri = new URI(window.location);
github TerriaJS / terriajs / lib / ViewModels / ToolsPanelViewModel.js View on Github external
function getDegreesRect(rect) {
    return { west: CesiumMath.toDegrees(rect.west),
        south: CesiumMath.toDegrees(rect.south),
        east: CesiumMath.toDegrees(rect.east),
        north: CesiumMath.toDegrees(rect.north)};
}
github TerriaJS / terriajs / lib / ReactViewModels / MouseCoords.js View on Github external
cartographicToFields(coordinates, errorBar) {
    const latitude = CesiumMath.toDegrees(coordinates.latitude);
    const longitude = CesiumMath.toDegrees(coordinates.longitude);

    if (this.useProjection) {
      var prettyProjection = prettifyProjection(
        longitude,
        latitude,
        this.proj4Projection,
        this.proj4longlat,
        this.projectionUnits
      );
      this.utmZone = prettyProjection.utmZone;
      this.north = prettyProjection.north;
      this.east = prettyProjection.east;
    }

    var prettyCoordinate = prettifyCoordinates(longitude, latitude, {
      height: coordinates.height,
github TerriaJS / terriajs / lib / Models / Leaflet.js View on Github external
function startTweens(leaflet) {
  if (leaflet._tweensAreRunning) {
    return;
  }

  var feature = leaflet.terria.selectedFeature;
  if (defined(feature) && defined(feature.position)) {
    var cartographic = Ellipsoid.WGS84.cartesianToCartographic(
      feature.position.getValue(leaflet.terria.clock.currentTime),
      cartographicScratch
    );
    leaflet._selectionIndicator.setLatLng([
      CesiumMath.toDegrees(cartographic.latitude),
      CesiumMath.toDegrees(cartographic.longitude)
    ]);
  }

  if (leaflet._tweens.length > 0) {
    leaflet._tweens.update();
  }

  if (
    leaflet._tweens.length !== 0 ||
    (defined(feature) && defined(feature.position))
  ) {
    cesiumRequestAnimationFrame(startTweens.bind(undefined, leaflet));
  }
}
github TerriaJS / terriajs / lib / ViewModels / ToolsPanelViewModel.js View on Github external
function getCkanRect(rect) {
    return CesiumMath.toDegrees(rect.west).toFixed(4) + ',' +
        CesiumMath.toDegrees(rect.south).toFixed(4) + ',' +
        CesiumMath.toDegrees(rect.east).toFixed(4) + ',' +
        CesiumMath.toDegrees(rect.north).toFixed(4);
}
github TerriaJS / terriajs / lib / ReactViews / Analytics / PointParameterEditorCore.js View on Github external
PointParameterEditorCore.prototype.formatValueForUrl = function(value) {
    if (!defined(value) || value === '') {
        return undefined;
    }

    const coordinates = [
        CesiumMath.toDegrees(value.longitude),
        CesiumMath.toDegrees(value.latitude),
    ];

    if (defined(value.height)) {
        coordinates.push(value.height);
    }

    return this.parameter.id + '=' + JSON.stringify({
        'type': 'FeatureCollection',
        'features': [
            {
                'type': 'Feature',
                'geometry': {
                    'type': 'Point',
                    'coordinates': coordinates
                }
            }
github TerriaJS / terriajs / lib / ReactViews / Custom / Chart / ChartExpandAndDownloadButtons.jsx View on Github external
stroke: "#ffffff",
      "marker-color": newCatalogItem.colors[0],
      "marker-opacity": 1
    };

    const carts = Ellipsoid.WGS84.cartesianToCartographic(
      feature.position._value
    );
    newGeoJsonItem.data = {
      type: "Feature",
      properties: {},
      geometry: {
        type: "Point",
        coordinates: [
          CesiumMath.toDegrees(carts.longitude),
          CesiumMath.toDegrees(carts.latitude)
        ]
      }
    };

    const compositeItem = new CompositeCatalogItem(terria, [
      newCatalogItem,
      newGeoJsonItem
    ]);
    let tableStructure = props.tableStructure;
    if (
      defined(props.colors) &&
      props.colors.length >= tableStructure.columns.length
    ) {
      newCatalogItem.getNextColor = index => props.colors[index];
    }