How to use the terriajs-cesium/Source/ThirdParty/when.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 / SensorObservationServiceCatalogItem.js View on Github external
// MODE 1. Do not load observation data for the features.
    // Just show where the features are, and when the feature info panel is opened, then load the feature's observation data
    // (via the 'chart' column in _tableStructure, which generates a call to item.loadIntoTableStructure).
    var tableStructure = item._tableStructure;
    if (!defined(tableStructure)) {
      tableStructure = new TableStructure(item.name);
    }
    var columns = createColumnsFromMapping(item, tableStructure);
    tableStructure.columns = columns;
    if (!defined(item._tableStructure)) {
      item._tableStyle.dataVariable = null; // Turn off the legend and give all the points a single colour.
      item.initializeFromTableStructure(tableStructure);
    } else {
      item._tableStructure.columns = tableStructure.columns;
    }
    return when();
  }
  // MODE 2. Create a big time-varying tableStructure with all the observations for all the features.
  // In this mode, the feature info panel shows a chart through as a standard time-series, like it would for any time-varying csv.
  return item
    .loadIntoTableStructure(featuresOfInterest)
    .then(function(observationTableStructure) {
      if (
        !defined(observationTableStructure) ||
        observationTableStructure.columns[0].values.length === 0
      ) {
        throw new TerriaError({
          sender: item,
          title: item.name,
          message:
            "The Sensor Observation Service did not return any features matching your query."
        });
github TerriaJS / terriajs / lib / Models / createCatalogItemFromFileOrUrl.js View on Github external
" conversion service? This may work for " +
        "small, zipped Esri Shapefiles or MapInfo TAB files."
    ).then(function(confirmed) {
      return confirmed
        ? loadItem(new OgrCatalogItem(terria), name, fileOrUrl)
        : undefined;
    });
  }

  var isUrl = typeof fileOrUrl === "string";
  dataType = defaultValue(dataType, "auto");

  var name = isUrl ? fileOrUrl : fileOrUrl.name;

  if (dataType === "auto") {
    return when(createCatalogItemFromUrl(name, terria, isUrl)).then(function(
      newItem
    ) {
      //##Doesn't work for file uploads
      if (!defined(newItem)) {
        return tryConversionService();
      } else {
        // It's a file or service we support directly
        // In some cases (web services), the item will already have been loaded by this point.
        return loadItem(newItem, name, fileOrUrl);
      }
    });
  } else if (dataType === "other") {
    // user explicitly chose "Other (use conversion service)"
    return getConfirmation(
      terria,
      viewState,
github TerriaJS / terriajs / lib / Models / createCatalogItemFromFileOrUrl.js View on Github external
function getConfirmation(terria, viewState, confirmConversion, message) {
  if (!confirmConversion) {
    return when(true);
  }

  var d = when.defer(); // there's no `when.promise(resolver)` in when 1.7.1
  viewState.notifications.push({
    confirmText: "Upload",
    denyText: "Cancel",
    title: "Use conversion service?",
    message: message,
    confirmAction: function() {
      d.resolve(true);
    },
    denyAction: function() {
      d.resolve(false);
    }
  });
  return d.promise;
github TerriaJS / terriajs / lib / Models / Terria.js View on Github external
Terria.prototype.addInitSource = function(initSource, fromStory = false) {
  var promise = when();
  var that = this;
  var viewerChangeListener;
  function zoomToInitialView() {
    that.currentViewer.zoomTo(that.initialView, 0.0);
    if (defined(viewerChangeListener)) {
      viewerChangeListener();
    }
  }
  // Extract the list of CORS-ready domains.
  if (defined(initSource.corsDomains)) {
    this.corsProxy.corsDomains.push.apply(
      this.corsProxy.corsDomains,
      initSource.corsDomains
    );
  }
github TerriaJS / terriajs / lib / Map / Reproject.js View on Github external
checkProjection: function(proj4ServiceBaseUrl, code) {
    if (Proj4Definitions.hasOwnProperty(code)) {
      return true;
    }

    var url = new urijs(proj4ServiceBaseUrl).segment(code).toString();
    return when(
      loadText(url),
      function(proj4Text) {
        Proj4Definitions[code] = proj4Text;
        console.log("Added new string for", code, "=", proj4Text);
        return true;
      },
      function(err) {
        return false;
      }
    );
  }
};
github TerriaJS / terriajs / lib / Models / sendFeedback.js View on Github external
if (!defined(options) || !defined(options.terria)) {
    throw new DeveloperError("options.terria is required.");
  }

  var terria = options.terria;

  if (!defined(terria.configParameters.feedbackUrl)) {
    raiseError(terria);
    return;
  }

  const shareLinkPromise = options.sendShareURL
    ? BuildShareLink.canShorten(terria)
      ? BuildShareLink.buildShortShareLink(terria)
      : when(BuildShareLink.buildShareLink(terria))
    : when("Not shared");

  return shareLinkPromise
    .then(shareLink => {
      const feedbackData = {
        title: options.title,
        name: options.name,
        email: options.email,
        shareLink: shareLink,
        comment: options.comment
      };
      if (
        options.additionalParameters &&
        terria.serverConfig.config &&
        terria.serverConfig.config.additionalFeedbackParameters
      ) {
        terria.serverConfig.config.additionalFeedbackParameters.forEach(
github TerriaJS / terriajs / lib / Models / addUserCatalogMember.js View on Github external
var addUserCatalogMember = function(
  terria,
  newCatalogMemberOrPromise,
  options
) {
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);

  return when(newCatalogMemberOrPromise, function(newCatalogItem) {
    if (!defined(newCatalogItem)) {
      return;
    }

    newCatalogItem.isUserSupplied = true;

    terria.catalog.userAddedDataGroup.add(newCatalogItem);

    if (defaultValue(options.open, true) && defined(newCatalogItem.isOpen)) {
      newCatalogItem.isOpen = true;
    }

    if (
      defaultValue(options.enable, true) &&
      defined(newCatalogItem.isEnabled)
    ) {
github TerriaJS / terriajs / lib / Core / readXml.js View on Github external
function readXml(file) {
  return when(
    readText(file),
    function(result) {
      var xml = parser.parseFromString(result, "application/xml");
      if (
        !xml ||
        !xml.documentElement ||
        xml.getElementsByTagName("parsererror").length > 0
      ) {
        throw new RuntimeError("The file does not contain valid XML.");
      }
      return xml;
    },
    function(e) {
      throw e;
    }
  );
github TerriaJS / terriajs / lib / Core / readJson.js View on Github external
function readJson(file) {
  return when(
    readText(file),
    function(result) {
      try {
        return JSON.parse(result);
      } catch (e) {
        if (e instanceof SyntaxError) {
          return json5.parse(result);
        } else {
          throw e;
        }
      }
    },
    function(e) {
      throw e;
    }
  );

terriajs-cesium

Cesium for TerriaJS.

Apache-2.0
Latest version published 8 months ago

Package Health Score

68 / 100
Full package analysis