Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Load page in right location based on now #1799

Benjamin Kingcc9d2bc0192b
diff --git a/web/js/map/model.js b/web/js/map/model.js
index a08d2a260..8ad1528b2 100644
--- a/web/js/map/model.js
+++ b/web/js/map/model.js
@@ -118,40 +118,6 @@ export function mapModel(models, config) {
} // convert from radians to degrees
};
- /*
- * Set default extent according to time of day:
- *
- * at 00:00 UTC, start at far eastern edge of
- * map: "20.6015625,-46.546875,179.9296875,53.015625"
- *
- * at 23:00 UTC, start at far western edge of map:
- * "-179.9296875,-46.546875,-20.6015625,53.015625"
- *
- * @method getLeadingExtent
- * @static
- *
- *
- * @returns {object} Extent Array
- */
- self.getLeadingExtent = function() {
- var curHour = util.now().getUTCHours();
-
- // For earlier hours when data is still being filled in, force a far eastern perspective
- if (curHour < 3) {
- curHour = 23;
- } else if (curHour < 9) {
- curHour = 0;
- }
-
- // Compute east/west bounds
- var minLon = 20.6015625 + curHour * (-200.53125 / 23.0);
- var maxLon = minLon + 159.328125;
-
- var minLat = -46.546875;
- var maxLat = 53.015625;
-
- return [minLon, minLat, maxLon, maxLat];
- };
init();
return self;
}
diff --git a/web/js/map/ui.js b/web/js/map/ui.js
index 474bce356..4187f83c9 100644
--- a/web/js/map/ui.js
+++ b/web/js/map/ui.js
@@ -49,6 +49,7 @@ import {
find as lodashFind
} from 'lodash';
import { CLEAR_ROTATE } from '../modules/map/constants';
+import { getLeadingExtent } from '../modules/map/util';
export function mapui(models, config, store, ui) {
var layerBuilder, createLayer;
@@ -211,7 +212,7 @@ export function mapui(models, config, store, ui) {
if (models.map.extent) {
extent = models.map.extent;
} else if (!models.map.extent && projId === 'geographic') {
- extent = models.map.getLeadingExtent();
+ extent = getLeadingExtent(config.pageLoadTime);
}
if (extent) {
map.getView().fit(extent, {
diff --git a/web/js/modules/map/util.js b/web/js/modules/map/util.js
index 10943e2c4..d4548cc40 100644
--- a/web/js/modules/map/util.js
+++ b/web/js/modules/map/util.js
@@ -1,4 +1,3 @@
-import util from '../../util/util';
import { encode } from '../link/util';
import * as olExtent from 'ol/extent';
import {
@@ -16,7 +15,7 @@ export function getMapParameterSetup(
errors
) {
models.map.load(legacyState, errors);
- const leadingExtent = getLeadingExtent();
+ const leadingExtent = getLeadingExtent(config.pageLoadTime);
return {
v: {
stateKey: 'map.extent',
@@ -91,8 +90,23 @@ export function mapIsExtentValid(extent) {
});
return valid;
}
-export function getLeadingExtent() {
- var curHour = util.now().getUTCHours();
+/*
+ * Set default extent according to time of day:
+ *
+ * at 00:00 UTC, start at far eastern edge of
+ * map: "20.6015625,-46.546875,179.9296875,53.015625"
+ *
+ * at 23:00 UTC, start at far western edge of map:
+ * "-179.9296875,-46.546875,-20.6015625,53.015625"
+ *
+ * @method getLeadingExtent
+ * @static
+ * @param {Object} Time
+ *
+ * @returns {object} Extent Array
+ */
+export function getLeadingExtent(loadtime) {
+ var curHour = loadtime.getUTCHours();
// For earlier hours when data is still being filled in, force a far eastern perspective
if (curHour < 3) {