/*
Switches to and displays the imagery layer appropriate for the given time. Uses a pre-fetched
layer if possible, and fetches the next one.
435611
function showDataForTime(catalogItem, currentTime, preloadNext = true) {
  function clearCurrent() {
    catalogItem._imageryLayer = undefined;
    catalogItem._currentIntervalIndex = -1;
    catalogItem._currentInterval = undefined;
  }

  function clearNext() {
    catalogItem._nextLayer = undefined;
    catalogItem._nextIntervalIndex = -1;
    catalogItem._nextInterval = undefined;
  }

  function replaceCurrentWithNext() {
    // Make the new one visible
    setOpacity(catalogItem, catalogItem._nextLayer, catalogItem.opacity);
    fixNextLayerOrder(
      catalogItem,
      catalogItem._imageryLayer,
      catalogItem._nextLayer
    );

    // Get rid of the old one.
    ImageryLayerCatalogItem.disableLayer(
      catalogItem,
      catalogItem._imageryLayer
    );
    catalogItem._imageryLayer = catalogItem._nextLayer;
    if (defined(catalogItem._imageryLayer)) {
      catalogItem._imageryLayer.imageryProvider.enablePickFeatures = true;
    }
    clearNext();
  }
  // Given an interval index, set up an imagery provider and layer.
  function nextLayerFromIndex(index) {
    const imageryProvider = catalogItem.createImageryProvider(
      catalogItem.intervals.get(index).data
    );
    imageryProvider.enablePickFeatures = false;
    catalogItem._nextLayer = ImageryLayerCatalogItem.enableLayer(
      catalogItem,
      imageryProvider,
      0.0
    );
    updateSplitDirection(catalogItem);
    ImageryLayerCatalogItem.showLayer(catalogItem, catalogItem._nextLayer);
  }

  const intervals = catalogItem.intervals;
  if (
    !defined(currentTime) ||
    !defined(intervals) ||
    !catalogItem.isEnabled ||
    !catalogItem.isShown
  ) {
    return;
  }

  const oldIndex = catalogItem._currentIntervalIndex;
  if (
    oldIndex >= 0 &&
    oldIndex < intervals.length &&
    TimeInterval.contains(intervals.get(oldIndex), currentTime) &&
    TimeInterval.equals(intervals.get(oldIndex), catalogItem._currentInterval)
  ) {
    // the currently shown imagery's interval contains the requested time, so nothing to do.
    return;
  }
  // Find the interval containing the current time.
  const currentTimeIndex = intervals.indexOf(currentTime);
  if (currentTimeIndex < 0) {
    // No interval contains this time, so do not show imagery at this time.
    ImageryLayerCatalogItem.disableLayer(
      catalogItem,
      catalogItem._imageryLayer
    );
    clearCurrent();
    return;
  } else if (
    currentTimeIndex !== catalogItem._nextIntervalIndex ||
    !TimeInterval.equals(
      intervals.get(currentTimeIndex),
      catalogItem._nextInterval
    )
  ) {
    // We have a "next" layer, but it's not the right one, so discard it.
    ImageryLayerCatalogItem.disableLayer(catalogItem, catalogItem._nextLayer);

    // Create the new "next" layer, which we will immediately use
    nextLayerFromIndex(currentTimeIndex);
  }

  // At this point we can assume that _nextLayer is applicable to this time.
  replaceCurrentWithNext();
  catalogItem._currentIntervalIndex = currentTimeIndex;
  catalogItem._currentInterval = intervals.get(currentTimeIndex);

  if (preloadNext) {
    // Prefetch the (predicted) next layer.
    // Here we use the terria clock because we want to optimise for the case where the item is playing on the
    // timeline (which is linked to the terria clock) and preload the layer at the next time that the timeslider
    // will move to.
    let nextIndex =
      currentTimeIndex + (catalogItem.terria.clock.multiplier >= 0.0 ? 1 : -1);
    if (
      nextIndex === intervals.length &&
      catalogItem.terria.clock.clockRange === ClockRange.LOOP_STOP
    ) {
      nextIndex = 0;
    }
    if (
      nextIndex >= 0 &&
      nextIndex < intervals.length &&
      (nextIndex !== catalogItem._nextIntervalIndex ||
        !TimeInterval.equals(
          catalogItem._nextInterval,
          intervals.get(nextIndex)
        ))
    ) {
      // Yes, we have found a non-cached, valid time index.
      nextLayerFromIndex(nextIndex);
      catalogItem._nextIntervalIndex = nextIndex;
      catalogItem._nextInterval = intervals.get(nextIndex);
    }
  }
}
876323
function() {
        if (!this.url && !this.imgDiv) {
            // fast path out - if there is no tile url and no previous image
            this.isLoading = false;
            return;
        }
        this.events.triggerEvent('beforeload');
        this.layer.div.appendChild(this.getTile());
        this.events.triggerEvent(this._loadEvent);
        var img = this.getImage();
        var src = img.getAttribute('src') || '';
        if (this.url && OpenLayers.Util.isEquivalentUrl(src, this.url)) {
            this._loadTimeout = window.setTimeout(
                OpenLayers.Function.bind(this.onImageLoad, this), 0
            );
        } else {
            this.stopLoading();
            if (this.crossOriginKeyword) {
                img.removeAttribute("crossorigin");
            }
            OpenLayers.Event.observe(img, "load",
                OpenLayers.Function.bind(this.onImageLoad, this)
            );
            OpenLayers.Event.observe(img, "error",
                OpenLayers.Function.bind(this.onImageError, this)
            );
            this.imageReloadAttempts = 0;
            this.setImgSrc(this.url);
        }
    }
1181003
function() {
        var layer = this.layer;
        for(var i=0; i<8; ++i) {
            if(this.rotate && i % 2 === 0) {
                layer.drawFeature(this.rotationHandles[i/2],
                    this.rotationHandleSymbolizer);
            }
            layer.drawFeature(this.handles[i], this.renderIntent);
        }
    }
86467
function() {
        var img = this.imgDiv;
        if (img.src != null) {
            this.imageReloadAttempts++;
            if (this.imageReloadAttempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {
                this.setImgSrc(this.layer.getURL(this.bounds));
            } else {
                OpenLayers.Element.addClass(img, "olImageLoadError");
                this.events.triggerEvent("loaderror");
                this.onImageLoad();
            }
        }
    }
1184483
def display(self):
        """"""
        size = list(range(len(self.layers)))
        size.reverse()
        for i in size:
            layer = self.layers[i]
            if layer.active:
                print('%s layer (size %d)' % (layer.name, layer.size))
                tlabel, olabel = '', ''
                if (layer.type == 'Output'):
                    if self.countWrong:
                        tlabel = ' (%s)' % self.classify(layer.target.tolist())
                        olabel = ' (%s)' % self.classify(layer.activation.tolist())
                        if olabel == tlabel:
                            self.numRight += 1
                        else:
                            olabel += '  *** WRONG ***'
                            self.numWrong += 1
                            if self.actDisplay is not None:
                                self.actDisplay.showWrong()
                    print('Target    : %s%s' % (pretty(layer.target, max=15), tlabel))
                print('Activation: %s%s' % (pretty(layer.activation, max=15), olabel))
                if self.patterned and layer.type != 'Hidden':
                    targetWord, diff = self.getWord( layer.target, returnDiff = 1)
                    if layer.kind == 'Output':
                        if targetWord == None:
                            print("Target Pattern   = %s" % "No match")
                        else:
                            if diff == 0.0:
                                print("Target Pattern   = '%s'" % targetWord)
                            else:
                                print("Target Pattern   = '%s'; difference = %f)" % (targetWord, diff))
                    actWord, diff = self.getWord( layer.activation, returnDiff = 1 )
                    if (layer.kind == 'Input' or layer.kind == 'Output'):
                        if actWord == None:
                            print("Matching Pattern = %s" % "No match")
                        else:
                            if diff == 0.0:
                                print("Matching Pattern = '%s'" % actWord)
                            else:
                                print("Matching Pattern = '%s'; difference = %f" % (actWord, diff))
                print("------------------------------------")
1307794
function(time) {
    var ms = time - this.lastTime;
    this.lastTime = time;

    // Update the different components of the scene.
    this.map.update(ms / 1000);
    this.player.update(ms / 1000);
    this.camera.render(this.player, this.map);

    // Continue the game loop.
    requestAnimationFrame(this.tick.bind(this));
  }
1063044
function mergeLayer( $image, $layerData, $lastLayerData )
    {
        $position = $image->calculatePosition( $layerData['parameters'], $this->width(), $this->height() );
        $x = $position['x'];
        $y = $position['y'];
        $imageObject = $this->imageObject();
        if ( $lastLayerData === null )
        {
            $destinationImageObject = $image->imageObjectInternal( false );
            if ( $destinationImageObject === null )
            {
                $isTrueColor = $this->isTruecolor();
                $image->cloneImage( $this->imageObject(), $this->width(), $this->height(),
                                    $isTrueColor );
            }
            else
            {
                $image->mergeImage( $destinationImageObject, $imageObject,
                                    $x, $y,
                                    $this->width(), $this->height(), 0, 0,
                                    $image->getTransparencyPercent( $layerData['parameters'] ) );
            }
        }
        else
        {
            $destinationImageObject = $image->imageObjectInternal();
            $image->mergeImage( $destinationImageObject, $imageObject,
                                $x, $y,
                                $this->width(), $this->height(), 0, 0,
                                $image->getTransparencyPercent( $layerData['parameters'] ) );
        }
    }
1357723
def _display(self, sent, now, chunk, mbps):
        
        if self.parent is not None:
            self.parent._display(self.parent.offset + sent, now, chunk, mbps)
            return

        elapsed = now - self.startTime

        if sent > 0 and self.total is not None and sent <= self.total:
            eta = (self.total - sent) * elapsed.total_seconds() / sent
            eta = datetime.timedelta(seconds=eta)
        else:
            eta = None

        self.output.write(
            "\r %s: Sent %s%s%s ETA: %s (%s) %s%20s\r" % (
                elapsed,
                util.humanize(sent),
                "" if self.total is None else " of %s" % (util.humanize(self.total),),
                "" if self.total is None else " (%d%%)" % (int(100 * sent / self.total),),
                eta,
                "" if not mbps else "%.3g Mbps " % (mbps,),
                chunk or "",
                " ",
            )
        )

        self.output.flush()
237121
def _time_show(self):
        """"""
        if not self._time_visible:
            self._time_visible = True
            self._time_window = tk.Toplevel(self)
            self._time_window.attributes("-topmost", True)
            self._time_window.overrideredirect(True)
            self._time_label = ttk.Label(self._time_window)
            self._time_label.grid()
            self._time_window.lift()
        x, y = self.master.winfo_pointerxy()
        geometry = "{0}x{1}+{2}+{3}".format(
            self._time_label.winfo_width(),
            self._time_label.winfo_height(),
            x - 15,
            self._canvas_ticks.winfo_rooty() - 10)
        self._time_window.wm_geometry(geometry)
        self._time_label.config(text=TimeLine.get_time_string(self.time, self._unit))
152232
function LayerGroupView(base) {
  var GMapsCartoDBLayerGroupView = function(layerModel, gmapsMap) {
    var self = this;
    var hovers = [];

    _.bindAll(this, 'featureOut', 'featureOver', 'featureClick');

    var opts = _.clone(layerModel.attributes);

    opts.map =  gmapsMap;

    var // preserve the user's callbacks
    _featureOver  = opts.featureOver,
    _featureOut   = opts.featureOut,
    _featureClick = opts.featureClick;

    var previousEvent;
    var eventTimeout = -1;

    opts.featureOver  = function(e, latlon, pxPos, data, layer) {
      if (!hovers[layer]) {
        self.trigger('layerenter', e, latlon, pxPos, data, layer);
      }
      hovers[layer] = 1;
      _featureOver  && _featureOver.apply(this, arguments);
      self.featureOver  && self.featureOver.apply(this, arguments);

      // if the event is the same than before just cancel the event
      // firing because there is a layer on top of it
      if (e.timeStamp === previousEvent) {
        clearTimeout(eventTimeout);
      }
      eventTimeout = setTimeout(function() {
        self.trigger('mouseover', e, latlon, pxPos, data, layer);
        self.trigger('layermouseover', e, latlon, pxPos, data, layer);
      }, 0);
      previousEvent = e.timeStamp;
    };

    opts.featureOut  = function(m, layer) {
      if (hovers[layer]) {
        self.trigger('layermouseout', layer);
      }
      hovers[layer] = 0;
      if(!_.any(hovers)) {
        self.trigger('mouseout');
      }
      _featureOut  && _featureOut.apply(this, arguments);
      self.featureOut  && self.featureOut.apply(this, arguments);
    };

    opts.featureClick  = _.debounce(function() {
      _featureClick  && _featureClick.apply(this, arguments);
      self.featureClick  && self.featureClick.apply(opts, arguments);
    }, 10);

    
    //CartoDBLayerGroup.call(this, opts);
    base.call(this, opts);
    cdb.geo.GMapsLayerView.call(this, layerModel, this, gmapsMap);
  };

  _.extend(
    GMapsCartoDBLayerGroupView.prototype,
    cdb.geo.GMapsLayerView.prototype,
    base.prototype,
    {

    _update: function() {
      this.setOptions(this.model.attributes);
    },

    reload: function() {
      this.model.invalidate();
    },

    remove: function() {
      cdb.geo.GMapsLayerView.prototype.remove.call(this);
      this.clear();
    },

    featureOver: function(e, latlon, pixelPos, data, layer) {
      // dont pass gmaps LatLng
      this.trigger('featureOver', e, [latlon.lat(), latlon.lng()], pixelPos, data, layer);
    },

    featureOut: function(e, layer) {
      this.trigger('featureOut', e, layer);
    },

    featureClick: function(e, latlon, pixelPos, data, layer) {
      // dont pass leaflet lat/lon
      this.trigger('featureClick', e, [latlon.lat(), latlon.lng()], pixelPos, data, layer);
    },

    error: function(e) {
      if(this.model) {
        //trigger the error form _checkTiles in the model
        this.model.trigger('error', e?e.errors:'unknown error');
        this.model.trigger('tileError', e?e.errors:'unknown error');
      }
    },

    ok: function(e) {
      this.model.trigger('tileOk');
    },

    tilesOk: function(e) {
      this.model.trigger('tileOk');
    },

    loading: function() {
      this.trigger("loading");
    },

    finishLoading: function() {
      this.trigger("load");
    }


  });
  return GMapsCartoDBLayerGroupView;
}
1234724
function() {
        var draw = OpenLayers.Tile.Image.prototype.shouldDraw.call(this);
        if(draw) {

            // this.url isn't set to the currect value yet, so we call getURL
            // on the layer and store the result in a local variable
            var url = this.layer.getURL(this.bounds);

            var usedIFrame = this.useIFrame;
            this.useIFrame = this.maxGetUrlLength !== null &&
                             !this.layer.async &&
                             url.length > this.maxGetUrlLength;

            var fromIFrame = usedIFrame && !this.useIFrame;
            var toIFrame = !usedIFrame && this.useIFrame;

            if(fromIFrame || toIFrame) {

                // Switching between GET (image) and POST (iframe).

                // We remove the imgDiv (really either an image or an iframe)
                // from the frame and set it to null to make sure initImage
                // will call getImage.

                if(this.imgDiv && this.imgDiv.parentNode === this.frame) {
                    this.frame.removeChild(this.imgDiv);
                }
                this.imgDiv = null;

                // And if we had an iframe we also remove the event pane.

                if(fromIFrame) {
                    this.frame.removeChild(this.frame.firstChild);
                }
            }
        }
        return OpenLayers.Tile.Image.prototype.draw.apply(this, arguments);
    }
993507
public void refresh() {
		if (layer instanceof RasterLayer) {
			RasterLayer rLayer = (RasterLayer) layer;
			rLayer.setVisible(false);
			rLayer.getStore().clear();
			rLayer.setVisible(true);
		} else if (layer instanceof org.geomajas.gwt.client.map.layer.VectorLayer) {
			org.geomajas.gwt.client.map.layer.VectorLayer vl = (org.geomajas.gwt.client.map.layer.VectorLayer) layer;
			vl.setVisible(false);
			vl.clearSelectedFeatures();
			vl.getFeatureStore().clear();
			vl.setVisible(true);
		}
	}
157537
def get_images_layer(self, image_id):
        """"""
        return self._http_call(self.IMAGE_LAYER, get, image_id=image_id)
13438
private WmsLayer getLayer(String layerId) {
		RasterLayer layer = configurationService.getRasterLayer(layerId);
		if (layer instanceof WmsLayer) {
			return (WmsLayer) layer;
		}
		return null;
	}
988116
function draw_shield(resp){

			    // ll("shield what: " + bbop.core.what_is(resp));
			    // ll("shield resp: " + bbop.core.dump(resp));

			     // First, extract the fields from the
			     // minimal response.
			     var fina = call_time_field_name;
			     var flist = resp.facet_field(call_time_field_name);

			     // Draw the proper contents of the shield.
			     filter_shield.draw(fina, flist, manager);
			 }
375946
function(feature) {
        var layer = feature.layer;
        var cont = this.events.triggerEvent("beforefeaturehighlighted", {
            feature : feature
        });
        if(cont !== false) {
            feature._prevHighlighter = feature._lastHighlighter;
            feature._lastHighlighter = this.id;
            var style = this.selectStyle || this.renderIntent;
            layer.drawFeature(feature, style);
            this.events.triggerEvent("featurehighlighted", {feature : feature});
        }
    }
26455
function(bounds, zoomChanged, dragging) {
        var display = this.visibility;
        if (!this.isBaseLayer) {
            display = display && this.inRange;
        }
        this.display(display);
    }