How to use the terriajs-cesium/Source/ThirdParty/knockout.defineProperty 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 / DataCatalogItem.js View on Github external
/**
     * Returns an array of all the colors used by this data catalog item, including possible duplicates and undefined.
     * Called by ChartCatalogGroup.
     * @memberOf DataCatalogItem.prototype
     * @type {Array}
     */
    knockout.defineProperty(this, 'colorsUsed', {
        get: function() {
            if (!defined(this.validYColumns)) {
                return [];
            }
            return this.validYColumns.map(function(column) { return column.color; });
        }
    });

    knockout.defineProperty(this, 'concepts', {
        get: function() {
            var concept = new DisplayVariablesConcept('', that.toggleYColumn.bind(that));  // TODO: I've changed DisplayVariableConcept params, so this won't work
            if (defined(that.validYColumns) && (that.validYColumns.length > 0)) {
                //create ko concept for now viewing ui
                for (var i = 0; i < that.validYColumns.length; i++) {
                    var thisYColumn = that.validYColumns[i];
                    var active = defined(that.yColumns) ? (that.yColumns.indexOf(thisYColumn) >= 0) : false;
                    // If it's active and doesn't have a color yet, give it one
                    if (active && !defined(thisYColumn.color) && that.terria.catalog.chartDataGroup) {
                        thisYColumn.color = that.terria.catalog.chartDataGroup.getNextColor();
                    }
                    concept.addVariable(thisYColumn.name, active, thisYColumn.color);
                }
            }
            return [concept];
        }
github TerriaJS / terriajs / lib / ReactViewModels / ViewState.js View on Github external
this.storyBuilderShown = false;

    // default value is null, because user has not made decision to show or
    // not show story
    // will be explicitly set to false when user 1. dismiss story
    // notification or 2. close a story
    this.storyShown = null;

    this.currentStoryId = 0;

    this.featurePrompts = [];

    this._explorerPanelIsVisible = false;
    this._showHelpMenu = false;
    knockout.defineProperty(this, "showHelpMenu", {
      get: function() {
        return this._showHelpMenu;
      },
      set: function(bool) {
        this._showHelpMenu = bool;

        // Help menu has been opened, don't need to show a popup to highlight presence of it to the user again
        if (bool) {
          this.toggleFeaturePrompt("mapGuidesLocation", true, true);
        }
      }
    });

    this.showWelcomeMessage = this.terria.getLocalProperty(
      WELCOME_PROPERTY_KEY
    );
github TerriaJS / terriajs / lib / ViewModels / RegionParameterEditor.js View on Github external
realRegion: regions[i]
                    });

                    if (result.length > 100) {
                        break;
                    }
                }
            }

            this.autocompleteVisible = result.length > 0 && result.length < 100;

            return result;
        }
    });

    knockout.defineProperty(this, 'value', {
        get: function() {
            return this.parameter.getValue(this._parameterValues);
        },
        set: function(value) {
            if (defined(value) && defined(value.realRegion)) {
                value = value.realRegion;
            }
            this._parameterValues[this.parameter.id] = value;
            this._displayValue = undefined;

            updateMapFromValue(this);
        }
    });

    knockout.defineProperty(this, 'regionProvider', {
        get: function() {
github TerriaJS / terriajs / lib / ReactViewModels / ViewState.js View on Github external
knockout.defineProperty(this, "explorerPanelIsVisible", {
      get: function() {
        return this._explorerPanelIsVisible;
      },
      set: function(bool) {
        if (!bool && this.location && this.location.pathname !== "/") {
          setTimeout(() => {
            this.history.push("/");
            this._explorerPanelIsVisible = false;
          }, 300);
        }
        this._explorerPanelIsVisible = bool;
      }
    });

    knockout.defineProperty(this, "chartIsOpen", {
      get: function() {
        const chartableItems = this.terria.catalog.chartableItems;
        const chartableColumnExists = chartableItems.some(
          item =>
            item.isEnabled && defined(item.chartData()) && !item.dontChartAlone
        );
        return chartableColumnExists;
      },
      set: function(value) {
        const chartableItems = this.terria.catalog.chartableItems;
        for (let i = chartableItems.length - 1; i >= 0; i--) {
          const item = chartableItems[i];
          if (item.isEnabled && defined(item.tableStructure)) {
            item.tableStructure.columns
              .filter(column => column.isActive === !value)
              .forEach(column => column.toggleActive());
github TerriaJS / terriajs / lib / ViewModels / BooleanParameterEditor.js View on Github external
var BooleanParameterEditor = function(options) {
    this.catalogFunction = options.catalogFunction;
    this.parameter = options.parameter;

    var parameterValues = options.parameterValues;
    knockout.defineProperty(this, 'value', {
        get: function() {
            return parameterValues[this.parameter.id];
        },
        set: function(value) {
            parameterValues[this.parameter.id] = value;
        }
    });
};
github TerriaJS / terriajs / lib / Models / CatalogItem.js View on Github external
}
  });

  /**
   * Gets the CatalogItems current time as the discrete time that the CatalogItem has information for.
   * Returns the nearest time in-range if the clock is beyond the range of the intervals specified by the layer.
   * Returns undefined if it is not possible to query the time (i.e. the item doesn't have a clock, availableDates or
   * intervals).
   *
   * See also discreteTime if you want the discrete time that is undefined if the current time is beyond the range of
   * the intervals specified by the item.
   *
   * @member {Date} clampedDiscreteTime
   * @memberOf CatalogItem.prototype
   */
  knockout.defineProperty(this, "clampedDiscreteTime", {
    get: function() {
      if (defined(this.discreteTime)) {
        return this.discreteTime;
      }

      if (!hasValidCurrentTimeAndIntervals(this)) {
        return undefined;
      }

      if (timeIsBeforeStart(this, this.currentTime)) {
        return timeAtIndex(this, 0);
      }

      if (timeIsAfterStop(this, this.currentTime)) {
        return timeAtIndex(this, this.intervals.length - 1);
      }
github TerriaJS / terriajs / lib / ViewModels / CatalogItemInfoViewModel.js View on Github external
var CatalogItemInfoViewModel = function(catalogItem) {
    this.catalogItem = catalogItem;
    this.svgArrowDown = svgArrowDown;
    this.svgArrowRight = svgArrowRight;

    this.showDataDetails = false;
    this.showServiceDetails = false;

    this._domNodes = undefined;

    knockout.track(this, ['showDataDetails', 'showServiceDetails']);

    knockout.defineProperty(this, 'sortedInfo', {
        get: function() {
            var items = this.catalogItem.info.slice();

            var infoSectionOrder = defaultValue(this.catalogItem.infoSectionOrder, CatalogItemInfoViewModel.infoSectionOrder);

            naturalSort.insensitive = true;
            items.sort(function(a, b) {
                var aIndex = infoSectionOrder.indexOf(a.name);
                var bIndex = infoSectionOrder.indexOf(b.name);
                if (aIndex >= 0 && bIndex < 0) {
                    return -1;
                } else if (aIndex < 0 && bIndex >= 0) {
                    return 1;
                } else if (aIndex < 0 && bIndex < 0) {
                    return naturalSort(a.name, b.name);
                } else {
github TerriaJS / terriajs / lib / Models / AugmentedVirtuality.js View on Github external
*/
  knockout.defineProperty(this, "manualAlignmentSet", {
    get: function() {
      return this._realignAlpha !== 0.0 || this._realignHeading !== 0.0;
    }
  });

  /**
   * Gets the index of the current hover level.
   *
   * Use <code>AugmentedVirtuality.PRESET_HEIGHTS.length</code> to find the total avaliable levels.
   *
   * @memberOf AugmentedVirtuality.prototype
   * @member {int} hoverLevel
   */
  knockout.defineProperty(this, "hoverLevel", {
    get: function() {
      return this._hoverLevel;
    }
  });

  /**
   * Gets or sets the the maximum number of times that the camera orientation will be updated per second. This is
   * the number of camera orientation updates per seconds is capped to (explicitly the number of times the
   * orientation is updated per second might be less but it won't be more then this number). We want the number of
   * times that the orientation is updated capped so that we don't consume to much battery life updating to
   * frequently, but responsiveness is still acceptable.
   *
   * @memberOf AugmentedVirtuality.prototype
   * @member {Float} maximumUpdatesPerSecond
   */
  knockout.defineProperty(this, "maximumUpdatesPerSecond", {
github TerriaJS / terriajs / lib / Models / CatalogItem.js View on Github external
this._dataUrl = undefined;
    this._dataUrlType = undefined;

    knockout.track(this, ['rectangle', 'dataCustodian', 'attribution', 'metadataUrl', 'isEnabled',
        'isShown', 'isLegendVisible', 'clock', 'isLoading', 'isMappable', 'nowViewingMessage', 'zoomOnEnable',
        'isEnableable', 'showsInfo', 'nowViewingMessage', 'url', '_legendUrl', '_legendUrls', '_dataUrl',
        '_dataUrlType', 'nowViewingCatalogItem']);

    var evaluatingLegendUrl = false;

    /**
     * Gets or sets the URLs of the legends to show when this catalog item is enabled.
     * @member {LegendUrl} legendUrls
     * @memberOf CatalogItem.prototype
     */
    knockout.defineProperty(this, 'legendUrls', {
        get: function() {
            if (!defined(this._legendUrls) || this._legendUrls.length === 0) {
                var legendUrl = evaluatingLegendUrl ? undefined : this.legendUrl;
                if (defined(legendUrl) && defined(legendUrl.url) && legendUrl.url.length > 0) {
                    return [legendUrl];
                }
            }
            return this._legendUrls;
        },
        set: function(value) {
            this._legendUrls = value;
            this._legendUrl = undefined;
        }
    });

    /**
github TerriaJS / terriajs / lib / ViewModels / RegionParameterEditor.js View on Github external
knockout.defineProperty(this, 'value', {
        get: function() {
            return this.parameter.getValue(this._parameterValues);
        },
        set: function(value) {
            if (defined(value) && defined(value.realRegion)) {
                value = value.realRegion;
            }
            this._parameterValues[this.parameter.id] = value;
            this._displayValue = undefined;

            updateMapFromValue(this);
        }
    });

    knockout.defineProperty(this, 'regionProvider', {
        get: function() {
            return this.parameter.getRegionProvider(this._parameterValues);
        }
    });

    knockout.defineProperty(this, 'displayValue', {
        get: function() {
            var region = this.value;
            if (!defined(region)) {
                return this._displayValue;
            }

            var index = this.regionProvider.regions.indexOf(region);
            if (index >= 0 && this._regionNames[index]) {
                return this._regionNames[index];
            } else {