How to use the terriajs-cesium/Source/Core/defined.default 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 / callWebCoverageService.js View on Github external
function getStyle(wmsItem) {
  const thisLayer = wmsItem._thisLayerInRawMetadata;
  if (!defined(thisLayer)) {
    console.log("cannot find current layer");
    return undefined;
  }

  var style;
  const availStyles = wmsItem.availableStyles[thisLayer.Name];
  if (availStyles.length >= 2) {
    const layers = wmsItem.layers.split(",");
    const layerIndex = layers.indexOf(thisLayer.Name);
    if (layerIndex === -1) {
      // Not a valid layer?  Something went wrong.
      console.log("cannot find layer index");
      return undefined;
    }

    const styles = wmsItem.styles.split(",");
github TerriaJS / terriajs / lib / Models / Cesium3DTilesCatalogItem.js View on Github external
Cesium3DTilesCatalogItem.prototype.syncMaximumScreenSpaceError = function() {
  if (defined(this._tileset) && !this.options.maximumScreenSpaceError) {
    if (!defined(this.terria.cesium)) {
      return;
    }
    // default is 16 (baseMaximumScreenSpaceError @ 2)
    // we want to reduce to 8 for higher levels of quality
    // the slider goes from [quality] 1 to 3 [performance]
    // in 0.1 steps
    const baseMax = this.terria.baseMaximumScreenSpaceError;

    /**
     * kring;
     * >but most datasets are set up with Cesium's default of 16 in mind so they'll look good with that default
     * >SSE is a projection of the tile's "geometric error" (in meters) to the screen. What effect that has kinda depends on how the tileset is structured
     * >like for the aero3Dpro datasets, because of the way they've set up their levels and geometric error, 16 looks pretty terrible
     * >and if you set it to 1 instead you'd get like 16 * 16 more detail and probably crash the browser
     * >(it's squared for 2D, more like cubed for something that's truly 3D)
     */
github TerriaJS / terriajs / lib / Models / OgrCatalogItem.js View on Github external
function loadOgrData(ogrItem, file, url) {
  var terria = ogrItem.terria;
  // generate form to submit file for conversion
  var formData = new FormData();
  if (defined(file)) {
    var maxConversionSize = 1000000;
    if (
      defined(terria.serverConfig) &&
      defined(terria.serverConfig.config) &&
      defined(terria.serverConfig.config.maxConversionSize)
    ) {
      maxConversionSize = terria.serverConfig.config.maxConversionSize;
    }
    if (file.size > maxConversionSize) {
      var maxConversionSizeMB = maxConversionSize / 1000000;
      errorLoading(
        ogrItem,
        "The file size is greater than the " +
          maxConversionSizeMB +
          "MB limit of the " +
          terria.appName +
          " conversion service."
      );
      return;
    }
    formData.append("input_file", file);
github TerriaJS / terriajs / lib / ViewModels / BingMapsSearchProviderViewModel.js View on Github external
// the country name to them.
      for (var i = 0; i < resourceSet.resources.length; ++i) {
        var resource = resourceSet.resources[i];

        var name = resource.name;
        if (!defined(name)) {
          continue;
        }

        var list = primaryCountryLocations;
        var isImportant = true;

        var country = resource.address
          ? resource.address.countryRegion
          : undefined;
        if (defined(that.primaryCountry) && country !== that.primaryCountry) {
          // Add this location to the list of other locations.
          list = otherLocations;
          isImportant = false;

          // Add the country to the name, if it's not already there.
          if (
            defined(country) &&
            name.lastIndexOf(country) !== name.length - country.length
          ) {
            name += ", " + country;
          }
        }

        list.push(
          new SearchResultViewModel({
            name: name,
github TerriaJS / terriajs / lib / Models / SensorObservationServiceCatalogItem.js View on Github external
procedureValues = [],
    observedPropertyValues = [];

  // extract columns from response
  responses.forEach(extractValues);
  // Now turn all the columns of dates, values etc into a single table structure
  var observationTableStructure = new TableStructure("observations");
  var columnOptions = { tableStructure: observationTableStructure };
  var timeColumn = new TableColumn("date", dateValues, columnOptions);

  var units = observableProperty.units || procedure.units;
  var valueTitle =
    observableProperty.title +
    " " +
    procedure.title +
    (defined(units) ? " (" + units + ")" : "");
  var valueColumn = new TableColumn(valueTitle, valueValues, columnOptions);
  valueColumn.id = "value";
  valueColumn.units = units;

  var featureColumn = new TableColumn(
    "identifier",
    featureValues,
    columnOptions
  ); // featureColumn.id must be 'identifier', used as an idColumn.

  var procedureColumn = new TableColumn(
    item.proceduresName,
    procedureValues,
    columnOptions
  );
github TerriaJS / terriajs / lib / Models / MagdaCatalogItem.js View on Github external
var isWms = matchingFormats[0][1] === WebMapServiceCatalogItem;
  var isWfs = matchingFormats[0][1] === WebFeatureServiceCatalogItem;

  // Extract the layer name from the URL.
  var uri = new URI(baseUrl);
  var params = uri.search(true);

  // Remove the query portion of the WMS URL.
  var url = baseUrl;

  var newItem;
  if (isWms || isWfs) {
    uri.search("");
    url = uri.toString();
    var layerName = params.LAYERS || params.layers || params.typeName;
    if (defined(layerName)) {
      newItem = isWms
        ? new WebMapServiceCatalogItem(options.terria)
        : new WebFeatureServiceCatalogItem(options.terria);
      newItem.layers = layerName;
      newItem.url = url;
    } else {
      // Construct a WMS/WFS CatalogGroup and return the first item
      var newGroup;
      if (isWms && options.allowWmsGroups) {
        newGroup = new WebMapServiceCatalogGroup(options.terria);
        newGroup.flatten = true;
      } else if (isWfs && options.allowWfsGroups) {
        newGroup = new WebFeatureServiceCatalogGroup(options.terria);
      } else {
        return when(undefined);
      }
github TerriaJS / terriajs / lib / Models / LegendHelper.js View on Github external
function getTableColumnStyle(tableColumn, tableStyle) {
  var tableColumnStyle;
  if (defined(tableColumn) && defined(tableStyle.columns)) {
    if (defined(tableStyle.columns[tableColumn.id])) {
      tableColumnStyle = clone(tableStyle.columns[tableColumn.id]);
    } else {
      // Also support column indices as keys into tableStyle.columns
      var tableStructure = tableColumn.parent;
      var columnIndex = tableStructure.columns.indexOf(tableColumn);
      if (defined(tableStyle.columns[columnIndex])) {
        tableColumnStyle = clone(tableStyle.columns[columnIndex]);
      }
    }
  }
  if (!defined(tableColumnStyle)) {
    return tableStyle;
  }
  // Copy defaults from tableStyle too.
  for (var propertyName in tableStyle) {
github TerriaJS / terriajs / lib / Models / GeoJsonCatalogItem.js View on Github external
var options = {
    describe: describeWithoutUnderscores,
    markerSize: defaultValue(parseMarkerSize(style["marker-size"]), 20),
    markerSymbol: style["marker-symbol"], // and undefined if none
    markerColor: defaultColor(style["marker-color"], geoJsonItem.name),
    strokeWidth: defaultValue(style["stroke-width"], 2),
    polygonStroke: getColor(defaultValue(style.stroke, "#000000")),
    polylineStroke: defaultColor(style.stroke, geoJsonItem.name),
    markerOpacity: style["marker-opacity"], // not in SimpleStyle spec or supported by Cesium but see below
    clampToGround: geoJsonItem.clampToGround,
    markerUrl: defaultValue(style["marker-url"], null) // not in SimpleStyle spec but gives an alternate to maki marker symbols
  };

  options.fill = defaultColor(style.fill, (geoJsonItem.name || "") + " fill");
  if (defined(style["stroke-opacity"])) {
    options.stroke.alpha = parseFloat(style["stroke-opacity"]);
  }
  if (defined(style["fill-opacity"])) {
    options.fill.alpha = parseFloat(style["fill-opacity"]);
  } else {
    options.fill.alpha = 0.75;
  }
  geoJsonItem.opacity = options.fill.alpha;
  return dataSource.load(geoJsonItem._readyData, options).then(function() {
    var entities = dataSource.entities.values;

    for (var i = 0; i < entities.length; ++i) {
      var entity = entities[i];

      var properties = entity.properties || {};
      // If we've got a marker url use that in a billboard
github TerriaJS / terriajs / lib / Models / GeoJsonCatalogItem.js View on Github external
function createEntitiesFromHoles(entityCollection, holes, mainEntity) {
  if (!defined(holes)) {
    return;
  }

  for (var i = 0; i < holes.length; ++i) {
    createEntityFromHole(entityCollection, holes[i], mainEntity);
  }
}
github TerriaJS / terriajs / lib / Models / WebFeatureServiceCatalogGroup.js View on Github external
) {
  var result = new WebFeatureServiceCatalogItem(wfsGroup.terria);

  result.name = featureType.Title;
  result.description =
    defined(featureType.Abstract) && featureType.Abstract.length > 0
      ? featureType.Abstract
      : wfsGroup.description;
  result.dataCustodian = dataCustodian;
  result.url = wfsGroup.url;
  result.typeNames = featureType.Name;

  result.description = "";

  var wfsGroupHasDescription =
    defined(wfsGroup.description) && wfsGroup.description.length > 0;
  var layerHasAbstract =
    defined(featureType.Abstract) && featureType.Abstract.length > 0;

  if (wfsGroupHasDescription) {
    result.description += wfsGroup.description;
  }

  if (wfsGroupHasDescription && layerHasAbstract) {
    result.description += "<br>";
  }

  if (layerHasAbstract) {
    result.description += featureType.Abstract;
  }

  result.requestGeoJson = supportsJsonGetFeature;