Interactive interface for browsing global, full-resolution satellite imagery
Started work on new projection change
Mike McGann7900492e9b66
diff --git a/src/js/Worldview.js b/src/js/Worldview.jsindex faacb5d11..0cf7417b8 100644--- a/src/js/Worldview.js+++ b/src/js/Worldview.js@@ -7,15 +7,6 @@*/(function(ns) {- /**- * Delay, in hours, from aquisition until data is available in GIBS.- *- * @property GIBS_HOUR_DELAY {integer}- * @final- * @static- */- ns.GIBS_HOUR_DELAY = 3;-// June 6, 2013ns.ARCTIC_PROJECTION_CHANGE_DATE = new Date(Date.UTC(2013, 05, 06));diff --git a/src/js/Worldview/Widget/WorldviewMap.js b/src/js/Worldview/Widget/WorldviewMap.jsindex ef0b4d615..2a782cabe 100644--- a/src/js/Worldview/Widget/WorldviewMap.js+++ b/src/js/Worldview/Widget/WorldviewMap.js@@ -191,7 +191,7 @@ Worldview.Widget.WorldviewMap = function(containerId, config) {var curHour = Worldview.now().getUTCHours();// For earlier hours when data is still being filled in, force a far eastern perspective- if (curHour < Worldview.GIBS_HOUR_DELAY) {+ if (curHour < 3) {curHour = 23;}else if (curHour < 9) {diff --git a/src/js/proj/wv.proj.change.js b/src/js/proj/wv.proj.change.jsnew file mode 100644index 000000000..fb4fdd8a2--- /dev/null+++ b/src/js/proj/wv.proj.change.js@@ -0,0 +1,63 @@+/*+ * NASA Worldview+ *+ * This code was originally developed at NASA/Goddard Space Flight Center for+ * the Earth Science Data and Information System (ESDIS) project.+ *+ * Copyright (C) 2013 - 2014 United States Government as represented by the+ * Administrator of the National Aeronautics and Space Administration.+ * All Rights Reserved.+ */++/**+ * @module wv.proj+ */+var wv = wv || {};+wv.proj = wv.proj || {};++/**+ * @class wv.proj.change+ */+wv.proj.change = wv.proj.change || function(models) {++ var PROJECTION_CHANGE_DATE = new Date(Date.UTC(2013, 05, 06));+ var self = {};++ self.events = wv.util.events();+ self.old = false;+ self.crs = null;+ self.epsg = null;++ var init = function() {+ models.proj.register("EPSG:3995",+ "+title=WGS 84 / Arctic Polar Stereographic +proj=stere " ++ "lat_0=90 +lat_ts=71 +lon_0=0 +k=1 +x_0=0 +y_0=0 " ++ "+datum=WGS84 +units=m +no_def");+ models.proj.events.on("select", update);+ models.date.events.on("select", update);+ update();+ };++ var update = function() {+ var proj = models.proj.selected;+ self.old = false;+ self.crs = proj.crs;+ self.epsg = proj.epsg;+ if ( proj.id === "arctic" || proj.id === "antarctic" ) {+ var day = models.date.selected.getTime();+ var change = PROJECTION_CHANGE_DATE.getTime();+ if ( day < change ) {+ self.old = true;+ if ( proj.id === "arctic" ) {+ self.crs = "EPSG:3995";+ self.epsg = 3995;+ }+ }+ }+ self.events.trigger("selected", self);+ };++ init();+ return self;+};+diff --git a/src/js/proj/wv.proj.model.js b/src/js/proj/wv.proj.model.jsindex e2815fe94..2a706a2f5 100644--- a/src/js/proj/wv.proj.model.js+++ b/src/js/proj/wv.proj.model.js@@ -61,7 +61,7 @@ wv.proj.model = wv.proj.model || function(config) {};self.register = function(crs, def) {- if ( def && Proj4js && !Proj4js.defs[crs] ) {+ if ( def && window.Proj4js && !Proj4js.defs[crs] ) {Proj4js.defs[crs] = def;}};diff --git a/test/proj/wv.proj.change-test.js b/test/proj/wv.proj.change-test.jsnew file mode 100644index 000000000..40b21e662--- /dev/null+++ b/test/proj/wv.proj.change-test.js@@ -0,0 +1,98 @@+/*+ * NASA Worldview+ *+ * This code was originally developed at NASA/Goddard Space Flight Center for+ * the Earth Science Data and Information System (ESDIS) project.+ *+ * Copyright (C) 2013 - 2014 United States Government as represented by the+ * Administrator of the National Aeronautics and Space Administration.+ * All Rights Reserved.+ */++buster.testCase("wv.proj.change", {++ config: null,+ models: null,++ setUp: function() {+ this.config = {+ defaults: {+ projection: "geographic",+ },+ projections: {+ geographic: {+ id: "geographic",+ epsg: "4326",+ crs: "EPSG:4326"+ },+ arctic: {+ id: "arctic",+ epsg: "3413",+ crs: "EPSG:3413",+ proj4: "Proj4 def"+ },+ antarctic: {+ id: "antarctic",+ epsg: "3031",+ crs: "EPSG:3031"+ }+ }+ };+ this.models = {+ date: wv.date.model(),+ proj: wv.proj.model(this.config)+ };+ this.models.change = wv.proj.change(this.models);+ },++ "Initializes with new projection": function() {+ buster.refute(this.models.change.old);+ buster.assert.equals(this.models.change.crs, "EPSG:4326");+ },++ "New projection with arctic": function() {+ this.models.date.select(new Date(Date.UTC(2014, 0, 1)));+ this.models.proj.select("arctic");+ buster.refute(this.models.change.old);+ buster.assert.equals(this.models.change.crs, "EPSG:3413");+ },++ "Old projection with arctic via projection change": function() {+ this.models.date.select(new Date(Date.UTC(2013, 0, 1)));+ this.models.proj.select("arctic");+ buster.assert(this.models.change.old);+ buster.assert.equals(this.models.change.crs, "EPSG:3995");+ },++ "Old projection with arctic via date change": function() {+ this.models.proj.select("arctic");+ this.models.date.select(new Date(Date.UTC(2013, 0, 1)));+ buster.assert(this.models.change.old);+ buster.assert.equals(this.models.change.crs, "EPSG:3995");+ },++ "Old projection with antarctic": function() {+ this.models.date.select(new Date(Date.UTC(2013, 0, 1)));+ this.models.proj.select("antarctic");+ buster.assert(this.models.change.old);+ buster.assert.equals(this.models.change.crs, "EPSG:3031");+ },++ "Changes back to new on date change": function() {+ this.models.proj.select("arctic");+ this.models.date.select(new Date(Date.UTC(2013, 0, 1)));+ this.models.date.select(new Date(Date.UTC(2014, 0, 1)));+ buster.refute(this.models.change.old);+ buster.assert.equals(this.models.change.crs, "EPSG:3413");+ },++ "Changes back to new on projection change": function() {+ this.models.date.select(new Date(Date.UTC(2013, 0, 1)));+ this.models.proj.select("arctic");+ this.models.proj.select("geographic");+ buster.refute(this.models.change.old);+ buster.assert.equals(this.models.change.crs, "EPSG:4326");+ }++});+