Interactive interface for browsing global, full-resolution satellite imagery
Added dialog box for when palettes are active and image download is selected
Mike McGanne7f3fb7ef523
diff --git a/ant/js.build.xml b/ant/js.build.xmlindex a57698747..60b507c63 100644--- a/ant/js.build.xml+++ b/ant/js.build.xml@@ -47,7 +47,7 @@<file name="Worldview/Map/GraticuleLayer.js"/><file name="Worldview/Widget/Map.js"/>- <file name="Worldview/Widget/PaletteManager.js"/>+ <file name="Worldview/Widget/Palette.js"/><file name="Worldview/Widget/WorldviewMap.js"/><file name="main.js"/>diff --git a/css/sote.css b/css/sote.cssindex f7731d83b..080343365 100644--- a/css/sote.css+++ b/css/sote.css@@ -5,6 +5,7 @@ div {display:block;}.yui-skin-sam .yui-panel {background: transparent; width:700px; font: 13px "Gill Sans", sans-serif; font-weight:100;}.yui-skin-sam .yui-panel-container .hd{ background:rgba(38, 43, 49, 0.65); color:#ffffff; border:none; padding:0;}.yui-skin-sam .yui-panel-container .bd{ background:rgba(18, 18, 18, 0.75); color:#d7d7d7;}+.yui-skin-sam .yui-panel-container .ft{ background:rgba(18, 18, 18, 0.75); color:#d7d7d7;}.yui-skin-sam .yui-panel-container .bd h3{ color:#FFFFFF; font: 18px "Gill Sans", sans-serif; font-weight:400; text-decoration:none; }.yui-skin-sam .yui-panel-container .bd h4{ color:#000000; font: 18px "Gill Sans", sans-serif; font-weight:400; text-decoration:none; }.yui-skin-sam .yui-panel-container .bd a {color: #48a8ff; }diff --git a/index.html b/index.htmlindex dd6eece95..d6e78f20d 100644--- a/index.html+++ b/index.html@@ -127,7 +127,7 @@<!-- js.dev --> <script type="text/javascript" src="js/Worldview/Map/TileRenderer.js"></script><!-- js.dev --> <script type="text/javascript" src="js/Worldview/Widget/Map.js"></script>- <!-- js.dev --> <script type="text/javascript" src="js/Worldview/Widget/PaletteManager.js"></script>+ <!-- js.dev --> <script type="text/javascript" src="js/Worldview/Widget/Palette.js"></script><!-- js.dev --> <script type="text/javascript" src="js/Worldview/Widget/WorldviewMap.js"></script><!-- js.dev --> <script type="text/javascript" src="js/main.js"></script>diff --git a/js/Worldview.js b/js/Worldview.jsindex ba50288ee..9f87af52f 100644--- a/js/Worldview.js+++ b/js/Worldview.js@@ -124,6 +124,71 @@}};+ /**+ * Function: ask+ * Asks the end user a yes or no question in a dialog box.+ *+ * Parameters:+ * spec.header - Header text to be displayed in the dialog box. If not+ * specified, "Notice" will be used.+ * spec.message - Message text to be displayed in the dialog box. If not+ * specified, "Are you sure?" will be used.+ * spec.noButton - Text to be used in the no button. If not specified,+ * "No" will be used.+ * spec.yesButton - Text to be used in the yes button. If not specified,+ * "Yes" will be used.+ * spec.onYes - Function to execute when the yes button is pressed. If+ * not specified, the dialog box simply closes.+ * spec.onNo - Function to execute when the no button is pressed. If+ * not specified, the dialog box simply closes.+ */+ ns.ask = function(spec) {+ var dialog = new YAHOO.widget.SimpleDialog("dialog", {+ width: "20em",+ effect: {+ effect: YAHOO.widget.ContainerEffect.FADE,+ duration: 0.25+ },+ fixedcenter: true,+ modal: true,+ visible: false,+ draggable: false+ });++ var header = spec.header || "Notice";+ dialog.setHeader(" " + header);+ dialog.setBody(spec.message || "Are you sure?");++ var handleYes = function() {+ try {+ this.hide();+ if ( spec.onYes ) {+ spec.onYes();+ }+ } catch ( error ) {+ Worldview.error("Internal error", error);+ }+ };+ var handleNo = function() {+ try {+ this.hide();+ if ( spec.onNo ) {+ spec.onNo();+ }+ } catch ( error ) {+ Worldview.error("Internal error", error);+ }+ };++ var buttons = [+ { text: spec.noButton || "No", handler: handleNo },+ { text: spec.yesButton || "Yes", handler: handleYes }+ ];+ dialog.cfg.queueProperty("buttons", buttons);+ dialog.render(document.body);+ dialog.show();+ }+/*** Function: size* Gets the number of properties in an object. This only includesdiff --git a/js/Worldview/Permalink.js b/js/Worldview/Permalink.jsindex f8650347b..fc14a6151 100644--- a/js/Worldview/Permalink.js+++ b/js/Worldview/Permalink.js@@ -146,7 +146,7 @@ $(function() {}var qs = ns.fromRegistry();-+// FIXME: Some components currently have values that are not supposed// to be in the query string or return undefined values. For now,// pick out the actual values that are really needed@@ -155,17 +155,17 @@ $(function() {var time = Worldview.extractFromQuery("time", qs);var s = Worldview.extractFromQuery("switch", qs);- qs = "?map="+map+"&products="+products+"&time="+time+"&switch="+s;+ var link = "?map="+map+"&products="+products+"&time="+time+"&switch="+s;- var palettes = Worldview.extractFromQuery("palettes");+ var palettes = Worldview.extractFromQuery("palettes", qs);if ( palettes ) {- qs += "&palettes=" + palettes;+ link += "&palettes=" + palettes;}var url = window.location.href;var prefix = url.split("?")[0];prefix = (prefix !== null && prefix !== undefined) ? prefix: url;- $('#permalink_content').val(prefix + qs);+ $('#permalink_content').val(prefix + link);permOverlay.show();permOverlay.center();diff --git a/js/Worldview/Widget/PaletteManager.js b/js/Worldview/Widget/Palette.jssimilarity index 96%rename from js/Worldview/Widget/PaletteManager.jsrename to js/Worldview/Widget/Palette.jsindex 44fb33091..8bde2e25a 100644--- a/js/Worldview/Widget/PaletteManager.js+++ b/js/Worldview/Widget/Palette.js@@ -11,7 +11,7 @@Worldview.namespace("Widget");-Worldview.Widget.PaletteManager = function(containerId, config) {+Worldview.Widget.Palette = function(containerId, config) {var self = {};var log = Logging.getLogger("Worldview.PaletteManager");@@ -56,7 +56,7 @@ Worldview.Widget.PaletteManager = function(containerId, config) {var qs = "";if ( parts.length > 0 ) {qs = containerId + "=" + parts.join("~");- }+ }return qs;} catch ( error ) {Worldview.error("Unable to update", error);@@ -131,10 +131,7 @@ Worldview.Widget.PaletteManager = function(containerId, config) {activePalettes[product] = palette.id;}REGISTRY.fire(self);- });---+ });};self.loadFromQuery = function(queryString) {diff --git a/js/main.js b/js/main.jsindex a2b39165d..4dc599d12 100644--- a/js/main.js+++ b/js/main.js@@ -29,7 +29,7 @@ $(function() {// Initialize "static" vars// Create mapvar m = Worldview.Widget.WorldviewMap("map", config);- var palettes = Worldview.Widget.PaletteManager("palettes", config);+ var palettes = Worldview.Widget.Palette("palettes", config);var ss = new SOTE.widget.Switch("switch",{dataSourceUrl:"a",selected:"geographic"});var a = new SOTE.widget.Bank("products",{paletteManager: palettes, dataSourceUrl:"ap_products.php",title:"My Layers",selected:{antarctic:"baselayers,MODIS_Terra_CorrectedReflectance_TrueColor~overlays,antarctic_coastlines", arctic:"baselayers,MODIS_Terra_CorrectedReflectance_TrueColor~overlays,arctic_coastlines",geographic:"baselayers,MODIS_Terra_CorrectedReflectance_TrueColor~overlays,sedac_bound"},categories:["Base Layers","Overlays"],callback:showSelector,selector:selector});var s = new SOTE.widget.Selector("selectorbox",{dataSourceUrl:"ap_products.php",categories:["Base Layers","Overlays"]});@@ -37,7 +37,7 @@ $(function() {// Initialize "static" vars//var tr = new SOTE.widget.MenuPicker("transition",{dataSourceUrl:"data/mp_transition.php"});var map = new SOTE.widget.DateSpan("time",{hasThumbnail:false});//Image download variables- rb = new SOTE.widget.RubberBand("camera",{icon:"images/camera.png",onicon:"images/cameraon.png",cropee:"map"});+ rb = new SOTE.widget.RubberBand("camera",{icon:"images/camera.png",onicon:"images/cameraon.png",cropee:"map",paletteWidget:palettes});var id = new SOTE.widget.ImageDownload("imagedownload",{baseLayer:"MODIS_Terra_CorrectedReflectance_TrueColor",alignTo: rb, m:m});// Get rid of address bar on iphone/ipod@@ -59,7 +59,7 @@ $(function() {// Initialize "static" varsREGISTRY.addEventListener("products","map","time","selectorbox","imagedownload");REGISTRY.addEventListener("selectorbox","products");REGISTRY.addEventListener("camera","imagedownload");- REGISTRY.addEventListener("palettes", "map");+ REGISTRY.addEventListener("palettes","map","camera");/*REGISTRY.addEventListener("map","time");REGISTRY.addEventListener("time","map");diff --git a/js/rubberBand.js b/js/rubberBand.jsindex 21b12b3a5..ac1f6321c 100644--- a/js/rubberBand.js+++ b/js/rubberBand.js@@ -14,7 +14,11 @@ SOTE.namespace("SOTE.widget.RubberBand");*/-SOTE.widget.RubberBand = function (containerId, config){+SOTE.widget.RubberBand = function (containerId, config){+ this.PALETTE_WARNING =+ "Image download does not support the custom palette that you have " ++ "applied. Would you like to reset the palette back to the default?";+this.container=document.getElementById(containerId);this.coords = null;if (this.container==null){@@ -32,6 +36,8 @@ SOTE.widget.RubberBand = function (containerId, config){this.id = containerId;this.state = "off";this.jcropAPI = null;+ this.paletteWidget = config.paletteWidget;+ this.palettesActive = false;//this.windowURL = "";this.init();@@ -63,11 +69,22 @@ SOTE.widget.RubberBand.prototype.init = function(){SOTE.widget.RubberBand.toggle = function(o){var self = o.data.self;+if(self.state == "off" && self.projectionSwitch == "geographic"){- self.state = "on";- $("#"+self.id+"camera_link img").attr("src",self.onicon);- $("#imagedownload").show('slide', {direction: 'up'}, 1000);- self.draw();+ if (self.palettesActive) {+ Worldview.ask({+ header: "Notice",+ message: self.PALETTE_WARNING,+ onYes: function() {+ self.paletteWidget.setValue("");+ }+ });+ } else {+ self.state = "on";+ $("#"+self.id+"camera_link img").attr("src",self.onicon);+ $("#imagedownload").show('slide', {direction: 'up'}, 1000);+ self.draw();+ }}else if(self.projectionSwitch == "geographic"){self.state = "off";@@ -118,6 +135,11 @@ SOTE.widget.RubberBand.prototype.getValue = function() {*/SOTE.widget.RubberBand.prototype.updateComponent = function(qs){this.projectionSwitch = SOTE.util.extractFromQuery("switch",qs);+ if(SOTE.util.extractFromQuery("palettes",qs)){+ this.palettesActive = true;+ } else {+ this.palettesActive = false;+ }};/**@@ -194,11 +216,11 @@ SOTE.widget.RubberBand.prototype.getStatus = function(){**/SOTE.widget.RubberBand.prototype.draw = function() {-- var self = this;- $("#"+this.cropee).Jcrop({- bgColor: 'black',+ var self = this;++ $("#"+this.cropee).Jcrop({+ bgColor: 'black',bgOpacity: 0.3,onSelect: function(c){SOTE.widget.RubberBand.handleChange(c, self);},onChange: function(c){SOTE.widget.RubberBand.handleChange(c, self);},@@ -208,9 +230,8 @@ SOTE.widget.RubberBand.prototype.draw = function() {this.jcropAPI = $('#'+this.cropee).data('Jcrop');- this.jcropAPI.setSelect([($(window).width()/2)-100,($(window).height()/2)-100,($(window).width()/2)+100,($(window).height()/2)+100]);+ this.jcropAPI.setSelect([($(window).width()/2)-100,($(window).height()/2)-100,($(window).width()/2)+100,($(window).height()/2)+100]);-};diff --git a/js/util.js b/js/util.jsindex 4b4c8a2a2..1f0ee56aa 100644--- a/js/util.js+++ b/js/util.js@@ -172,202 +172,3 @@ SOTE.util.DayNameFromUTCDayInt = function(dayOfWeekInt)}--/**- * Generates an array of OpenLayers layers for the specified product: one for each- * day starting from the current day, working backwards for a total of numDays.- * If the passed-in "product" doesn't match the "displayNameStr", the function- * returns an empty array.- *- *- * @param product the product as specified from the querystring- * @param displayNameStr name shown in OL layer list; mostly for debugging at this point- * @param wmsProductNameStr the product name recognized by the WMS server- * @param formatStr the type of image format expected in return, e.g., "image/jpeg"- * @param urlsArr an array containing a set of URLs to the WMS; multiple array entries can be provided to allow more parallel access to WMS server- * @param tileSizeArr a 2-entry integer array containing the tile dimensions in pixels- * @param projectionStr string containing the projection, e.g., "EPSG:4326"- * @param numZoomLevelsInt number of zoom levels contained in the data- * @param maxExtentArr a 4-entry array containing the max extent of the layer- * @param maxResolutionFloat max resolution of the data (degrees/pixel)- * @param preferredOpacity preferred opacity for this layer [0.0, 1.0]- * @param numDays number of days to generate; i.e., a value of 3 would generate today, yesterday, and two days ago- * @param screenResolutionsArr an array of screen resolutions that this layer should support- * @param serverResolutionsArr an array of resolutions that are available for this layer on the server- *- * @returns if querystring product matches displayNameStr, returns an array whose elements contain a single day of the specified product- *- */-SOTE.util.generateProductLayersForDateRange = function(product, displayNameStr, wmsProductNameStr, formatStr, urlsArr, tileSizeArr, projectionStr, numZoomLevelsInt, maxExtentArr, maxResolutionFloat, preferredOpacityFloat, numDays, screenResolutionsArr, serverResolutionsArr)-{- // Check if these layers should be generated- if (product != displayNameStr)- return [];-- // Get current date- var curDate = new Date();-- // Generate layer for each day- var returnArr = new Array(numDays);- for (var i=0; i<numDays; i++)- {- // Generate YYYY-MM-DD string- var dateStr = curDate.getUTCFullYear() + "-" + SOTE.util.zeroPad(eval(curDate.getUTCMonth()+1),2) + "-" +- SOTE.util.zeroPad(curDate.getUTCDate(),2);-- // Generate layer entry- returnArr[i] = {displayName: (displayNameStr + "__" + dateStr), wmsProductName: wmsProductNameStr,- time: dateStr, format: formatStr, urls: urlsArr, tileSize: tileSizeArr, projection: projectionStr,- numZoomLevels: numZoomLevelsInt, maxExtent: maxExtentArr, maxResolution: maxResolutionFloat,- resolutions: screenResolutionsArr, serverResolutions: serverResolutionsArr,- preferredOpacity: preferredOpacityFloat };-- // Compute next date value by subtracting one day (in ms) from currently stored value- curDate = new Date(curDate - (1000*60*60*24));- }--- return returnArr;-};---/**- * Adds WMTS TileMatrixSet to returned array- */-SOTE.util.generateProductLayersForDateRangeTMS = function(product, displayNameStr, wmsProductNameStr, formatStr, urlsArr, tileSizeArr, projectionStr, numZoomLevelsInt, maxExtentArr, maxResolutionFloat, preferredOpacityFloat, numDays, screenResolutionsArr, serverResolutionsArr, tileMatrixSetStr)-{- // Check if these layers should be generated- if (product != displayNameStr)- return [];-- // Get current date- var curDate = new Date();-- // Generate layer for each day- var returnArr = new Array(numDays);- for (var i=0; i<numDays; i++)- {- // Generate YYYY-MM-DD string- var dateStr = curDate.getUTCFullYear() + "-" + SOTE.util.zeroPad(eval(curDate.getUTCMonth()+1),2) + "-" +- SOTE.util.zeroPad(curDate.getUTCDate(),2);-- // Generate layer entry- returnArr[i] = {displayName: (displayNameStr + "__" + dateStr), wmsProductName: wmsProductNameStr,- time: dateStr, format: formatStr, urls: urlsArr, tileSize: tileSizeArr, projection: projectionStr,- numZoomLevels: numZoomLevelsInt, maxExtent: maxExtentArr, maxResolution: maxResolutionFloat,- resolutions: screenResolutionsArr, serverResolutions: serverResolutionsArr,- tileMatrixSet: tileMatrixSetStr, preferredOpacity: preferredOpacityFloat };-- // Compute next date value by subtracting one day (in ms) from currently stored value- curDate = new Date(curDate - (1000*60*60*24));- }--- return returnArr;-};----/**- * Generates an array of OpenLayers layers for the specified product: one for each- * day starting from the current day, working backwards for a total of numDays.- *- * "NoOversample" means that if the server doesn't contain imagery for the- * requested zoom level, no imagery will be displayed- *- *- * @param displayNameStr name shown in OL layer list; mostly for debugging at this point- * @param wmsProductNameStr the product name recognized by the WMS server- * @param formatStr the type of image format expected in return, e.g., "image/jpeg"- * @param urlsArr an array containing a set of URLs to the WMS; multiple array entries can be provided to allow more parallel access to WMS server- * @param tileSizeArr a 2-entry integer array containing the tile dimensions in pixels- * @param projectionStr string containing the projection, e.g., "EPSG:4326"- * @param numZoomLevelsInt number of zoom levels contained in the data- * @param maxExtentArr a 4-entry array containing the max extent of the layer- * @param maxResolutionFloat max resolution of the data (degrees/pixel)- * @param preferredOpacity preferred opacity for this layer [0.0, 1.0]- * @param numDays number of days to generate; i.e., a value of 3 would generate today, yesterday, and two days ago- *- * @returns an array whose elements contain a single day of the specified product- *- */-SOTE.util.generateProductLayersForDateRangeNoOversample = function(displayNameStr, wmsProductNameStr, formatStr, urlsArr, tileSizeArr, projectionStr, numZoomLevelsInt, maxExtentArr, maxResolutionFloat, preferredOpacityFloat, numDays)-{-- // Get current date- var curDate = new Date();-- // Generate layer for each day- var returnArr = new Array(numDays);- for (var i=0; i<numDays; i++)- {- // Generate YYYY-MM-DD string- var dateStr = curDate.getUTCFullYear() + "-" + SOTE.util.zeroPad(eval(curDate.getUTCMonth()+1),2) + "-" +- SOTE.util.zeroPad(curDate.getUTCDate(),2);-- // Generate layer entry- returnArr[i] = {displayName: (displayNameStr + "__" + dateStr), wmsProductName: wmsProductNameStr,- time: dateStr, format: formatStr, urls: urlsArr, tileSize: tileSizeArr, projection: projectionStr,- numZoomLevels: numZoomLevelsInt, maxExtent: maxExtentArr, maxResolution: maxResolutionFloat,- preferredOpacity: preferredOpacityFloat };-- // Compute next date value by subtracting one day (in ms) from currently stored value- curDate = new Date(curDate - (1000*60*60*24));- }--- return returnArr;-}---/**- * Generates an array of OpenLayers layers for the specified product: one for each- * day starting from the current day, working backwards for a total of numDays.- * If the passed-in "product" doesn't match the "displayNameStr", the function- * returns an empty array.- *- * This version of the function is for full (i.e., non-tiled) WMS layers- *- * @param product the product as specified from the querystring- * @param displayNameStr name shown in OL layer list; mostly for debugging at this point- * @param wmsProductNameStr the product name recognized by the WMS server- * @param formatStr the type of image format expected in return, e.g., "image/jpeg"- * @param urlsArr an array containing a set of URLs to the WMS; multiple array entries can be provided to allow more parallel access to WMS server- * @param projectionStr string containing the projection, e.g., "EPSG:4326"- * @param preferredOpacity preferred opacity for this layer [0.0, 1.0]- * @param singleTile boolean if WMS single tile flag should be set- * @param numDays number of days to generate; i.e., a value of 3 would generate today, yesterday, and two days ago- *- * @returns an array whose elements contain a single day of the specified product- *- */-SOTE.util.generateWmsProductLayersForDateRange = function(product, displayNameStr, wmsProductNameStr, formatStr, urlsArr, projectionStr, preferredOpacityFloat, isSingleTile, numDays)-{- // Check if these layers should be generated- if (product != displayNameStr)- return [];--- // Get current date- var curDate = new Date();-- // Generate layer for each day- var returnArr = new Array(numDays);- for (var i=0; i<numDays; i++)- {- // Generate YYYY-MM-DD string- var dateStr = curDate.getUTCFullYear() + "-" + SOTE.util.zeroPad(eval(curDate.getUTCMonth()+1),2) + "-" +- SOTE.util.zeroPad(curDate.getUTCDate(),2);-- // Generate layer entry- returnArr[i] = {displayName: (displayNameStr + "__" + dateStr), wmsProductName: wmsProductNameStr,- time: dateStr, format: formatStr, urls: urlsArr, projection: projectionStr,- preferredOpacity: preferredOpacityFloat, singleTile: isSingleTile };-- // Compute next date value by subtracting one day (in ms) from currently stored value- curDate = new Date(curDate - (1000*60*60*24));- }--- return returnArr;-}