Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Aptana didn't rename properly

Mike McGann285acce2aa6f
diff --git a/src/js/Worldview/Map/DailyProduct.js b/src/js/Worldview/Map/DailyProduct.js
deleted file mode 100644
index d3da28b86..000000000
--- a/src/js/Worldview/Map/DailyProduct.js
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * NASA Worldview
- *
- * This code was originally developed at NASA/Goddard Space Flight Center for
- * the Earth Science Data and Information System (ESDIS) project.
- *
- * Copyright (C) 2013 United States Government as represented by the
- * Administrator of the National Aeronautics and Space Administration.
- * All Rights Reserved.
- */
-
-Worldview.namespace("Map");
-
-/**
- * Class: Worldview.Map.DailyProduct
- * Product that updates on a daily basis.
- *
- * A requirement in Worldview is to be able to slide between several dates
- * and quickly see the changes per day without redrawing the map. This trick is
- * performed by adding a new layer for each day selected and setting the
- * opacity for the other layers to zero. Once the map moves, the "cached"
- * layers are invalidated and eligbile for removal the next time the map
- * needs to be redrawn.
- *
- * Delegates to:
- * <Worldview.Map.Product>
- *
- * Constructor: DailyProduct
- * Creates a new instance.
- *
- * Parameters:
- * map - The map object that layers will be added and removed from.
- * config - Configuration for this layer as a <Worldview.JSON.MapConfig.Product>
- * object.
- */
-Worldview.Map.DailyProduct = function(map, config) {
-
- var self = Worldview.Map.Product(config);
-
- // The current z-index for all layers.
- var zIndex = 0;
-
- // Layers from previous days are cached for quick display when moving
- // the time slider
- var cachedLayers = {};
-
- // Layers that are no longer valid because the map has moved. These
- // are removed using a timeout to prevent map flickering.
- var staleLayers = [];
-
- // The layer that is currently visible and seen by the user
- var currentLayer = null;
-
- // The day of the data displayed on the map
- var currentDay;
-
- // Active lookup table for all layers in the product, null if no table
- // is active
- var lookupTable = null;
-
- // Timeout identifier for the reaper that cleans out stale layers.
- var reaperId = null;
-
- // Time, in milliseconds, to wait before reaping stale layers.
- var reapDelay = 500;
-
- //-------------------------------------------------------------------------
- // Public
- //-------------------------------------------------------------------------
-
- var init = function() {
- self.setDay(Worldview.today());
-
- map.events.register("movestart", self, invalidate);
- map.events.register("zoomend", self, invalidate);
- $(window).resize(invalidate);
- };
-
- /**
- * Method: setDay
- * Changes the map to display the product for the given day.
- *
- * Parameters:
- * d - The day to display.
- */
- self.setDay = function(d) {
- // Don't do anything if nothing has changed or if there are no valid
- // layers
- if ( !d ) {
- return;
- }
- var ds = d.toISOStringDate();
- if ( ds === currentDay ) {
- return;
- }
-
- // If there is a current layer, cache it
- if ( currentLayer ) {
- cachedLayers[currentDay] = currentLayer;
- }
- currentDay = ds;
-
- // If the layer is hidden, don't fetch anything
- if ( self.visible ) {
- fetchLayer();
- } else {
- currentLayer = null;
- }
- };
-
- self.setOpacity = function(opacity) {
- if ( self.opacity === opacity ) {
- return;
- }
- self.opacity = opacity;
- if ( currentLayer ) {
- Worldview.Map.setVisiblity(currentLayer, self.visible, self.opacity);
- }
- };
-
- self.setVisibility = function(visible) {
- if ( self.visible === visible ) {
- return;
- }
- self.visible = visible;
- if ( visible && !currentLayer ) {
- fetchLayer();
- }
- if ( currentLayer ) {
- Worldview.Map.setVisibility(currentLayer, self.visible,
- self.opacity);
- }
- };
-
- /**
- * Method: setLookup
- * Applies a lookup table to this product. If this product doesn't have
- * a lookup table already, all layers are discarded and a new layer is
- * created using <Worldview.Map.CanvasTile>.
- *
- * Parameters:
- * lookup - The <ColorLookup> to apply.
- */
- self.setLookup = function(lookup) {
- var resetRequired = (lookupTable === null);
- lookupTable = lookup;
- if ( currentLayer ) {
- if ( resetRequired ) {
- reset();
- fetchLayer();
- } else {
- invalidate();
- currentLayer.lookupTable = lookup;
- applyLookup(currentLayer);
- }
- }
- };
-
- /**
- * Method: clearLookup
- * Removes a lookup table from this product. If the product has a lookup
- * table, all layers are discarded and a new layer using the standard
- * tile renderer is created.
- */
- self.clearLookup = function() {
- if ( lookupTable !== null ) {
- lookupTable = null;
- if ( currentLayer ) {
- reset();
- fetchLayer();
- }
- }
- };
-
- /**
- * Method: setZIndex
- * Sets the z-index for all layers in this product.
- *
- * Parameters:
- * index - The z-index to set. All layers are set with this z-index
- * except for the visible layer which is set to index + 1.
- */
- self.setZIndex = function(index) {
- zIndex = index;
- refreshZOrder();
- };
-
- /**
- * Method: dispose
- * Remove all layers from the map.
- */
- self.dispose = function() {
- reset();
- if ( reaperId !== null ) {
- clearTimeout(reaperId);
- }
- map.events.unregister("movestart", self, invalidate);
- map.events.unregister("zoomend", self, invalidate);
- $(window).unbind("resize", invalidate);
- };
-
- //-------------------------------------------------------------------------
- // Private
- //-------------------------------------------------------------------------
-
- var fetchLayer = function() {
- var previousLayer = currentLayer;
-
- if ( currentDay in cachedLayers ) {
- currentLayer = cachedLayers[currentDay];
- Worldview.Map.setVisibility(currentLayer, self.visible,
- self.opacity);
- delete cachedLayers[currentDay];
- } else {
- var additionalOptions = {};
- if ( lookupTable !== null ) {
- additionalOptions.tileClass = Worldview.Map.CanvasTile;
- }
- currentLayer = self.createLayer(additionalOptions, {
- time: currentDay
- });
- if ( lookupTable !== null ) {
- currentLayer.lookupTable = lookupTable;
- }
- map.addLayer(currentLayer);
- }
-
- if ( previousLayer ) {
- previousLayer.setZIndex(zIndex);
- }
- currentLayer.setZIndex(zIndex + 1);
- Worldview.Map.setVisibility(currentLayer, self.visible, self.opacity);
-
- if ( previousLayer ) {
- Worldview.Map.setVisibility(previousLayer, false, 0);
- }
- };
-
- /*
- * Iterates through each tile in the layer and applies the lookup.
- */
- var applyLookup = function(layer) {
- $.each(layer.grid, function(index, row) {
- $.each(row, function(index, tile) {
- tile.applyLookup();
- });
- });
- };
-
- /*
- * Sets the z-index on all layers.
- */
- var refreshZOrder = function() {
- $.each(cachedLayers, function(i, layer) {
- layer.setZIndex(zIndex);
- });
- if ( currentLayer ) {
- currentLayer.setZIndex(zIndex + 1);
- }
- };
-
- /*
- * Clears the cache and removes the current layer. Called when switching
- * between a lookup and non-lookup based layer.
- */
- var reset = function() {
- invalidate();
- if ( currentLayer ) {
- map.removeLayer(currentLayer);
- }
- currentLayer = null;
- }
-
- /*
- * Hide all layers that are not currently being displayed and move them
- * to the stale set. Restart the reaper to remove those layers.
- */
- var invalidate = function() {
- if ( currentLayer ) {
- var opacity = currentLayer.div.style.opacity;
- if ( opacity !== "" && opacity < 0.001 ) {
- currentLayer.setVisibility(false);
- }
- }
- if ( $.isEmptyObject(cachedLayers) ) {
- return;
- }
- $.each(cachedLayers, function(day, layer) {
- layer.setVisibility(false);
- staleLayers.push(layer);
- });
- cachedLayers = {};
-
- if ( reaperId !== null ) {
- clearTimeout(reaperId);
- }
- reaperId = setTimeout(function() { reaper(); }, reapDelay);
- };
-
-
- /*
- * Remove all layers in the invalid set from the map.
- */
- var reaper = function(all) {
- $.each(staleLayers, function(index, layer) {
- if ( map.getLayerIndex(layer) >= 0 ) {
- map.removeLayer(layer);
- }
- });
- staleLayers = [];
- refreshZOrder();
- reaperId = null;
- };
-
- init();
- return self;
-}
diff --git a/src/js/Worldview/Map/Product.js b/src/js/Worldview/Map/Product.js
deleted file mode 100644
index 04b5072fe..000000000
--- a/src/js/Worldview/Map/Product.js
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * NASA Worldview
- *
- * This code was originally developed at NASA/Goddard Space Flight Center for
- * the Earth Science Data and Information System (ESDIS) project.
- *
- * Copyright (C) 2013 United States Government as represented by the
- * Administrator of the National Aeronautics and Space Administration.
- * All Rights Reserved.
- */
-
-Worldview.namespace("Map");
-
-/**
- * Class: Worldview.Map.Product
- * Provides common methods for all products.
- *
- * Constructor: Worldview.Map.Product
- * Creates a new instance.
- *
- * Parameters:
- * c - Configuration for this layer as a <Worldview.JSON.MapConfig.Product>
- * object.
- */
-Worldview.Map.Product = function(c) {
-
- var self = {};
- self.opacity = 1;
- self.visible = false;
- var config;
-
- var init = function() {
- config = $.extend(true, {}, c);
-
- var prop = config.properties || {};
- if ( prop.style === undefined ) { prop.style = ""; }
- if ( prop.tileSize ) {
- prop.tileSize = new OpenLayers.Size(prop.tileSize[0],
- prop.tileSize[1]);
- }
- if ( prop.transitionEffect === undefined ) {
- prop.transitionEffect = "resize";
- }
-
- // HACK: For the moment, some projections use TWMS and others use
- // WMTS. Copy the type attribute to the correct location if required
- if ( config.properties.type ) {
- config.type = config.properties.type;
- delete config.properties.type;
- }
- // If this is a WMS layer, the urls are passed in directly and not
- // part of the parameters or properties
- if ( config.type === "wms" && config.properties.url ) {
- config.url = config.properties.url;
- delete config.properties.url;
- }
- // TWMS does not like the projection parameter, remove it
- if ( config.type === "wms" && config.parameters ) {
- delete config.parameters.projection;
- }
- };
-
- /**
- * Function: createLayer
- * Creates a new layer based on the configuration provided.
- *
- * Parameters:
- * additionalProperties - If specified, these properites are merged into
- * the product configuration to create the layer.
- *
- * Return:
- * An OpenLayers Layer.
- */
- self.createLayer = function(additionalProperties, additionalParameters) {
- var properties = config.properties;
- if ( additionalProperties ) {
- properties = $.extend(true, {}, config.properties,
- additionalProperties);
- }
- var parameters = config.parameters;
- if ( additionalParameters ) {
- parameters = $.extend(true, {}, config.parameters,
- additionalParameters);
- }
- var layer;
- if ( properties.opacity ) {
- self.opacity = properties.opacity;
- } else {
- properties.opacity = self.opacity;
- }
- properties.visiblity = false;
- if ( config.type === "wms" ) {
- layer = new Worldview.Map.TWMSLayer(config.name, config.url,
- parameters, properties);
- } else if ( config.type === "wmts" ) {
- layer = new OpenLayers.Layer.WMTS(properties);
- if ( parameters && parameters.time ) {
- layer.mergeNewParams({"time": parameters.time});
- }
- } else if ( config.type === "graticule" ) {
- layer = new Worldview.Map.GraticuleLayer(config.name,
- properties);
- } else {
- throw new Error("Unsupported layer type: " + config.type);
- }
-
- return layer;
- };
-
- init();
- return self;
-}
diff --git a/src/js/Worldview/Map/StaticProduct.js b/src/js/Worldview/Map/StaticProduct.js
deleted file mode 100644
index e6038f258..000000000
--- a/src/js/Worldview/Map/StaticProduct.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * NASA Worldview
- *
- * This code was originally developed at NASA/Goddard Space Flight Center for
- * the Earth Science Data and Information System (ESDIS) project.
- *
- * Copyright (C) 2013 United States Government as represented by the
- * Administrator of the National Aeronautics and Space Administration.
- * All Rights Reserved.
- */
-
-Worldview.namespace("Map");
-
-/**
- * Class: Worldview.Map.StaticProduct
- * Product that is not based on the current date or time.
- *
- * Inherits from:
- * <Worldview.Map.Product>
- *
- * Constructor: StaticProduct
- * Creates a new instance.
- *
- * Parameters:
- * map - The map object that layers will be added and removed from.
- * config - Configuration for this layer as a <Worldview.JSON.MapConfig.Product>
- * object.
- */
-Worldview.Map.StaticProduct = function(map, config) {
-
- var self = Worldview.Map.Product(config);
-
- // There is only one layer and this is it
- var layer = null;
-
- // Tue current z-index for the layer
- var zIndex = 0;
-
- //-------------------------------------------------------------------------
- // Public
- //-------------------------------------------------------------------------
- var init = function() {
- layer = self.createLayer();
- map.addLayer(layer);
- layer.setZIndex(zIndex);
-
- map.events.register("movestart", self, invalidate);
- map.events.register("zoomend", self, invalidate);
- };
-
- /**
- * Method: setDay
- * Does nothing.
- */
- self.setDay = function(d) {
- };
-
- self.setOpacity = function(opacity) {
- if ( self.opacity === opacity ) {
- return;
- }
- self.opacity = opacity;
- Worldview.Map.setVisibility(layer, self.visible, self.opacity);
- };
-
- self.setVisibility = function(visible) {
- if ( self.visible === visible ) {
- return;
- }
- self.visible = visible;
- Worldview.Map.setVisibility(layer, self.visible, self.opacity);
- };
-
- /**
- * Method: setZIndex
- * Sets the z-index for the product's layer.
- *
- * Parameters:
- * index - The z-index to set.
- */
- self.setZIndex = function(index) {
- zIndex = index;
- setZOrder();
- };
-
- /**
- * Method: dispose
- * Removes the layer from the map.
- */
- self.dispose = function() {
- map.removeLayer(layer);
- map.events.unregister("movestart", self, invalidate);
- map.events.unregister("zoomend", self, invalidate);
- };
-
- /**
- * Method: setLookup
- * Does nothing. This can be implemented once there is a static data
- * product that could be adjusted.
- */
- self.setLookup = function(lookup) {
- };
-
- /**
- * Method: clearLookup
- * Does nothing. This can be implemented once there is a static data
- * product that could be adjusted.
- */
- self.clearLookup = function() {
- };
-
- //-------------------------------------------------------------------------
- // Private
- //-------------------------------------------------------------------------
- var setZOrder = function() {
- layer.setZIndex(zIndex);
- };
-
- var invalidate = function() {
- if ( layer ) {
- var opacity = layer.div.style.opacity;
- if ( opacity !== "" && opacity < 0.001 ) {
- layer.setVisibility(false);
- }
- }
- setZOrder();
- };
-
- init();
- return self;
-}
\ No newline at end of file