Interactive interface for browsing global, full-resolution satellite imagery
Cleanup of code after self-review. Also moved application start to main.js so test code can be run cleanly without including that file
Mike McGann203c3efa8f52
diff --git a/ant/js.build.xml b/ant/js.build.xmlindex d33df1ffd..939ce3312 100644--- a/ant/js.build.xml+++ b/ant/js.build.xml@@ -24,6 +24,7 @@<file name="switch.js"/><file name="selector.js"/><file name="sote.js"/>+ <file name="main.js"/></filelist></project>\ No newline at end of filediff --git a/index.html b/index.htmlindex dec602642..b15e41d0d 100644--- a/index.html+++ b/index.html@@ -74,6 +74,7 @@<!-- js.dev --> <script type="text/javascript" src="js/switch.js?v=0.3.0"></script><!-- js.dev --> <script type="text/javascript" src="js/selector.js?v=0.3.0"></script><!-- js.dev --> <script type="text/javascript" src="js/sote.js?v=0.3.0"></script>+ <!-- js.dev --> <script type="text/javascript" src="js/main.js?v=0.3.0"></script></head><body class="yui-skin-sam">diff --git a/js/Worldview/Visual.js b/js/Worldview/Visual.jsindex 1d1b2c8c1..e60a727fd 100644--- a/js/Worldview/Visual.js+++ b/js/Worldview/Visual.js@@ -69,7 +69,7 @@ $(function() {var currentStop = 0;var min = palette.min || 0;- var max = palette.max || 1;+ var max = ( palette.max === undefined ) ? 1 : palette.max;for ( var bin = 0; bin < bins; bin++ ) {// Percentange this bin is located at along the range.diff --git a/js/Worldview/Visual/ColorBar.js b/js/Worldview/Visual/ColorBar.jsindex 993996736..5209fedff 100644--- a/js/Worldview/Visual/ColorBar.js+++ b/js/Worldview/Visual/ColorBar.js@@ -76,7 +76,7 @@ Worldview.Visual.ColorBar = function(spec) {* The <Palette> or <Lookup> to render in the canvas. If not specified, this* value is null and no palette will be rendered.*/- self.palette = spec.palette;+ self.palette = spec.palette || null;/*** Constructor: ColorBardiff --git a/js/Worldview/Visual/Lookup.js b/js/Worldview/Visual/Lookup.jsindex 3a8cb6367..06d2c7e6c 100644--- a/js/Worldview/Visual/Lookup.js+++ b/js/Worldview/Visual/Lookup.js@@ -40,14 +40,14 @@ Worldview.Visual.Lookup = function(spec) {** Identifier for this lookup (optional).*/- id: spec.id || undefined,+ id: spec.id || null,/*** Property: name** Descriptive name for this lookup (optional).*/- name: spec.name || undefined,+ name: spec.name || null,/*** Property: tablediff --git a/js/Worldview/Visual/Palette.js b/js/Worldview/Visual/Palette.jsindex 53368ac1b..d573e02dd 100644--- a/js/Worldview/Visual/Palette.js+++ b/js/Worldview/Visual/Palette.js@@ -60,27 +60,27 @@ Worldview.Visual.Palette = function(spec) {* Property: id* Identifier for this palette.*/- id: spec.id || undefined,+ id: spec.id || null,/*** Property: name* Name for this palette.*/- name: spec.name || undefined,+ name: spec.name || null,/*** Property: min* Minimum display value. Values below this percentage will be* transparent. Valid range is [0.0, 1.0].*/- min: spec.min || undefined,+ min: spec.min || 0.0,/*** Property: max* Maximum display value. Values above this percentage will be* transparent. Valid range is [0.0, 1.0].*/- max: spec.max || 1.0,+ max: ( spec.max === undefined ) ? 1.0 : spec.max,/*** Property: typediff --git a/js/main.js b/js/main.jsnew file mode 100644index 000000000..7f1a0b7ea--- /dev/null+++ b/js/main.js@@ -0,0 +1,40 @@+$(function(){// Initialize "static" vars++ // Test for IE and show warning, if necessary+ if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))+ {+ var ieWarningOverlay = new YAHOO.widget.Panel("iewarning", { zIndex:1020, visible:false, underlay:"matte" } );+ var msg = "<div>" ++ "<h4>Internet Explorer is not currently supported</h4>"++ "<br /><p>Worldview uses a set of browser technologies that are not currently supported by Internet Explorer. " ++ "We are awaiting the release of IE version 10 and are hopeful that it will load Worldview properly. " ++ "In the meantime, please try loading this page in Mozilla Firefox, Google Chrome, Apple Safari, or a tablet device. " ++ "<br /><br />Thanks for your patience.</p>" ++ "<br /><p>-The Worldview development team";++ ieWarningOverlay.setBody(msg);+ ieWarningOverlay.render(document.body);+ ieWarningOverlay.show();+ ieWarningOverlay.center();+ }++ this.selector = new YAHOO.widget.Panel("selector", { zIndex:1019, visible:false } );+ this.selector.setBody("<div id='selectorbox'></div>");+ this.selector.render(document.body);+ var sel_id = this.selector.id;+ this.selector.beforeHideEvent.subscribe(function(e){ $("#"+sel_id).css("display","none");})+ this.selector.beforeShowEvent.subscribe(function(e){$("#"+sel_id).css("display","block");})++ // Create map+ var m = new SOTE.widget.MapSote("map",{baseLayer:"MODIS_Terra_CorrectedReflectance_TrueColor"});+ var ss = new SOTE.widget.Switch("switch",{dataSourceUrl:"a",selected:"geographic"});+ var a = new SOTE.widget.Bank("products",{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:this.showSelector,selector:this.selector});+ var s = new SOTE.widget.Selector("selectorbox",{dataSourceUrl:"ap_products.php",categories:["Base Layers","Overlays"]});+ //var h = new SOTE.widget.MenuPicker("hazard",{dataSourceUrl:"data/mp_hazard.php"});+ //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"});+ var id = new SOTE.widget.ImageDownload("imagedownload",{baseLayer:"MODIS_Terra_CorrectedReflectance_TrueColor",alignTo: rb, m:m});++});diff --git a/js/sote.js b/js/sote.jsindex 1b9bcc1ac..6397a0153 100644--- a/js/sote.js+++ b/js/sote.js@@ -1,45 +1,4 @@var rb;-window.onload = function(){// Initialize "static" vars-- // Test for IE and show warning, if necessary- if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))- {- var ieWarningOverlay = new YAHOO.widget.Panel("iewarning", { zIndex:1020, visible:false, underlay:"matte" } );- var msg = "<div>" +- "<h4>Internet Explorer is not currently supported</h4>"+- "<br /><p>Worldview uses a set of browser technologies that are not currently supported by Internet Explorer. " +- "We are awaiting the release of IE version 10 and are hopeful that it will load Worldview properly. " +- "In the meantime, please try loading this page in Mozilla Firefox, Google Chrome, Apple Safari, or a tablet device. " +- "<br /><br />Thanks for your patience.</p>" +- "<br /><p>-The Worldview development team";-- ieWarningOverlay.setBody(msg);- ieWarningOverlay.render(document.body);- ieWarningOverlay.show();- ieWarningOverlay.center();- }-- this.selector = new YAHOO.widget.Panel("selector", { zIndex:1019, visible:false } );- this.selector.setBody("<div id='selectorbox'></div>");- this.selector.render(document.body);- var sel_id = this.selector.id;- this.selector.beforeHideEvent.subscribe(function(e){ $("#"+sel_id).css("display","none");})- this.selector.beforeShowEvent.subscribe(function(e){$("#"+sel_id).css("display","block");})-- // Create map- var m = new SOTE.widget.MapSote("map",{baseLayer:"MODIS_Terra_CorrectedReflectance_TrueColor"});- var ss = new SOTE.widget.Switch("switch",{dataSourceUrl:"a",selected:"geographic"});- var a = new SOTE.widget.Bank("products",{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:this.showSelector,selector:this.selector});- var s = new SOTE.widget.Selector("selectorbox",{dataSourceUrl:"ap_products.php",categories:["Base Layers","Overlays"]});- //var h = new SOTE.widget.MenuPicker("hazard",{dataSourceUrl:"data/mp_hazard.php"});- //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"});- var id = new SOTE.widget.ImageDownload("imagedownload",{baseLayer:"MODIS_Terra_CorrectedReflectance_TrueColor",alignTo: rb, m:m});---};function showSelector(e){var selector = e.data.selector;diff --git a/test/Worldview/Visual/testColorBar.js b/test/Worldview/Visual/testColorBar.jsindex 12cec9e1d..e5a8d9b82 100644--- a/test/Worldview/Visual/testColorBar.js+++ b/test/Worldview/Visual/testColorBar.js@@ -10,14 +10,20 @@*/TestCase("Visual.ColorBar", {+ // This namespacens: null,+ // Dimensions of the canvaswidth: null,height: null,+ // Actual canvas objectcanvas: null,+ // Graphics context for drawing on the canvasg: null,++ // Background pattern of solid redpattern: null,setUp: function() {@@ -53,6 +59,7 @@ TestCase("Visual.ColorBar", {pattern = g.createPattern(background, "repeat");},+ // Is only the background drawn if no palette is specified?testEmpty: function() {var colorBar = ns.ColorBar({selector: "#test-colorBar",@@ -101,15 +108,16 @@ TestCase("Visual.ColorBar", {bins: 10,background: pattern,palette: {+ interpolate: "rgb",stops: [{ at: 0.0, r: 0x00, g: 0x00, b: 0x00 },- { at: 1.0, r: 0xff, g: 0xff, b: 0xff }+ { at: 1.0, r: 0x00, g: 0xff, b: 0xff }]}});var pixels = g.getImageData(0, 0, width, height).data;for ( var i = 0; i < pixels.length; i += 4 ) {- assertNotEquals(0xff, pixels[0]);+ assertEquals(0x00, pixels[i]);}},