lib/Models/RegionTypeParameter.js
function(options) {
  FunctionParameter.call(this, options);

  this._regionProviderPromise = undefined;
  this._regionProviderList = undefined;

  this.validRegionTypes = options.validRegionTypes;

  // Track this so that defaultValue can update once regionProviderList is known.
  knockout.track(this, ["_regionProviderList"]);

  /**
   * Gets the default region provider if the user has not specified one.  If region-mapped data
   * is loaded on the map, this property returns the {@link RegionProvider} of the topmost
   * region-mapped catalog item.  Otherwise, it returns the first region provider.  If the
   * parameter has not yet been loaded, this property returns undefined.
   * @memberof RegionTypeParameter.prototype
   * @type {RegionProvider}
   */
  overrideProperty(this, "defaultValue", {
    get: function() {
      if (defined(this._defaultValue)) {
        return this._defaultValue;
      }

      const nowViewingItems = this.terria.nowViewing.items;
      if (nowViewingItems.length > 0) {
        for (let i = 0; i < nowViewingItems.length; ++i) {
          const item = nowViewingItems[i];
          if (
            defined(item.regionMapping) &&
            defined(item.regionMapping.regionDetails) &&
            item.regionMapping.regionDetails.length > 0
          ) {
            return item.regionMapping.regionDetails[0].regionProvider;
          }
        }
      }
      if (
        defined(this._regionProviderList) &&
        this._regionProviderList.length > 0
      ) {
        return this._regionProviderList[0];
      }

      // No defaults available; have we requested the region providers yet?
      this.load();
      return undefined;
    }
  });
}
function(options) {
  FunctionParameter.call(this, options);

  this._regionProviderPromise = undefined;
  this._regionProviderList = undefined;

  this.validRegionTypes = options.validRegionTypes;

  // Track this so that defaultValue can update once regionProviderList is known.
  knockout.track(this, ["_regionProviderList"]);

  /**
   * Gets the default region provider if the user has not specified one.  If region-mapped data
   * is loaded on the map, this property returns the {@link RegionProvider} of the topmost
   * region-mapped catalog item.  Otherwise, it returns the first region provider.  If the
   * parameter has not yet been loaded, this property returns undefined.
   * @memberof RegionTypeParameter.prototype
   * @type {RegionProvider}
   */
  overrideProperty(this, "defaultValue", {
    get: function() {
      if (defined(this._defaultValue)) {
        return this._defaultValue;
      }

      const nowViewingItems = this.terria.nowViewing.items;
      if (nowViewingItems.length > 0) {
        for (let i = 0; i < nowViewingItems.length; ++i) {
          const item = nowViewingItems[i];
          if (
            defined(item.regionMapping) &&
            defined(item.regionMapping.regionDetails) &&
            item.regionMapping.regionDetails.length > 0
          ) {
            return item.regionMapping.regionDetails[0].regionProvider;
          }
        }
      }
      if (
        defined(this._regionProviderList) &&
        this._regionProviderList.length > 0
      ) {
        return this._regionProviderList[0];
      }

      // No defaults available; have we requested the region providers yet?
      this.load();
      return undefined;
    }
  });
}
function ( options ) { FunctionParameter . call ( this , options ) ; this . _regionProviderPromise = undefined ; this . _regionProviderList = undefined ; this . validRegionTypes = options . validRegionTypes ; // Track this so that defaultValue can update once regionProviderList is known. knockout . track ( this , [ "_regionProviderList" ] ) ; /**
   * Gets the default region provider if the user has not specified one.  If region-mapped data
   * is loaded on the map, this property returns the {@link RegionProvider} of the topmost
   * region-mapped catalog item.  Otherwise, it returns the first region provider.  If the
   * parameter has not yet been loaded, this property returns undefined.
   * @memberof RegionTypeParameter.prototype
   * @type {RegionProvider}
   */ overrideProperty ( this , "defaultValue" , { get : function ( ) { if ( defined ( this . _defaultValue ) ) { return this . _defaultValue ; } const nowViewingItems = this . terria . nowViewing . items ; if ( nowViewingItems . length > 0 ) { for ( let i = 0 ; i < nowViewingItems . length ; ++ i ) { const item = nowViewingItems [ i ] ; if ( defined ( item . regionMapping ) && defined ( item . regionMapping . regionDetails ) && item . regionMapping . regionDetails . length > 0 ) { return item . regionMapping . regionDetails [ 0 ] . regionProvider ; } } } if ( defined ( this . _regionProviderList ) && this . _regionProviderList . length > 0 ) { return this . _regionProviderList [ 0 ] ; } // No defaults available; have we requested the region providers yet? this . load ( ) ; return undefined ; } } ) ; }
A parameter that specifies a type of region.

@alias RegionTypeParameter
@constructor
@extends FunctionParameter

@param {Object} [options] Object with the following properties:
@param {Terria} options.terria The Terria instance.
@param {String} options.id The unique ID of this parameter.
@param {String} [options.name] The name of this parameter.  If not specified, the ID is used as the name.
@param {String} [options.description] The description of the parameter.
@param {String[]} [options.validRegionTypes] The region types from which this RegionTypeParameter selects.  If this parameter is not specified, all region types
known to {@link Terria} may be selected.
A parameter that specifies a type of region .