Interactive interface for browsing global, full-resolution satellite imagery
Merge branch 'download_poles'
Shriram Ilavajhala654cc95a902f
diff --cc js/imageDownload.jsindex 667793309,a4d26a920..2e40fc2d9--- a/js/imageDownload.js+++ b/js/imageDownload.js@@@ -136,34 -123,50 +123,45 @@@ SOTE.widget.ImageDownload.prototype.updvar pixels = SOTE.util.extractFromQuery('camera', qs);var s = SOTE.util.extractFromQuery('switch',qs);var products = SOTE.util.extractFromQuery('products',qs);----- var px = pixels.split(",");- var x1 = px[0]; var y1= px[1]; var x2 = px[2]; var y2=px[3];-- var lonlat1 = this.m.productMap.map.getLonLatFromViewPortPx(new OpenLayers.Pixel(x1, y2));- var lonlat2 = this.m.productMap.map.getLonLatFromViewPortPx(new OpenLayers.Pixel(x2, y1));-- var dlURL = "http://map2.vis.earthdata.nasa.gov/imagegen/?";-++ var px = pixels.split(",");+ var x1 = px[0]; var y1= px[1]; var x2 = px[2]; var y2=px[3];+ var lonlat1 = this.m.productMap.map.getLonLatFromViewPortPx(new OpenLayers.Pixel(Math.floor(x1), Math.floor(y2)));+ var lonlat2 = this.m.productMap.map.getLonLatFromViewPortPx(new OpenLayers.Pixel(Math.floor(x2), Math.floor(y1)));++ var dlURL = "http://map2.vis.earthdata.nasa.gov/imagegen/index2.php?";- //var dTime = new Date((time.split(/T/))[0]+"T00:00:00");+ var conversionFactor = 256;+ if (s=="geographic") {+ if( !(0 != $('#selImgFormat option[value=KMZ]').length)) {+ $('#selImgFormat').append( $('<option></option>').val("KMZ").text("KMZ"));+ }+ conversionFactor = 0.002197;+ }+ else { //polar+ if( 0 != $('#selImgFormat option[value=KMZ]').length) {+ $('#selImgFormat option[value=KMZ]').remove();+ }+ }- //var dTime = new Date((time.split(/T/))[0]+"T00:00:00");- var dTime = SOTE.util.UTCDateFromISO8601String(time);- dTime.setHours(0);- dTime.setMinutes(0);- dTime.setSeconds(0);-+ var dTime = Date.parseISOString(time).clearUTCTime();-//Julian date, padded with two zeros (to ensure the julian date is always in DDD format).- var jDate = "00" + (1+Math.ceil((dTime - new Date(dTime.getFullYear(),0,1)) / 86400000));- dlURL += "TIME="+dTime.getFullYear()+(jDate).substr((jDate.length)-3);+ var jDate = "00" + (1+Math.ceil((dTime - new Date(dTime.getUTCFullYear(),0,1)) / 86400000));+ dlURL += "TIME="+dTime.getUTCFullYear()+(jDate).substr((jDate.length)-3);++- dlURL += "&extent="+lonlat1.lon+","+lonlat1.lat+","+lonlat2.lon+","+lonlat2.lat;+ dlURL += "&extent="+lonlat1.lon+","+lonlat1.lat+","+lonlat2.lon+","+lonlat2.lat;++ dlURL += "&switch="+s;- dlURL +="&layers=";+ dlURL +="&layers=";//Reverse the order of overlays to get the correct layer ordering.- if (products != ""){+ if (products != ""){var a = products.split("~");- var base = a[0].split(/[\.,]/);+ var base = a[0].split(",");- var overlays = a[1].split(",");- overlays.reverse(); overlays.pop();+++ var overlays = a[1].split(/[\.,]/);- overlays.reverse(); overlays.pop();++ overlays.reverse(); overlays.pop();for(var i=1; i<base.length; ++i){dlURL += base[i]+",";}@@@ -176,13 -179,14 +174,15 @@@}-- var imgWidth=0; var imgHeight=0;+++ var imgWidth=0; var imgHeight=0;++- $("select#selImgResolution").change(function () {+ $("select#selImgResolution").change(function () {imgRes = $("#selImgResolution option:selected").val();- imgWidth = Math.round((Math.abs(lonlat2.lon - lonlat1.lon) / 0.002197) / Number(imgRes));- imgHeight = Math.round((Math.abs(lonlat2.lat - lonlat1.lat) / 0.002197) / Number(imgRes));- imgFilesize = ((imgWidth * imgHeight * 24) / 8388608).toFixed(2);+ imgWidth = Math.round((Math.abs(lonlat2.lon - lonlat1.lon) / conversionFactor) / Number(imgRes));+ imgHeight = Math.round((Math.abs(lonlat2.lat - lonlat1.lat) / conversionFactor) / Number(imgRes));+ imgFilesize = (( imgWidth * imgHeight * 24) / 8388608).toFixed(2);$("#imgWidth").text((imgWidth));$("#imgHeight").text((imgHeight));diff --cc js/rubberBand.jsindex 1bb268dec,aa32db70a..fe4181951--- a/js/rubberBand.js+++ b/js/rubberBand.js@@@ -71,56 -63,21 +71,55 @@@ SOTE.widget.RubberBand.prototype.initSOTE.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();+ var toggleOn = function() {+ self.state = "on";+ $("#"+self.id+"camera_link img").attr("src",self.onicon);+ $("#imagedownload").show('slide', {direction: 'up'}, 1000);+ self.draw();+ };++ // When disabling the palettes, we need to wait for the map to reload all+ // the tiles before enabling the crop box. The crop box copies all+ // elements in the map to do its background effect and if the map isn't+ // ready yet, it will copy blank images.+ var disablePalettes = function() {+ var map = self.mapWidget.productMap.map;+ var handler = function() {+ map.events.unregister("maploadend", map, handler);+ toggleOn();+ };+ map.events.register("maploadend", map, handler);++ // Save the previous state to be restored later+ self.previousPalettes = self.currentPalettes;+ self.paletteWidget.setValue("");+ };+- if(self.state == "off" && self.projectionSwitch == "geographic"){++ if(self.state == "off") { // && self.projectionSwitch == "geographic"){+ // Confirm with the user they want to continue, and if so, disable+ // the palettes before bringing up the crop box.+ if (self.currentPalettes) {+ Worldview.ask({+ header: "Notice",+ message: self.PALETTE_WARNING,+ onOk: disablePalettes+ });+ } else {+ toggleOn();+ }}- else if(self.projectionSwitch == "geographic"){+ else { //}(self.projectionSwitch == "geographic"){self.state = "off";$("#"+self.id+"camera_link img").attr("src",self.icon);self.jcropAPI.destroy();$("#imagedownload").hide('slide', {direction: 'up'}, 1000);+ if (self.previousPalettes) {+ self.paletteWidget.setValue(self.previousPalettes);+ }}- else {+ /*else {SOTE.util.throwError("The download feature is currently available for geographic projection only.");- }+ }*/}/**@@@ -252,8 -208,9 +251,8 @@@ SOTE.widget.RubberBand.prototype.drawthis.jcropAPI = $('#'+this.cropee).data('Jcrop');- this.jcropAPI.setSelect([($(window).width()/2)-100,($(window).height()/2)-100,($(window).width()/2)+100,($(window).height()/2)+100]);-- alert();+ this.jcropAPI.setSelect([($(window).width()/2)-100,($(window).height()/2)-100,($(window).width()/2)+100,($(window).height()/2)+100]);-++};