Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Namespaced lodash functions. Added specific ol imports.

ZachTRicef18051fc2c73
diff --git a/web/js/image/panel.js b/web/js/image/panel.js
index ae51a9cea..794c1c754 100644
--- a/web/js/image/panel.js
+++ b/web/js/image/panel.js
@@ -1,7 +1,7 @@
import $ from 'jquery';
-import each from 'lodash/each';
-import isUndefined from 'lodash/isUndefined';
-import ol from 'openlayers';
+import loEach from 'lodash/each';
+import loIsUndefined from 'lodash/isUndefined';
+import olProj from 'ol/proj';
import {GA as googleAnalytics} from 'worldview-components';
import util from '../util/util';
import wvui from '../ui/ui';
@@ -264,8 +264,8 @@ export function imagePanel(models, ui, config) {
// get layer transparencies (opacities)
var opacities = [];
- each(products, function (product) {
- opacities.push((isUndefined(product.opacity)) ? 1 : product.opacity);
+ loEach(products, function (product) {
+ opacities.push((loIsUndefined(product.opacity)) ? 1 : product.opacity);
});
// console.log("EPSG: " + epsg);
@@ -280,8 +280,8 @@ export function imagePanel(models, ui, config) {
var lonlat1 = map.getCoordinateFromPixel([Math.floor(x1), Math.floor(y2)]);
var lonlat2 = map.getCoordinateFromPixel([Math.floor(x2), Math.floor(y1)]);
- var geolonlat1 = ol.proj.transform(lonlat1, crs, 'EPSG:4326');
- var geolonlat2 = ol.proj.transform(lonlat2, crs, 'EPSG:4326');
+ var geolonlat1 = olProj.transform(lonlat1, crs, 'EPSG:4326');
+ var geolonlat2 = olProj.transform(lonlat2, crs, 'EPSG:4326');
var minLon = geolonlat1[0];
var maxLon = geolonlat2[0];
@@ -329,7 +329,7 @@ export function imagePanel(models, ui, config) {
// dlURL += "&switch="+s;
dlURL += '&epsg=' + epsg;
var layers = [];
- each(products, function (layer) {
+ loEach(products, function (layer) {
if (layer.projections[s].layer) {
layers.push(layer.projections[s].layer);
} else {
diff --git a/web/js/image/rubberband.js b/web/js/image/rubberband.js
index 2f28ff53c..128b97c9e 100644
--- a/web/js/image/rubberband.js
+++ b/web/js/image/rubberband.js
@@ -1,5 +1,5 @@
import $ from 'jquery';
-import find from 'lodash/find';
+import loFind from 'lodash/find';
import util from '../util/util';
import wvui from '../ui/ui';
@@ -117,7 +117,7 @@ export function imageRubberband(models, ui, config) {
renderable: true
});
var on = true;
- if (find(layers, {
+ if (loFind(layers, {
id: 'Graticule'
}) && geographic) {
wvui.ask({
diff --git a/web/js/layers/active.js b/web/js/layers/active.js
index a0f1725d6..1dc22c7db 100644
--- a/web/js/layers/active.js
+++ b/web/js/layers/active.js
@@ -1,6 +1,6 @@
import $ from 'jquery';
-import each from 'lodash/each';
-import eachRight from 'lodash/eachRight';
+import loEach from 'lodash/each';
+import loEachRight from 'lodash/eachRight';
import util from '../util/util';
import wvui from '../ui/ui';
import layersInfo from './info';
@@ -49,7 +49,7 @@ export function layersActive(models, ui, config) {
var $container = $('<div />', {class: 'layer-container bank'});
$(self.selector).empty().append($container);
- eachRight(groups, function (group) {
+ loEachRight(groups, function (group) {
renderGroup($container, group);
});
@@ -90,7 +90,7 @@ export function layersActive(models, ui, config) {
$('.layer-container ul.category')
.bind('sortstop', moveLayer);
- each(model.get({
+ loEach(model.get({
group: 'overlays'
}), function (layer) {
if (layer.palette) {
@@ -113,7 +113,7 @@ export function layersActive(models, ui, config) {
$parent.append($header);
- each(model.get({
+ loEach(model.get({
group: group.id
}), function (layer) {
renderLayer($container, group, layer);
@@ -450,7 +450,7 @@ export function layersActive(models, ui, config) {
};
var onPaletteUpdateAll = function () {
- each(legends, function (legend) {
+ loEach(legends, function (legend) {
legend.update();
});
};
@@ -462,8 +462,8 @@ export function layersActive(models, ui, config) {
setTimeout(render, 1);
};
var onZoomChange = function () {
- each(groups, function (group) {
- each(model.get({
+ loEach(groups, function (group) {
+ loEach(model.get({
group: group.id
}), function (layer) {
var $layer = $('#products li.productsitem[data-layer="' +
@@ -473,8 +473,8 @@ export function layersActive(models, ui, config) {
});
};
var onDateChange = function () {
- each(groups, function (group) {
- each(model.get({
+ loEach(groups, function (group) {
+ loEach(model.get({
group: group.id
}), function (layer) {
var $layer = $('#' + group.id + '-' + encodeURIComponent(layer.id));
diff --git a/web/js/layers/add.js b/web/js/layers/add.js
index cef4f939c..7b31af206 100644
--- a/web/js/layers/add.js
+++ b/web/js/layers/add.js
@@ -1,7 +1,7 @@
import $ from 'jquery';
-import each from 'lodash/each';
-import find from 'lodash/find';
-import throttle from 'lodash/throttle';
+import loEach from 'lodash/each';
+import loFind from 'lodash/find';
+import loThrottle from 'lodash/throttle';
import util from '../util/util';
export function layersAdd(models, ui, config) {
@@ -16,7 +16,7 @@ export function layersAdd(models, ui, config) {
var visible = {};
var init = function () {
- each(config.layers, function (layer) {
+ loEach(config.layers, function (layer) {
visible[layer.id] = true;
});
@@ -127,7 +127,7 @@ export function layersAdd(models, ui, config) {
.addClass('category')
.addClass('scroll-pane');
- each(config.layerOrder, function (layerId) {
+ loEach(config.layerOrder, function (layerId) {
var layer = config.layers[layerId];
if (!layer) {
console.warn('In layer order but not defined', layerId);
@@ -180,7 +180,7 @@ export function layersAdd(models, ui, config) {
if (group === 'baselayers') {
$checkbox.attr('name', group);
}
- if (find(model.active, {
+ if (loFind(model.active, {
id: layer.id
})) {
$checkbox.attr('checked', 'checked');
@@ -319,7 +319,7 @@ export function layersAdd(models, ui, config) {
};
var adjustTitles = function () {
- each(config.layers, function (def) {
+ loEach(config.layers, function (def) {
var names = models.layers.getTitles(def.id);
$('#selectorbox [data-layer=\'' + encodeURIComponent(def.id) +
'\'] .title')
@@ -402,7 +402,7 @@ export function layersAdd(models, ui, config) {
return filtered;
};
- var filter = throttle(function () {
+ var filter = loThrottle(function () {
var search = searchTerms();
$.each(config.layers, function (layerId, layer) {
var fproj = filterProjection(layer);
diff --git a/web/js/layers/layers.js b/web/js/layers/layers.js
index f87c9201b..ab3b2ce3a 100644
--- a/web/js/layers/layers.js
+++ b/web/js/layers/layers.js
@@ -1,13 +1,13 @@
-import cloneDeep from 'lodash/cloneDeep';
-import each from 'lodash/each';
-import remove from 'lodash/remove';
+import loCloneDeep from 'lodash/cloneDeep';
+import loEach from 'lodash/each';
+import loRemove from 'lodash/remove';
// Permalink versions 1.0 and 1.1
var parse11 = function (state, errors, config) {
var str = state.products;
var layers = [];
var ids = str.split(/[~,\.]/);
- each(ids, function (id) {
+ loEach(ids, function (id) {
if (id === 'baselayers' || id === 'overlays') {
return;
}
@@ -47,7 +47,7 @@ var parse12 = function (state, errors, config) {
// Split by layer definitions (commas not in parens)
var layerDefs = str.match(/[^\(,]+(\([^\)]*\))?,?/g);
var lstates = [];
- each(layerDefs, function (layerDef) {
+ loEach(layerDefs, function (layerDef) {
// Get the text before any paren or comma
var layerId = layerDef.match(/[^\(,]+/)[0];
if (config.redirects && config.redirects.layers) {
@@ -64,7 +64,7 @@ var parse12 = function (state, errors, config) {
var strAttr = arrayAttr[0].replace(/[\(\)]/g, '');
// Key value pairs
var kvps = strAttr.split(',');
- each(kvps, function (kvp) {
+ loEach(kvps, function (kvp) {
parts = kvp.split('=');
if (parts.length === 1) {
lstate.attributes.push({
@@ -101,16 +101,16 @@ export function validate(errors, config) {
layerRemoved: true
});
delete config.layers[layerId];
- remove(config.layerOrder.baselayers, function (e) {
+ loRemove(config.layerOrder.baselayers, function (e) {
return e === layerId;
});
- remove(config.layerOrder.overlays, function (e) {
+ loRemove(config.layerOrder.overlays, function (e) {
return e === layerId;
});
};
- var layers = cloneDeep(config.layers);
- each(layers, function (layer) {
+ var layers = loCloneDeep(config.layers);
+ loEach(layers, function (layer) {
if (!layer.group) {
error(layer.id, 'No group defined');
return;
@@ -120,8 +120,8 @@ export function validate(errors, config) {
}
});
- var orders = cloneDeep(config.layerOrder);
- each(orders, function (layerId) {
+ var orders = loCloneDeep(config.layerOrder);
+ loEach(orders, function (layerId) {
if (!config.layers[layerId]) {
error(layerId, 'No configuration');
}
diff --git a/web/js/layers/modal.js b/web/js/layers/modal.js
index d9d2a1cfe..857e2d2c0 100644
--- a/web/js/layers/modal.js
+++ b/web/js/layers/modal.js
@@ -1,8 +1,8 @@
import $ from 'jquery';
-import find from 'lodash/find';
-import indexOf from 'lodash/indexOf';
-import sortBy from 'lodash/sortBy';
-import startCase from 'lodash/startCase';
+import loFind from 'lodash/find';
+import loIndexOf from 'lodash/indexOf';
+import loSortBy from 'lodash/sortBy';
+import loStartCase from 'lodash/startCase';
import util from '../util/util';
export function layersModal(models, ui, config) {
@@ -36,8 +36,8 @@ export function layersModal(models, ui, config) {
if (layer.subtitle) layer.subtitle = decodeHtml(layer.subtitle);
return layer;
});
- return sortBy(filteredLayers, function (layer) {
- return indexOf(config.layerOrder, layer.id);
+ return loSortBy(filteredLayers, function (layer) {
+ return loIndexOf(config.layerOrder, layer.id);
});
};
@@ -541,7 +541,7 @@ export function layersModal(models, ui, config) {
}).on('ifChecked', addLayer)
.on('ifUnchecked', removeLayer);
- if (find(model.active, {id: layer.id})) {
+ if (loFind(model.active, {id: layer.id})) {
$setting.attr('checked', 'checked');
}
@@ -556,7 +556,7 @@ export function layersModal(models, ui, config) {
if (layer.layergroup && layer.layergroup.indexOf('reference_orbits') !== -1) {
var orbitTitle;
if (layer.daynight && layer.track) {
- orbitTitle = startCase(layer.track) + '/' + startCase(layer.daynight);
+ orbitTitle = loStartCase(layer.track) + '/' + loStartCase(layer.daynight);
}
$label.empty()
diff --git a/web/js/layers/model.js b/web/js/layers/model.js
index 4016cee28..2e2b424eb 100644
--- a/web/js/layers/model.js
+++ b/web/js/layers/model.js
@@ -1,9 +1,9 @@
-import each from 'lodash/each';
-import eachRight from 'lodash/eachRight';
-import filter from 'lodash/filter';
-import find from 'lodash/find';
-import findIndex from 'lodash/findIndex';
-import isUndefined from 'lodash/isUndefined';
+import loEach from 'lodash/each';
+import loEachRight from 'lodash/eachRight';
+import loFilter from 'lodash/filter';
+import loFind from 'lodash/find';
+import loFindIndex from 'lodash/findIndex';
+import loIsUndefined from 'lodash/isUndefined';
import util from '../util/util';
export function layersModel(models, config) {
@@ -21,7 +21,7 @@ export function layersModel(models, config) {
self.reset = function () {
self.clear();
if (config.defaults && config.defaults.startingLayers) {
- each(config.defaults.startingLayers, function (start) {
+ loEach(config.defaults.startingLayers, function (start) {
self.add(start.id, start);
});
}
@@ -86,7 +86,7 @@ export function layersModel(models, config) {
// if the layer exists in the active layer list
self.exists = function (layer) {
var found = false;
- each(self.active, function (current) {
+ loEach(self.active, function (current) {
if (layer === current.id) {
found = true;
}
@@ -97,7 +97,7 @@ export function layersModel(models, config) {
self.dateRange = function (spec) {
spec = spec || {};
var projId = spec.projId || models.proj.selected.id;
- var layers = (spec.layer) ? [find(self.active, {
+ var layers = (spec.layer) ? [loFind(self.active, {
id: spec.layer
})]
: self.active;
@@ -113,7 +113,7 @@ export function layersModel(models, config) {
var min = Number.MAX_VALUE;
var max = 0;
var range = false;
- each(layers, function (def) {
+ loEach(layers, function (def) {
if (def.startDate) {
range = true;
var start = util.parseDateUTC(def.startDate)
@@ -153,7 +153,7 @@ export function layersModel(models, config) {
};
self.add = function (id, spec) {
- if (find(self.active, {
+ if (loFind(self.active, {
id: id
})) {
return;
@@ -164,12 +164,12 @@ export function layersModel(models, config) {
throw new Error('No such layer: ' + id);
}
def.visible = true;
- if (!isUndefined(spec.visible)) {
+ if (!loIsUndefined(spec.visible)) {
def.visible = spec.visible;
- } else if (!isUndefined(spec.hidden)) {
+ } else if (!loIsUndefined(spec.hidden)) {
def.visible = !spec.hidden;
}
- def.opacity = (isUndefined(spec.opacity)) ? 1.0 : spec.opacity;
+ def.opacity = (loIsUndefined(spec.opacity)) ? 1.0 : spec.opacity;
if (def.group === 'overlays') {
self.active.unshift(def);
split += 1;
@@ -181,7 +181,7 @@ export function layersModel(models, config) {
};
self.remove = function (id) {
- var index = findIndex(self.active, {
+ var index = loFindIndex(self.active, {
id: id
});
var def = self.active[index];
@@ -196,7 +196,7 @@ export function layersModel(models, config) {
};
self.replace = function (idOld, idNew) {
- var index = findIndex(self.active, {
+ var index = loFindIndex(self.active, {
id: idOld
});
if (index < 0) {
@@ -214,7 +214,7 @@ export function layersModel(models, config) {
self.clear = function (projId) {
projId = projId || models.proj.selected.id;
var defs = self.active.slice(0);
- each(defs, function (def) {
+ loEach(defs, function (def) {
if (projId && def.projections[projId]) {
self.remove(def.id);
}
@@ -222,7 +222,7 @@ export function layersModel(models, config) {
};
self.pushToBottom = function (id) {
- var oldIndex = findIndex(self.active, {
+ var oldIndex = loFindIndex(self.active, {
id: id
});
if (oldIndex < 0) {
@@ -240,7 +240,7 @@ export function layersModel(models, config) {
};
self.moveBefore = function (sourceId, targetId) {
- var sourceIndex = findIndex(self.active, {
+ var sourceIndex = loFindIndex(self.active, {
id: sourceId
});
if (sourceIndex < 0) {
@@ -248,7 +248,7 @@ export function layersModel(models, config) {
}
var sourceDef = self.active[sourceIndex];
- var targetIndex = findIndex(self.active, {
+ var targetIndex = loFindIndex(self.active, {
id: targetId
});
if (targetIndex < 0) {
@@ -265,7 +265,7 @@ export function layersModel(models, config) {
};
self.setVisibility = function (id, visible) {
- var def = find(self.active, {
+ var def = loFind(self.active, {
id: id
});
if (def.visible !== visible) {
@@ -276,7 +276,7 @@ export function layersModel(models, config) {
};
self.setOpacity = function (id, opacity) {
- var def = find(self.active, {
+ var def = loFind(self.active, {
id: id
});
if (def.opacity !== opacity) {
@@ -287,7 +287,7 @@ export function layersModel(models, config) {
};
self.isRenderable = function (id) {
- var def = find(self.active, {
+ var def = loFind(self.active, {
id: id
});
if (!def) {
@@ -303,7 +303,7 @@ export function layersModel(models, config) {
return true;
}
var obscured = false;
- each(self.get({
+ loEach(self.get({
group: 'baselayers'
}), function (otherDef) {
if (otherDef.id === def.id) {
@@ -321,8 +321,8 @@ export function layersModel(models, config) {
self.save = function (state) {
var defs = self.get();
state.l = state.l || [];
- each(self.get(), function (def) {
- var lstate = find(state.l, {
+ loEach(self.get(), function (def) {
+ var lstate = loFind(state.l, {
id: def.id
});
if (!lstate) {
@@ -349,9 +349,9 @@ export function layersModel(models, config) {
};
self.load = function (state, errors) {
- if (!isUndefined(state.l)) {
+ if (!loIsUndefined(state.l)) {
self.clear(models.proj.selected.id);
- eachRight(state.l, function (layerDef) {
+ loEachRight(state.l, function (layerDef) {
if (!config.layers[layerDef.id]) {
errors.push({
message: 'No such layer: ' + layerDef.id
@@ -360,7 +360,7 @@ export function layersModel(models, config) {
}
var hidden = false;
var opacity = 1.0;
- each(layerDef.attributes, function (attr) {
+ loEach(layerDef.attributes, function (attr) {
if (attr.id === 'hidden') {
hidden = true;
}
@@ -381,10 +381,10 @@ export function layersModel(models, config) {
spec = spec || {};
var projId = spec.proj || models.proj.selected.id;
var results = [];
- var defs = filter(self.active, {
+ var defs = loFilter(self.active, {
group: group
});
- each(defs, function (def) {
+ loEach(defs, function (def) {
// Skip if this layer isn't available for the selected projection
if (!def.projections[projId]) {
return;
diff --git a/web/js/layers/options.js b/web/js/layers/options.js
index 00d43c9e2..f98853de1 100644
--- a/web/js/layers/options.js
+++ b/web/js/layers/options.js
@@ -1,9 +1,9 @@
import $ from 'jquery';
-import each from 'lodash/each';
-import indexOf from 'lodash/indexOf';
-import isEqual from 'lodash/isEqual';
-import isUndefined from 'lodash/isUndefined';
-import parseInt from 'lodash/parseInt';
+import loEach from 'lodash/each';
+import loIndexOf from 'lodash/indexOf';
+import loIsEqual from 'lodash/isEqual';
+import loIsUndefined from 'lodash/isUndefined';
+import loParseInt from 'lodash/parseInt';
import util from '../util/util';
import wvui from '../ui/ui';
import palettes from '../palettes/palettes';
@@ -16,7 +16,6 @@ export function layersOptions(config, models, layer) {
var $dropDown;
var self = {};
var canvas;
- var palettes;
var index = 0;
var init = function () {
@@ -174,7 +173,7 @@ export function layersOptions(config, models, layer) {
.addClass('wv-legend-buttons');
var legends = models.palettes.getLegends(layer.id);
- each(legends, function (legend, index) {
+ loEach(legends, function (legend, index) {
id = 'wv-legend-' + index;
$panel.append('<input type=\'radio\' id=\'' + id + '\' ' +
'name=\'legend\' value=\'' + index + '\'>' +
@@ -185,7 +184,7 @@ export function layersOptions(config, models, layer) {
$('.wv-legend-buttons input[type=\'radio\']')
.change(function () {
- index = parseInt($(this)
+ index = loParseInt($(this)
.val());
rerenderRange();
rerenderPaletteSelector();
@@ -272,11 +271,11 @@ export function layersOptions(config, models, layer) {
updateRangeLabels();
var palette = models.palettes.get(layer.id, index);
- var imin = (isUndefined(palette.min)) ? 0 : palette.min;
- var imax = (isUndefined(palette.max))
+ var imin = (loIsUndefined(palette.min)) ? 0 : palette.min;
+ var imax = (loIsUndefined(palette.max))
? palette.legend.tooltips.length - 1 : palette.max;
current = [parseFloat($range.val()[0]), parseFloat($range.val()[1])];
- if (!isEqual(current, [imin, imax])) {
+ if (!loIsEqual(current, [imin, imax])) {
$range.val([imin, imax]);
}
@@ -324,14 +323,14 @@ export function layersOptions(config, models, layer) {
.empty();
$pane.append(defaultLegend());
var recommended = layer.palette.recommended || [];
- each(recommended, function (id) {
+ loEach(recommended, function (id) {
var item = customLegend(id);
if (item) {
$pane.append(item);
}
});
- each(config.paletteOrder, function (id) {
- if (indexOf(recommended, id) < 0) {
+ loEach(config.paletteOrder, function (id) {
+ if (loIndexOf(recommended, id) < 0) {
var item = customLegend(id);
if (item) {
$pane.append(item);
diff --git a/web/js/link/model.js b/web/js/link/model.js
index feb9f4dc6..97c070261 100644
--- a/web/js/link/model.js
+++ b/web/js/link/model.js
@@ -1,8 +1,8 @@
import $ from 'jquery';
-import each from 'lodash/each';
-import map from 'lodash/map';
-import isArray from 'lodash/isArray';
-import isObject from 'lodash/isObject';
+import loEach from 'lodash/each';
+import loMap from 'lodash/map';
+import loIsArray from 'lodash/isArray';
+import loIsObject from 'lodash/isObject';
import util from '../util/util';
export function linkModel(config) {
@@ -46,19 +46,19 @@ export function linkModel(config) {
// Returns a serialized string containing information of the current session
self.toQueryString = function () {
var state = {};
- each(components, function (component) {
+ loEach(components, function (component) {
component.save(state);
});
- var strings = map(state, function (value, key) {
- if (isArray(value)) {
+ var strings = loMap(state, function (value, key) {
+ if (loIsArray(value)) {
var parts = [];
- each(value, function (item) {
+ loEach(value, function (item) {
var part = '';
- if (isObject(item)) {
+ if (loIsObject(item)) {
part = item.id;
if (item.attributes && item.attributes.length > 0) {
var attributes = [];
- each(item.attributes, function (attribute) {
+ loEach(item.attributes, function (attribute) {
if (attribute.value) {
attributes.push(attribute.id + '=' + attribute.value);
} else {
@@ -111,14 +111,14 @@ export function linkModel(config) {
self.load = function (state, errors) {
errors = errors || [];
- each(components, function (component) {
+ loEach(components, function (component) {
component.load(state, errors);
});
};
var encode = function (value) {
var encoded = encodeURIComponent(value);
- each(ENCODING_EXCEPTIONS, function (exception) {
+ loEach(ENCODING_EXCEPTIONS, function (exception) {
encoded = encoded.replace(exception.match, exception.replace);
});
return encoded;
diff --git a/web/js/link/ui.js b/web/js/link/ui.js
index b7c6a8f8f..a7a6568bf 100644
--- a/web/js/link/ui.js
+++ b/web/js/link/ui.js
@@ -1,5 +1,5 @@
import $ from 'jquery';
-import throttle from 'lodash/throttle';
+import loThrottle from 'lodash/throttle';
import React from 'react';
import ReactDOM from 'react-dom';
import Clipboard from 'clipboard';
@@ -46,7 +46,7 @@ export function linkUi(models, config) {
};
// Calls toQueryString to fetch updated state and returns URL
- var replaceHistoryState = throttle(function () {
+ var replaceHistoryState = loThrottle(function () {
if (util.browser.history) {
window.history.replaceState('', '@OFFICIAL_NAME@', '?' + models.link.toQueryString());
}
diff --git a/web/js/palettes/legend.js b/web/js/palettes/legend.js
index cddc43846..6427f2859 100644
--- a/web/js/palettes/legend.js
+++ b/web/js/palettes/legend.js
@@ -1,7 +1,7 @@
import $ from 'jquery';
-import each from 'lodash/each';
-import first from 'lodash/first';
-import last from 'lodash/last';
+import loEach from 'lodash/each';
+import loFirst from 'lodash/first';
+import loLast from 'lodash/last';
import util from '../util/util';
import palettes from './palettes';
@@ -46,7 +46,7 @@ export function palettesLegend(spec) {
.attr('data-layer', layer.id);
$parent.append($legendPanel);
var legends = model.getLegends(layer.id);
- each(legends, function (legend, index) {
+ loEach(legends, function (legend, index) {
if ((legend.type === 'continuous') ||
(legend.type === 'discrete')) {
renderScale($legendPanel, legend, index, layer.id);
@@ -118,7 +118,7 @@ export function palettesLegend(spec) {
var updateClasses = function (legend, index) {
var $panel = $(selector + ' [data-index=\'' + index + '\']');
$panel.empty();
- each(legend.colors, function (color, classIndex) {
+ loEach(legend.colors, function (color, classIndex) {
var $colorBox;
var $runningDataPointLabel = $('<span></span>')
.addClass('wv-running-category-label');
@@ -137,7 +137,7 @@ export function palettesLegend(spec) {
$colorBox.on('mouseout', hideUnitsOnMouseOut);
});
var $detailPanel = $('<div></div>');
- each(legend.colors, function (color, classIndex) {
+ loEach(legend.colors, function (color, classIndex) {
var label = legend.tooltips[classIndex];
label = (legend.units) ? label + ' ' + legend.units : label;
var $row = $('<div></div>')
@@ -166,7 +166,7 @@ export function palettesLegend(spec) {
return;
}
var legends = model.getLegends(layer.id);
- each(legends, function (legend, index) {
+ loEach(legends, function (legend, index) {
if ((legend.type === 'continuous') ||
(legend.type === 'discrete')) {
palettes.colorbar(selector + ' ' +
@@ -185,9 +185,9 @@ export function palettesLegend(spec) {
var legends = model.getLegends(layer.id, index);
var entries = model.get(layer.id, index)
.entries;
- each(legends, function (legend, index) {
- var min = legend.minLabel || first(legend.tooltips);
- var max = legend.maxLabel || last(legend.tooltips);
+ loEach(legends, function (legend, index) {
+ var min = legend.minLabel || loFirst(legend.tooltips);
+ var max = legend.maxLabel || loLast(legend.tooltips);
min = (legend.units) ? min + ' ' + legend.units : min;
max = (legend.units) ? max + ' ' + legend.units : max;
$(selector + ' [data-index=\'' + index + '\'] .wv-palettes-min')
diff --git a/web/js/palettes/model.js b/web/js/palettes/model.js
index fd8e285fd..43f1ac238 100644
--- a/web/js/palettes/model.js
+++ b/web/js/palettes/model.js
@@ -1,9 +1,9 @@
-import each from 'lodash/each';
-import find from 'lodash/find';
-import cloneDeep from 'lodash/cloneDeep';
-import isNaN from 'lodash/isNaN';
-import isUndefined from 'lodash/isUndefined';
-import parseInt from 'lodash/parseInt';
+import loEach from 'lodash/each';
+import loFind from 'lodash/find';
+import loCloneDeep from 'lodash/cloneDeep';
+import loIsNaN from 'lodash/isNaN';
+import loIsUndefined from 'lodash/isUndefined';
+import loParseInt from 'lodash/parseInt';
import util from '../util/util';
import palettes from './palettes';
@@ -20,7 +20,7 @@ export function palettesModel(models, config) {
self.getRendered = function (layerId, index) {
var name = config.layers[layerId].palette.id;
var palette = config.palettes.rendered[name];
- if (!isUndefined(index)) {
+ if (!loIsUndefined(index)) {
palette = palette.maps[index];
}
return palette;
@@ -38,11 +38,11 @@ export function palettesModel(models, config) {
self.active[layerId] = self.active[layerId] || {};
var active = self.active[layerId];
active.maps = active.maps || [];
- each(self.getRendered(layerId)
+ loEach(self.getRendered(layerId)
.maps,
function (palette, index) {
if (!active.maps[index]) {
- active.maps[index] = cloneDeep(palette);
+ active.maps[index] = loCloneDeep(palette);
}
});
};
@@ -59,7 +59,7 @@ export function palettesModel(models, config) {
throw new Error('Invalid layer: ' + layerId);
}
prepare(layerId);
- index = (isUndefined(index)) ? 0 : index;
+ index = (loIsUndefined(index)) ? 0 : index;
var active = self.active[layerId];
var palette = active.maps[index];
if (palette.custom === paletteId) {
@@ -72,7 +72,7 @@ export function palettesModel(models, config) {
};
self.clearCustom = function (layerId, index) {
- index = (isUndefined(index)) ? 0 : index;
+ index = (loIsUndefined(index)) ? 0 : index;
var active = self.active[layerId];
if (!active) {
return;
@@ -89,7 +89,7 @@ export function palettesModel(models, config) {
self.setRange = function (layerId, min, max, squash, index) {
prepare(layerId);
- index = (isUndefined(index)) ? 0 : index;
+ index = (loIsUndefined(index)) ? 0 : index;
var palette = self.active[layerId].maps[index];
if (min === 0) {
min = undefined;
@@ -122,7 +122,7 @@ export function palettesModel(models, config) {
* @return {object} object including the entries and legend
*/
self.get = function (layerId, index) {
- index = (isUndefined(index)) ? 0 : index;
+ index = (loIsUndefined(index)) ? 0 : index;
if (self.active[layerId]) {
return self.active[layerId].maps[index];
}
@@ -200,8 +200,8 @@ export function palettesModel(models, config) {
if (self.inUse() && !state.l) {
throw new Error('No layers in state');
}
- each(self.active, function (def, layerId) {
- if (!find(models.layers.get(), {
+ loEach(self.active, function (def, layerId) {
+ if (!loFind(models.layers.get(), {
id: layerId
})) {
return;
@@ -215,7 +215,7 @@ export function palettesModel(models, config) {
};
self.saveSingle = function (state, layerId) {
- var attr = find(state.l, {
+ var attr = loFind(state.l, {
id: layerId
})
.attributes;
@@ -288,7 +288,7 @@ export function palettesModel(models, config) {
}
}
- var attr = find(state.l, {
+ var attr = loFind(state.l, {
id: layerId
})
.attributes;
@@ -344,18 +344,18 @@ export function palettesModel(models, config) {
return;
}
- each(state.l, function (layerDef) {
+ loEach(state.l, function (layerDef) {
var layerId = layerDef.id;
var minValue, maxValue;
var min = [],
max = [];
var squash = [];
var count = 0;
- each(layerDef.attributes, function (attr) {
+ loEach(layerDef.attributes, function (attr) {
if (attr.id === 'palette') {
count = self.getCount(layerId);
values = util.toArray(attr.value.split(';'));
- each(values, function (value, index) {
+ loEach(values, function (value, index) {
try {
self.setCustom(layerId, value, index);
} catch (error) {
@@ -366,13 +366,13 @@ export function palettesModel(models, config) {
if (attr.id === 'min') {
count = self.getCount(layerId);
values = util.toArray(attr.value.split(';'));
- each(values, function (value, index) {
+ loEach(values, function (value, index) {
if (value === '') {
min.push(undefined);
return;
}
minValue = parseFloat(value);
- if (isNaN(minValue)) {
+ if (loIsNaN(minValue)) {
errors.push('Invalid min value: ' + value);
} else {
min.push(findIndex(layerId, 'min', minValue, index));
@@ -382,13 +382,13 @@ export function palettesModel(models, config) {
if (attr.id === 'max') {
count = self.getCount(layerId);
values = util.toArray(attr.value.split(';'));
- each(values, function (value, index) {
+ loEach(values, function (value, index) {
if (value === '') {
max.push(undefined);
return;
}
maxValue = parseFloat(value);
- if (isNaN(maxValue)) {
+ if (loIsNaN(maxValue)) {
errors.push('Invalid max value: ' + value);
} else {
max.push(findIndex(layerId, 'max', maxValue, index));
@@ -401,7 +401,7 @@ export function palettesModel(models, config) {
squash[0] = true;
} else {
values = util.toArray(attr.value.split(';'));
- each(values, function (value) {
+ loEach(values, function (value) {
squash.push(value === 'true');
});
}
@@ -423,7 +423,7 @@ export function palettesModel(models, config) {
var values = self.get(layerId, index)
.entries.values;
var result;
- each(values, function (check, index) {
+ loEach(values, function (check, index) {
var min = getMinValue(check);
var max = getMaxValue(check);
if (type === 'min' && value === min) {
@@ -443,7 +443,7 @@ export function palettesModel(models, config) {
self.inUse = function () {
var layers = models.layers.get();
var found = false;
- each(layers, function (layer) {
+ loEach(layers, function (layer) {
if (self.active[layer.id]) {
found = true;
return false;
@@ -456,7 +456,7 @@ export function palettesModel(models, config) {
var use = false;
var active = self.active[layerId].maps;
- each(active, function (palette, index) {
+ loEach(active, function (palette, index) {
if (palette.custom) {
use = true;
return false;
@@ -469,7 +469,7 @@ export function palettesModel(models, config) {
if (palette.max >= rendered.entries.values.length) {
delete palette.max;
}
- if (!isUndefined(palette.min) || !isUndefined(palette.max)) {
+ if (!loIsUndefined(palette.min) || !loIsUndefined(palette.max)) {
use = true;
return false;
}
@@ -485,7 +485,7 @@ export function palettesModel(models, config) {
}
var active = self.active[layerId].maps;
var lookup = {};
- each(active, function (palette, index) {
+ loEach(active, function (palette, index) {
oldLegend = palette.legend;
entries = palette.entries;
legend = {
@@ -511,7 +511,7 @@ export function palettesModel(models, config) {
var targetCount = target.length;
var indexCount = max - min;
- each(source, function (color, index) {
+ loEach(source, function (color, index) {
var newColor;
if (index < min || index > max) {
targetColor = '00000000';
@@ -534,15 +534,15 @@ export function palettesModel(models, config) {
}
legend.colors.push(targetColor);
var lookupSource =
- parseInt(color.substring(0, 2), 16) + ',' +
- parseInt(color.substring(2, 4), 16) + ',' +
- parseInt(color.substring(4, 6), 16) + ',' +
- parseInt(color.substring(6, 8), 16);
+ loParseInt(color.substring(0, 2), 16) + ',' +
+ loParseInt(color.substring(2, 4), 16) + ',' +
+ loParseInt(color.substring(4, 6), 16) + ',' +
+ loParseInt(color.substring(6, 8), 16);
var lookupTarget = {
- r: parseInt(targetColor.substring(0, 2), 16),
- g: parseInt(targetColor.substring(2, 4), 16),
- b: parseInt(targetColor.substring(4, 6), 16),
- a: parseInt(targetColor.substring(6, 8), 16)
+ r: loParseInt(targetColor.substring(0, 2), 16),
+ g: loParseInt(targetColor.substring(2, 4), 16),
+ b: loParseInt(targetColor.substring(4, 6), 16),
+ a: loParseInt(targetColor.substring(6, 8), 16)
};
lookup[lookupSource] = lookupTarget;
});
diff --git a/web/js/palettes/palettes.js b/web/js/palettes/palettes.js
index 7d7cbdf78..8e89a1157 100644
--- a/web/js/palettes/palettes.js
+++ b/web/js/palettes/palettes.js
@@ -1,6 +1,6 @@
import $ from 'jquery';
-import each from 'lodash/each';
-import find from 'lodash/find';
+import loEach from 'lodash/each';
+import loFind from 'lodash/find';
import util from '../util/util';
import wvui from '../ui/ui';
@@ -37,7 +37,7 @@ export const palettes = (function (self) {
var bins = colors.length;
var binWidth = canvas.width / bins;
var drawWidth = Math.ceil(binWidth);
- each(colors, function (color, i) {
+ loEach(colors, function (color, i) {
g.fillStyle = util.hexToRGBA(color);
g.fillRect(Math.floor(binWidth * i), 0, drawWidth,
canvas.height);
@@ -69,7 +69,7 @@ export const palettes = (function (self) {
self.translate = function (source, target) {
var translation = [];
- each(source, function (color, index) {
+ loEach(source, function (color, index) {
var sourcePercent = index / source.length;
var targetIndex = Math.floor(sourcePercent * target.length);
translation.push(target[targetIndex]);
@@ -79,7 +79,7 @@ export const palettes = (function (self) {
self.lookup = function (sourcePalette, targetPalette) {
var lookup = {};
- each(sourcePalette.colors, function (sourceColor, index) {
+ loEach(sourcePalette.colors, function (sourceColor, index) {
var source =
parseInt(sourceColor.substring(0, 2), 16) + ',' +
parseInt(sourceColor.substring(2, 4), 16) + ',' +
@@ -114,12 +114,12 @@ export const palettes = (function (self) {
rendered: {},
custom: {}
};
- each(state.l, function (qsLayer) {
+ loEach(state.l, function (qsLayer) {
var layerId = qsLayer.id;
if (config.layers[layerId] && config.layers[layerId].palette) {
promises.push(self.loadRendered(config, layerId));
}
- var custom = find(qsLayer.attributes, {
+ var custom = loFind(qsLayer.attributes, {
id: 'palette'
});
if (custom) {
@@ -147,7 +147,7 @@ export const palettes = (function (self) {
return;
}
var parts = state.palettes.split('~');
- each(parts, function (part) {
+ loEach(parts, function (part) {
var items = part.split(',');
var layerId = items[0];
var paletteId = items[1];
@@ -162,7 +162,7 @@ export const palettes = (function (self) {
'support palettes'
});
} else {
- var layer = find(state.l, {
+ var layer = loFind(state.l, {
id: layerId
});
if (layer) {
diff --git a/web/js/projection/model.js b/web/js/projection/model.js
index 716da6dac..34097fdab 100644
--- a/web/js/projection/model.js
+++ b/web/js/projection/model.js
@@ -1,5 +1,5 @@
-import each from 'lodash/each';
-import ol from 'openlayers';
+import loEach from 'lodash/each';
+import olProj from 'ol/proj';
import proj4 from 'proj4';
import util from '../util/util';
@@ -10,10 +10,10 @@ export function projectionModel(config) {
var init = function () {
self.selectDefault();
- each(config.projections, function (proj) {
+ loEach(config.projections, function (proj) {
if (proj.crs && proj.proj4) {
self.register(proj.crs, proj.proj4);
- ol.proj.get(proj.crs)
+ olProj.get(proj.crs)
.setExtent(proj.maxExtent);
}
});
diff --git a/web/js/projection/ui.js b/web/js/projection/ui.js
index c10e08698..120b5e113 100644
--- a/web/js/projection/ui.js
+++ b/web/js/projection/ui.js
@@ -1,5 +1,5 @@
import $ from 'jquery';
-import each from 'lodash/each';
+import loEach from 'lodash/each';
import wvui from '../ui/ui';
export function projectionUi(models, config) {
@@ -55,7 +55,7 @@ export function projectionUi(models, config) {
.attr('id', 'wv-proj-menu');
$menuItems = $('<ul></ul>');
- each(config.ui.projections, function (ui) {
+ loEach(config.ui.projections, function (ui) {
var $item = $(
'<li data-proj=\'' + ui.id + '\'>' +
'<a data-proj=\'' + ui.id + '\'>' +
diff --git a/web/js/util/events.js b/web/js/util/events.js
index a70ed8c8d..b5c8de113 100644
--- a/web/js/util/events.js
+++ b/web/js/util/events.js
@@ -1,5 +1,5 @@
-import each from 'lodash/each';
-import pull from 'lodash/pull';
+import loEach from 'lodash/each';
+import loPull from 'lodash/pull';
export function events () {
var self = {};
@@ -24,7 +24,7 @@ export function events () {
self.off = function (event, callback) {
var listeners = events[event];
if (listeners) {
- pull(listeners, callback);
+ loPull(listeners, callback);
}
return self;
};
@@ -42,10 +42,10 @@ export function events () {
return;
}
var eventArguments = Array.prototype.slice.call(arguments, 1);
- each(events[event], function (listener) {
+ loEach(events[event], function (listener) {
listener.apply(self, eventArguments);
});
- each(allListeners, function (listener) {
+ loEach(allListeners, function (listener) {
listener.apply(self, eventArguments);
});
return self;
diff --git a/web/js/util/load.js b/web/js/util/load.js
index 0d8b15a04..39e6d4ef4 100644
--- a/web/js/util/load.js
+++ b/web/js/util/load.js
@@ -1,5 +1,5 @@
import $ from 'jquery';
-import size from 'lodash/size';
+import loSize from 'lodash/size';
import wvui from '../ui/ui.js';
import brand from '../brand.js';
@@ -18,7 +18,7 @@ export const load = (function () {
.fail(promise.reject);
return promise;
}
- if (root[attr] && size(root[attr]) > 0) {
+ if (root[attr] && loSize(root[attr]) > 0) {
promise.resolve(root[attr]);
} else {
loading += 1;
diff --git a/web/js/util/util.js b/web/js/util/util.js
index 5690cd9d3..ab5942189 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -1,8 +1,8 @@
/* global ntptEventTag */
import $ from 'jquery';
-import each from 'lodash/each';
-import isNull from 'lodash/isNull';
+import loEach from 'lodash/each';
+import loIsNull from 'lodash/isNull';
import wvui from '../ui/ui.js';
import browser from './browser.js';
import events from './events.js';
@@ -110,9 +110,9 @@ export const util = (function () {
self.toQueryString = function (kvps, exceptions) {
exceptions = exceptions || {};
var parts = [];
- each(kvps, function (value, key) {
+ loEach(kvps, function (value, key) {
var part = key + '=' + encodeURIComponent(value);
- each(exceptions, function (exception) {
+ loEach(exceptions, function (exception) {
var regexp = new RegExp(exception, 'ig');
var decoded = decodeURIComponent(exception);
part = part.replace(regexp, decoded);
@@ -481,7 +481,7 @@ export const util = (function () {
*/
self.fromCompactTimestamp = function (str) {
var v = str.match(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{3})/);
- if (isNull(v)) {
+ if (loIsNull(v)) {
throw new Error('Invalid timestamp:' + str);
}
return new Date(Date.UTC(
diff --git a/web/js/wv.main.js b/web/js/wv.main.js
index 28206acdf..8ebb07699 100644
--- a/web/js/wv.main.js
+++ b/web/js/wv.main.js
@@ -1,6 +1,6 @@
// External Dependencies
import $ from 'jquery';
-import each from 'lodash/each';
+import loEach from 'lodash/each';
import {GA as googleAnalytics} from 'worldview-components';
// Utils
@@ -120,7 +120,7 @@ window.onload = () => {
// Load any additional scripts as needed
if (config.scripts) {
- each(config.scripts, function(script) {
+ loEach(config.scripts, function(script) {
$.getScript(script);
});
}
@@ -140,7 +140,7 @@ window.onload = () => {
if (config.features.animation) {
parsers.push(animationParser);
}
- each(parsers, function(parser) {
+ loEach(parsers, function(parser) {
parser(state, errors, config);
});
requirements = [
@@ -347,7 +347,7 @@ window.onload = () => {
var errorReport = function() {
var layersRemoved = 0;
- each(errors, function(error) {
+ loEach(errors, function(error) {
var cause = (error.cause) ? ': ' + error.cause : '';
util.warn(error.message + cause);
if (error.layerRemoved) {