Interactive interface for browsing global, full-resolution satellite imagery
Code cleanup
Mike McGanna3a8c162046e
diff --git a/doc/NaturalDocs/Menu.txt b/doc/NaturalDocs/Menu.txtindex 146b396f4..db86be7db 100644--- a/doc/NaturalDocs/Menu.txt+++ b/doc/NaturalDocs/Menu.txt@@ -86,6 +86,7 @@ Group: Code Reference {File: Product (/Users/jmcgann/Code/Aptana/worldview/js/Worldview/Map/Product.js)File: ProductMap (/Users/jmcgann/Code/Aptana/worldview/js/Worldview/Map/ProductMap.js)File: StaticProduct (/Users/jmcgann/Code/Aptana/worldview/js/Worldview/Map/StaticProduct.js)+ File: GraticleLayer (/Users/jmcgann/Code/Aptana/worldview/js/Worldview/Map/GraticuleLayer.js)} # Group: MapGroup: Palette {diff --git a/js/Worldview.js b/js/Worldview.jsindex 9c1231da2..ba50288ee 100644--- a/js/Worldview.js+++ b/js/Worldview.js@@ -170,13 +170,24 @@var parent = window;$.each(nodes, function(index, node) {if ( parent[node] === undefined ) {- throw "In " + path + ", " + node + " is undefined";+ throw new Error("In " + path + ", " + node + " is undefined");}parent = parent[node];});return parent;};+ /**+ * Function: queryStringToObject+ * Converts a query string into an object.+ *+ * Parameters:+ * queryString - The query string to convert+ *+ * Return:+ * An object where each property is one of the parameters found in the+ * query string.+ */ns.queryStringToObject = function(queryString) {var parameters = queryString.split("&");result = {};@@ -189,7 +200,6 @@/*** Function: extractFromQuery- ** Extracts the value of the given key from the querystring.** Parameters:@@ -207,7 +217,19 @@elsereturn val[1];};-++ /**+ * Function: ajaxError+ * Wrapper for handling AJAX errors when the XHR and status code is not+ * necessary.+ *+ * Parameters:+ * handler - Callback to be invoked on error that accepts one argument,+ * the error that was thrown.+ *+ * Returns:+ * The function wrapper.+ */ns.ajaxError = function(handler) {return function(jqXHR, textStatus, errorThrown) {handler(errorThrown);@@ -265,7 +287,7 @@*/ns.clamp = function(min, max, value) {if ( min > max ) {- throw "Invalid clamp range (" + min + " - " + max + ")";+ throw new Error("Invalid clamp range (" + min + " - " + max + ")");}if ( value < min ) { return min; }if ( value > max ) { return max; }diff --git a/js/Worldview/Map.js b/js/Worldview/Map.jsindex a98230be1..4dafda810 100644--- a/js/Worldview/Map.js+++ b/js/Worldview/Map.js@@ -52,6 +52,16 @@ $(function(ns) {})};+ /**+ * Function: isExtentValid+ * Determines if an exent object contains valid values.+ *+ * Parameters:+ * extent - An OpenLayers.Bound ojbect+ *+ * Returns:+ * False if any of the values is NaN, otherwise returns true.+ */ns.isExtentValid = function(extent) {if ( extent === undefined ) {return false;@@ -65,6 +75,10 @@ $(function(ns) {return valid;};+ /**+ * Property: tileScheduler+ * Scheduler used to render canvas tiles. Must be initialized on startup.+ */ns.tileScheduler = null;}(Worldview.Map));diff --git a/js/Worldview/Map/CanvasTile.js b/js/Worldview/Map/CanvasTile.jsindex 38d41ebe2..e8916e9b2 100644--- a/js/Worldview/Map/CanvasTile.js+++ b/js/Worldview/Map/CanvasTile.js@@ -28,34 +28,40 @@ Worldview.namespace("Map");* (end code)** To apply a lookup table to dynamically change the colors of the tile,- * set a lookupTable property in OpenLayers.Layer with a mapping of RGBA- * integer values to RGBA integer values. Example:+ * set a lookupTable property in OpenLayers.Layer with a <ColorLookup> object.+ * Example:** (start code)- * var grn = { r: 0x00, g: 0xff, b: 0xff, a: 0xff };- * var red = { r: 0xff, g: 0x00, b: 0x00, a: 0xff };- *- * var grnInt = ( grn.a << 24 | grn.b << 16 | grn.g << 8 | grn.r );- * var redInt = ( red.a << 24 | grn.b << 16 | grn.g << 8 | grn.r );+ * var red = { r: 255, g: 0x00, b: 0x00, a: 255 };** // Map green to blue* myLayer.lookupTable = {- * grnInt: redInt+ * "0,255,0,255": redInt* };* (end code)*/Worldview.Map.CanvasTile = OpenLayers.Class(OpenLayers.Tile.Image, {- /*- * Element that contains the canvas to draw the tile. Initially set to- * null and created after the tile has been loaded. Set back to null- * when clear() is invoked.- */+ // Element that contains the canvas to draw the tile. Initially set to+ // null and created after the tile has been loaded. Set back to null+ // when clear() is invoked.canvas: null,++ // Canvas that contains the pixels of the original tile. This allows+ // lookups to be applied multiple times without reloading the layer.canvasOriginal: null,++ // Graphics context for the canvasgraphics: null,- grpahicsOriginal: null,++ // Graphics context for the canvas containing the original image+ graphicsOriginal: null,++ // The ID of the last job submitted to the scheduler. If a response+ // comes back that is not this ID, the tile is stale and can be thrown+ // outlatestJobId: null,+log: Logging.getLogger("Worldview.Map.CanvasTile"),initialize: function(layer, position, bounds, url, size, options) {@@ -115,7 +121,6 @@ Worldview.Map.CanvasTile = OpenLayers.Class(OpenLayers.Tile.Image, {style.width = image.style.width;style.height = image.style.height;}- //style.visibility = image.style.visibility;style.visibility = "hidden";style.opacity = 0;style.filter = image.style.filter;@@ -135,7 +140,12 @@ Worldview.Map.CanvasTile = OpenLayers.Class(OpenLayers.Tile.Image, {return this.frame ? this.frame : canvas;},+ /*+ * Relods a tile from the server.+ */setImgSrc: function() {+ // If the tile is being reloaded, hide the canvas so that stale+ // tiles are not visibleif ( this.canvas ) {this.log.debug(this.id + ": setImgSrc: " + arguments[0]);this.canvas.visibility = "hidden";@@ -147,15 +157,87 @@ Worldview.Map.CanvasTile = OpenLayers.Class(OpenLayers.Tile.Image, {}},+ /*+ * Takes the loaded image and submits it to the scheduler to render the+ * color lookup table.+ */+ onImageLoad: function() {+ OpenLayers.Event.stopObservingElement(this.imgDiv);++ this.log.debug(this.id + ": tile loaded");++ // Draw the image that was loaded and save it for anytime a color+ // lookup needs to be applied+ this.canvasOriginal = document.createElement("canvas");+ this.graphicsOriginal = this.canvasOriginal.getContext("2d");+ this.canvasOriginal.width = this.imgDiv.width;+ this.canvasOriginal.height = this.imgDiv.height;+ this.graphicsOriginal.drawImage(this.imgDiv, 0, 0);++ // Ensure the canvas object has been created+ var canvas = this.getCanvas();+ canvas.width = this.canvasOriginal.width;+ canvas.height = this.canvasOriginal.height;++ this.scheduleTile();+ },++ /**+ * Function: applyLookup+ * Changes the lookup table for the tile and repaints the canvas.+ */+ applyLookup: function() {+ if ( !this.canvas ) {+ return;+ }+ this.isLoading = true;+ this.events.triggerEvent("loadstart");+ this.scheduleTile();+ },++ /*+ * Submit the render operation to the scheduler.+ */+ scheduleTile: function() {+ var lookupTable = this.layer.lookupTable;+ var source = this.graphicsOriginal.getImageData(0, 0, this.canvas.width,+ this.canvas.height);+ var destination = this.graphics.getImageData(0, 0, this.canvas.width,+ this.canvas.height);++ this.latestJobId = Worldview.Map.tileScheduler.submit({+ message: {+ lookupTable: lookupTable,+ source: source,+ destination: destination+ },+ callback: this.onTileRendered,+ self: this+ });+ },++ /*+ * Callback for when the tile has finished rendering.+ */onTileRendered: function(results) {var self = results.self;var canvas = self.canvas;++ // If there is no longer a canvas (a zoom operation cleared it out+ // for use in the back buffer) or this render is not the last tile+ // submitted, this data is now stale and can be thrown away.if ( !canvas || results.id !== self.latestJobId ) {self.log.debug(self.id + ": Discarding stale tile");++ // If the operation was cancelled during execution, ignore the result.} else if ( results.status === "cancelled" ) {self.log.debug(self.id + ": Cancelled");++ // If there was an error during processing, report it here} else if ( results.status === "error" ) {self.log.error(self.id + ": Unable to render tile");++ // Draw the tile} else if ( results.status === "success" ){var imageData = results.message.destination;self.graphics.putImageData(imageData, 0, 0);@@ -170,63 +252,12 @@ Worldview.Map.CanvasTile = OpenLayers.Class(OpenLayers.Tile.Image, {self.isLoading = false;self.events.triggerEvent("loadend");},-- applyLookup: function(imageLoaded) {- if ( !this.canvas ) {- if ( imageLoaded ) {- this.isLoading = false;- this.events.triggerEvent("loadend");- }- return;- }- this.isLoading = true;-- var lookupTable = this.layer.lookupTable;- var source = this.graphicsOriginal.getImageData(0, 0, this.canvas.width,- this.canvas.height);- var destination = this.graphics.getImageData(0, 0, this.canvas.width,- this.canvas.height);-- this.latestJobId = Worldview.Map.tileScheduler.submit({- message: {- lookupTable: lookupTable,- source: source,- destination: destination- },- callback: this.onTileRendered,- self: this- });- },-+/*- * Draws the loaded image to the canvas and applies a lookup table if+ * This is called during a zoom for the resize transition effect. It+ * steals away the canvas object for use in the scaled image shown before+ * tiles are loaded.*/- onImageLoad: function() {- OpenLayers.Event.stopObservingElement(this.imgDiv);-- this.log.debug(this.id + ": tile loaded");- this.canvasOriginal = document.createElement("canvas");- this.graphicsOriginal = this.canvasOriginal.getContext("2d");- this.canvasOriginal.width = this.imgDiv.width;- this.canvasOriginal.height = this.imgDiv.height;-- var canvas = this.getCanvas();- canvas.width = this.canvasOriginal.width;- canvas.height = this.canvasOriginal.height;-- this.graphicsOriginal.drawImage(this.imgDiv, 0, 0);-- if ( this.layer.lookupTable ) {- this.applyLookup(true);- } else {- this.canvas.style.visibility = "inherit";- this.canvas.style.opacity = this.layer.opacity;- this.isLoading = false;- this.canvasContext = null;- this.events.triggerEvent("loadend");- }- },-createBackBuffer: function() {if ( !this.canvas || this.isLoading ) {return;diff --git a/js/Worldview/Map/DailyProduct.js b/js/Worldview/Map/DailyProduct.jsindex 346d915b8..b43b3b321 100644--- a/js/Worldview/Map/DailyProduct.js+++ b/js/Worldview/Map/DailyProduct.js@@ -22,7 +22,7 @@ Worldview.namespace("Map");* layers are invalidated and eligbile for removal the next time the map* needs to be redrawn.*- * Inherits from:+ * Delegates to:* <Worldview.Map.Product>** Constructor: DailyProduct@@ -40,10 +40,12 @@ Worldview.Map.DailyProduct = function(map, config) {// The current z-index for all layers.var zIndex = 0;+ // Layers from previous days are cached for quick display when moving+ // the time slidervar cachedLayers = {};// Layers that are no longer valid because the map has moved. These- // can be removed on the next map redrawn+ // are removed using a timeout to prevent map flickering.var staleLayers = [];// The layer that is currently visible and seen by the user@@ -52,10 +54,16 @@ Worldview.Map.DailyProduct = function(map, config) {// The day of the data displayed on the mapvar currentDay;+ // Active lookup table for all layers in the product, null if no table+ // is activevar lookupTable = null;+ // Timeout identifier for the reaper that cleans out stale layers.var reaperId = null;+ // Time, in seconds, to wait before reaping stale layers.+ var reapDelay = 2000;+//-------------------------------------------------------------------------// Public//-------------------------------------------------------------------------@@ -66,47 +74,7 @@ Worldview.Map.DailyProduct = function(map, config) {map.events.register("movestart", self, onMoveStart);map.events.register("zoomend", self, onZoomEnd);};-- var fetchLayer = function() {- var previousLayer = currentLayer;-- // If a layer was visible, hide it.- if ( previousLayer ) {- previousLayer.div.style.opacity = 0;- }- if ( currentDay in cachedLayers ) {- currentLayer = cachedLayers[currentDay];- delete cachedLayers[currentDay];- } else {- var additionalOptions = null;- if ( lookupTable !== null ) {- additionalOptions = {- tileClass: Worldview.Map.CanvasTile- };- }- currentLayer = self.createLayer(additionalOptions);- currentLayer.mergeNewParams({ time: currentDay });- if ( lookupTable !== null ) {- currentLayer.lookupTable = lookupTable;- }- currentLayer.div.style.opacity = 0;- map.addLayer(currentLayer);- }-- // The visible layer is one level higher than all the other layers- if ( previousLayer ) {- previousLayer.setZIndex(zIndex);- }- currentLayer.setZIndex(zIndex + 1);-- // Make sure the layer is visible.- currentLayer.div.style.opacity = currentLayer.opacity;- if ( currentLayer.getVisibility() === false ) {- currentLayer.setVisibility(true);- }- }-/*** Method: setDay* Changes the map to display the product for the given day.@@ -115,6 +83,8 @@ Worldview.Map.DailyProduct = function(map, config) {* d - The day to display.*/self.setDay = function(d) {+ // Don't do anything if nothing has changed or if there are no valid+ // layersif ( !d ) {return;}@@ -122,13 +92,24 @@ Worldview.Map.DailyProduct = function(map, config) {if ( currentLayer && ds === currentDay ) {return;}++ // If there is a current layer, cache itif ( currentLayer ) {cachedLayers[currentDay] = currentLayer;}currentDay = ds;fetchLayer();};-++ /**+ * 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;@@ -142,6 +123,12 @@ Worldview.Map.DailyProduct = function(map, config) {}};+ /**+ * 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;@@ -179,7 +166,50 @@ Worldview.Map.DailyProduct = function(map, config) {//-------------------------------------------------------------------------// Private//-------------------------------------------------------------------------++ var fetchLayer = function() {+ var previousLayer = currentLayer;++ // If a layer was visible, hide it.+ if ( previousLayer ) {+ previousLayer.div.style.opacity = 0;+ }++ if ( currentDay in cachedLayers ) {+ currentLayer = cachedLayers[currentDay];+ delete cachedLayers[currentDay];+ } else {+ var additionalOptions = null;+ if ( lookupTable !== null ) {+ additionalOptions = {+ tileClass: Worldview.Map.CanvasTile+ };+ }+ currentLayer = self.createLayer(additionalOptions);+ currentLayer.mergeNewParams({ time: currentDay });+ if ( lookupTable !== null ) {+ currentLayer.lookupTable = lookupTable;+ }+ currentLayer.div.style.opacity = 0;+ map.addLayer(currentLayer);+ }+ // The visible layer is one level higher than all the other layers+ if ( previousLayer ) {+ previousLayer.setZIndex(zIndex);+ }+ currentLayer.setZIndex(zIndex + 1);++ // Make sure the layer is visible.+ currentLayer.div.style.opacity = currentLayer.opacity;+ if ( currentLayer.getVisibility() === false ) {+ currentLayer.setVisibility(true);+ }+ };++ /*+ * 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) {@@ -200,6 +230,10 @@ Worldview.Map.DailyProduct = function(map, config) {}};+ /*+ * Clears the cache and removes the current layer. Called when switching+ * between a lookup and non-lookup based layer.+ */var reset = function() {clearCache();map.removeLayer(currentLayer);@@ -208,7 +242,7 @@ Worldview.Map.DailyProduct = function(map, config) {/** Hide all layers that are not currently being displayed and move them- * to the invalid set.+ * to the stale set. Restart the reaper to remove those layers.*/var clearCache = function() {$.each(cachedLayers, function(day, layer) {@@ -219,7 +253,7 @@ Worldview.Map.DailyProduct = function(map, config) {if ( reaperId !== null ) {clearTimeout(reaperId);}- reaperId = setTimeout(function() { reaper(); }, 2000);+ reaperId = setTimeout(function() { reaper(); }, reapDelay);};diff --git a/js/Worldview/Map/GraticuleLayer.js b/js/Worldview/Map/GraticuleLayer.jsindex c48baec2c..64ecabb23 100644--- a/js/Worldview/Map/GraticuleLayer.js+++ b/js/Worldview/Map/GraticuleLayer.js@@ -11,6 +11,10 @@Worldview.namespace("Map");+/**+ * Class: Worldview.Map.GraticleLayer+ * Standard OpenLayers graticle control that acts like a layer.+ */Worldview.Map.GraticuleLayer = OpenLayers.Class(OpenLayers.Layer, {graticuleLineStyle: null,@@ -35,10 +39,11 @@ Worldview.Map.GraticuleLayer = OpenLayers.Class(OpenLayers.Layer, {fontColor: '#0000e1',fontOpacity: 1.0});--},+ /*+ * Add the control when the layer is added to the map+ */setMap: function(map) {OpenLayers.Layer.prototype.setMap.apply(this, arguments);@@ -53,6 +58,9 @@ Worldview.Map.GraticuleLayer = OpenLayers.Class(OpenLayers.Layer, {map.addControl(graticule);},+ /*+ * Remove the contorl when the layer is removed from the map+ */removeMap: function(map) {OpenLayers.Layer.prototype.removeMap.apply(this, arguments);map.removeControl(graticule);diff --git a/js/Worldview/Map/Product.js b/js/Worldview/Map/Product.jsindex a3b49e6f9..303c806ad 100644--- a/js/Worldview/Map/Product.js+++ b/js/Worldview/Map/Product.js@@ -45,7 +45,15 @@ Worldview.Map.Product = function(c) {};/**+ * 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) {var properties = config.properties;@@ -62,7 +70,7 @@ Worldview.Map.Product = function(c) {return new Worldview.Map.GraticuleLayer(config.name,properties);} else {- throw "Unsupported layer type: " + config.type;+ throw new Error("Unsupported layer type: " + config.type);}};diff --git a/js/Worldview/Map/ProductMap.js b/js/Worldview/Map/ProductMap.jsindex a8aedd529..e564e4c44 100644--- a/js/Worldview/Map/ProductMap.js+++ b/js/Worldview/Map/ProductMap.js@@ -78,7 +78,7 @@ Worldview.Map.ProductMap = function(containerId, mapConfig, component) {var init = function() {var $container = $("#" + containerId);if ( $container.length === 0 ) {- throw "No container for ProductMap: " + containerId;+ throw new Error("No container for ProductMap: " + containerId);}// Create map objects, one for each projection.@@ -137,7 +137,7 @@ Worldview.Map.ProductMap = function(containerId, mapConfig, component) {*/self.setProjection = function(projection) {if ( !(projection in activeMaps) ) {- throw "Unsupported projection: " + projection;+ throw new Error("Unsupported projection: " + projection);}log.debug("Switch projection: " + projection);@@ -228,19 +228,35 @@ Worldview.Map.ProductMap = function(containerId, mapConfig, component) {refreshZOrder();};+ /**+ * Method: setPalettes+ * Sets which products should have custom palettes applied.+ *+ * Parameters:+ * activePalettes - An object which has product names as properties+ * and palette names as values.+ */self.setPalettes = function(activePalettes) {$.each(activeMaps, function(projection, map) {$.each(map.products, function(name, product) {if ( name in activePalettes ) {+ // Find the rendered palette for this productvar productConfig = self.mapConfig.products[name];var renderedName = productConfig.rendered;var renderedPalette = self.mapConfig.palettes[renderedName];++ // Find the palette that should be used insteadvar paletteName = activePalettes[name];var palette = self.mapConfig.palettes[paletteName];++ // Create a lookup table and map it to the color+ // values found in the rendered palettevar indexed = Worldview.Palette.toIndexedLookup(productConfig.bins, palette, productConfig.stops);var lookup = Worldview.Palette.toColorLookup(- indexed, renderedPalette.stops);+ indexed, renderedPalette.stops);++ // Applyproduct.setLookup(lookup);} else {product.clearLookup();@@ -248,15 +264,6 @@ Worldview.Map.ProductMap = function(containerId, mapConfig, component) {});});};-- self.clearLookup = function(product, lookup) {- $.each(products, function(projection, activeProducts) {- var index = $.inArray(product, products);- if ( index >= 0 ) {- products[index].clearLookup(lookup);- }- });- };//-------------------------------------------------------------------------// Private@@ -436,7 +443,7 @@ Worldview.Map.ProductMap = function(containerId, mapConfig, component) {} else if ( config.product === "static" ) {return Worldview.Map.StaticProduct(map, config);}- throw "Unsupported product type: " + config.product;+ throw new Error("Unsupported product type: " + config.product);};var onZoomEnd = function(evt) {diff --git a/js/Worldview/Map/StaticProduct.js b/js/Worldview/Map/StaticProduct.jsindex 5e3dfae5a..622d2cf95 100644--- a/js/Worldview/Map/StaticProduct.js+++ b/js/Worldview/Map/StaticProduct.js@@ -76,13 +76,21 @@ Worldview.Map.StaticProduct = function(map, config) {map.events.unregister("movestart", self, refreshZOrder);map.events.unregister("zoomend", self, refreshZOrder);};-++ /**+ * Method: setLookup+ * Does nothing. This can be implemented once there is a static data+ * product that could be adjusted.+ */self.setLookup = function(lookup) {- layer.lookupTable = lookup;};-++ /**+ * Method: clearLookup+ * Does nothing. This can be implemented once there is a static data+ * product that could be adjusted.+ */self.clearLookup = function() {- delete layer.lookupTable;};//-------------------------------------------------------------------------diff --git a/js/Worldview/Palette.js b/js/Worldview/Palette.jsindex f2728e74f..8e7bd192a 100644--- a/js/Worldview/Palette.js+++ b/js/Worldview/Palette.js@@ -429,11 +429,12 @@ $(function() {* Example:* (begin code)* var lookup = {- * "{\"r\":0,\"g\":0,\"b\":255,\"a\":255}": { r: 0xff, g: 0x00, b: 0x00, a: 0xff }+ * "0,0,255,255": { r: 0xff, g: 0x00, b: 0x00, a: 0xff }** (end code)*- * Each property in the object is a stringified <ColorRGBA> object that contains+ * Each property in the object is a string containing integer red, green,+ * blue, and alpha values separated by commas. Each property contains contains* a <ColorRGBA> value to map.*/diff --git a/js/Worldview/Palette/ColorBar.js b/js/Worldview/Palette/ColorBar.jsindex 3ec52905b..632508fdb 100644--- a/js/Worldview/Palette/ColorBar.js+++ b/js/Worldview/Palette/ColorBar.js@@ -97,8 +97,8 @@ Worldview.Palette.ColorBar = function(spec) {} else if ( spec.selector ) {$canvas = $(spec.selector);if ( $canvas.length === 0 ) {- throw "No such canvas element (" + spec.selector +- ") for the ColorBar";+ throw new Error("No such canvas element (" + spec.selector ++ ") for the ColorBar");}canvas = $canvas.get(0);diff --git a/js/Worldview/Palette/PaletteSelector.js b/js/Worldview/Palette/PaletteSelector.jsindex 763bb0736..91de368a9 100644--- a/js/Worldview/Palette/PaletteSelector.js+++ b/js/Worldview/Palette/PaletteSelector.js@@ -50,7 +50,8 @@ Worldview.Palette.PaletteSelector = function(spec) {var init = function() {$container = $(spec.selector);if ( $container.length === 0 ) {- throw "Container not found for PaletteSelector: " + spec.selector;+ throw new Error("Container not found for PaletteSelector: " ++ spec.selector);}var items = [];diff --git a/js/Worldview/Scheduler.js b/js/Worldview/Scheduler.jsindex c04780615..cab1b33ca 100644--- a/js/Worldview/Scheduler.js+++ b/js/Worldview/Scheduler.js@@ -61,7 +61,7 @@ Worldview.Scheduler = function(config) {var executing = 0;// Number of workers to start- var maxWorkers = maxWorkers || 1;+ var maxWorkers = config.max || 1;//-------------------------------------------------------------------------// Public@@ -143,6 +143,7 @@ Worldview.Scheduler = function(config) {}jobs[id] = job;+ log.debug("Executing: " + executing);if ( executing < maxWorkers ) {execute(job);} else {diff --git a/js/Worldview/Widget/Map.js b/js/Worldview/Widget/Map.jsindex 6fa6f9ef5..b49a65549 100644--- a/js/Worldview/Widget/Map.js+++ b/js/Worldview/Widget/Map.js@@ -48,7 +48,7 @@ Worldview.Widget.Map = function(containerId, config) {if ( REGISTRY ) {REGISTRY.register(containerId, self);} else {- throw "Cannot register Map, REGISTRY not found";+ throw new Error("Cannot register Map, REGISTRY not found");}self.config = validateConfig(self.config);@@ -141,7 +141,7 @@ Worldview.Widget.Map = function(containerId, config) {* Throws an unsupported exception.*/self.setDataSourceUrl = function(url) {- throw "setDataSourceUrl: unsupported";+ throw new Error("setDataSourceUrl: unsupported");};/**@@ -161,7 +161,7 @@ Worldview.Widget.Map = function(containerId, config) {* invoked.*/self.setStatus = function(status) {- throw "setStatus: unsupported";+ throw new Error("setStatus: unsupported");};/**@@ -170,7 +170,7 @@ Worldview.Widget.Map = function(containerId, config) {* invoked.*/self.getStatus = function() {- throw "getStatus: unsupported";+ throw new Error("getStatus: unsupported");};/*@@ -187,7 +187,8 @@ Worldview.Widget.Map = function(containerId, config) {var _config = ["defaultProjection"];$.each(_config, function(index, key) {if ( !(key in config.config) ) {- throw "config." + key + " is required in the map configuraiton";+ throw new Error("config." + key + " is required in the " ++ "map configuraiton");}});return config;diff --git a/js/Worldview/Widget/PaletteManager.js b/js/Worldview/Widget/PaletteManager.jsindex 4c350413a..44fb33091 100644--- a/js/Worldview/Widget/PaletteManager.js+++ b/js/Worldview/Widget/PaletteManager.js@@ -26,7 +26,8 @@ Worldview.Widget.PaletteManager = function(containerId, config) {if ( REGISTRY ) {REGISTRY.register(containerId, self);} else {- throw "Cannot register PaletteManager, REGISTRY not found";+ throw new Error("Cannot register PaletteManager, REGISTRY " ++ "not found");}REGISTRY.markComponentReady(containerId);};