Interactive interface for browsing global, full-resolution satellite imagery
Fix image-download for subdaily. Add `toJulianDate` util + unit tests
ZachTRicec4d029cee29b
diff --git a/test/util/util-spec.js b/test/util/util-spec.jsindex f0685a12e..a6fec9485 100644--- a/test/util/util-spec.js+++ b/test/util/util-spec.js@@ -79,6 +79,11 @@ buster.testCase('wv.util', (function () {});};+ self['toJulianDate: Converts date'] = function () {+ var d = new Date(Date.UTC(2013, 0, 15));+ buster.assert.equals(wv.util.toJulianDate(d), '2013015');+ };+self['toISOStringDate: Converts date'] = function () {var d = new Date(Date.UTC(2013, 0, 15));buster.assert.equals(wv.util.toISOStringDate(d), '2013-01-15');diff --git a/web/js/image/panel.js b/web/js/image/panel.jsindex d052605d4..29a7f37a8 100644--- a/web/js/image/panel.js+++ b/web/js/image/panel.js@@ -376,18 +376,12 @@ export function imagePanel (models, ui, config, dialogConfig) {};var createDownloadURL = function(time, lonlats, epsg, products, opacities, dlURL) {- var layers, jStart, jDate;- var dTime = time;-+ var layers;layers = getLayers(products, models.proj.selected.id);- // Julian date, padded with two zeros (to ensure the julian date is always in DDD format).- jStart = util.parseDateUTC(dTime.getUTCFullYear() + '-01-01');- jDate = '00' + (1 + Math.ceil((dTime.getTime() - jStart) / 86400000));- dlURL += 'TIME=' + dTime.getUTCFullYear() + (jDate)- .substr((jDate.length) - 3);++ dlURL += 'TIME=' + util.toISOStringSeconds(time);dlURL += '&extent=' + lonlats[0][0] + ',' + lonlats[0][1] + ',' + lonlats[1][0] + ',' + lonlats[1][1];- // dlURL += "&switch="+s;dlURL += '&epsg=' + epsg;dlURL += '&layers=' + layers.join(',');dlURL += '&opacities=' + opacities.join(',');diff --git a/web/js/util/util.js b/web/js/util/util.jsindex 569ad81b2..a73cff0a0 100644--- a/web/js/util/util.js+++ b/web/js/util/util.js@@ -222,6 +222,21 @@ export default (function (self) {var metrics = context.measureText(text);return metrics.width;};++ /**+ * Julian date, padded with two zeros+ * (to ensure the julian date is always in DDD format).+ *+ * @param {Date} date {Date} the date to convert+ * @return {string} Julian date string in the form of `YYYYDDD`+ */+ self.toJulianDate = function (date) {+ var jStart, jDate;+ jStart = self.parseDateUTC(date.getUTCFullYear() + '-01-01');+ jDate = '00' + (1 + Math.ceil((date.getTime() - jStart) / 86400000));+ return date.getUTCFullYear() + (jDate).substr((jDate.length) - 3);+ };+/*** Converts a date into an ISO string with only the date portion.*@@ -240,7 +255,7 @@ export default (function (self) {** @method toISOStringSeconds* @static- * @param date {Date} the date to convert+ * @param {Date} date the date to convert* @return {string} ISO string in the form of `YYYY-MM-DDThh:mm:ssZ`.*/self.toISOStringSeconds = function (date) {