Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

added annotations to wv.map.runningdata.js

Benjamin40176a5c840b
diff --git a/web/js/map/wv.map.runningdata.js b/web/js/map/wv.map.runningdata.js
index 50c4b5e4a..1a232aa9d 100644
--- a/web/js/map/wv.map.runningdata.js
+++ b/web/js/map/wv.map.runningdata.js
@@ -21,7 +21,23 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
self.prePixelData = [];
self.pixel = null;
self.oldLayers = [];
-
+
+ /*
+ * Retrieves the label, length and index of
+ * of the label from the palette scale object
+ *
+ * @method getDataLabel
+ *
+ * @param {object} scale - pallete scale object
+ * contains 3 arrays:
+ * scale.colors
+ * scale.labels
+ * scale.values
+ *
+ * @param {String} hex - color value
+ *
+ * @return {object}
+ */
self.getDataLabel = function(scale, hex) {
for(var i = 0, len = scale.colors.length; i < len; i++) {
if(scale.colors[i] === hex) {
@@ -31,6 +47,21 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
return undefined;
};
+ /*
+ * Gets the point in which to place the running
+ * data value label
+ *
+ * @method getLabelMarginLeft
+ *
+ * @param {Number} labelWidth - width of label
+ *
+ * @param {Number} caseWidth - width of palette case
+ *
+ * @param {Number} location - location of point on palette
+ *
+ * @return {number} margin-left value of label
+ *
+ */
self.getLabelMarginLeft = function(labelWidth, caseWidth, location) {
if(location + (labelWidth / 2) > caseWidth) {
return (caseWidth - labelWidth);
@@ -40,9 +71,36 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
return (location - (labelWidth / 2));
}
};
+
+ /*
+ * Gets the point in which to place the running
+ * data value label
+ *
+ * @method getLabelMarginLeft
+ *
+ * @param {String} id - Palette id
+ *
+ * @return {Object} Jquery palette dom object
+ *
+ */
self.getPalette = function(id) {
return $('#' + id + '_palette');
};
+
+ /*
+ * Get location in which to put pin on palette
+ *
+ * @method getPercent
+ *
+ * @param {Number} len - length of palette palette.scale.colors array
+ *
+ * @param {Number} Index - Index of color value in
+ * palette.scale.colors array
+ *
+ * @return {number} Percent of color index in
+ * palette.scale.colors array
+ *
+ */
self.getPercent = function(len, index, caseWidth) {
var segmentWidth;
var location;
@@ -54,9 +112,38 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
return (index / len);
}
};
+
+ /*
+ * Compare old and new arrays to determine which Layers need to be
+ * removed
+ *
+ * @method LayersToRemove
+ *
+ * @param {Array} oldArray - Array of layers at last pixel point
+ *
+ * @param {Array} newArray - Array of layers at new pixel point
+ * palette.scale.colors array
+ *
+ * @return {Array} Array of layers to remove
+ *
+ */
self.LayersToRemove = function(oldArray, newArray) {
return _.difference(oldArray, newArray);
};
+
+ /*
+ * Compare old and new arrays to determine which Layers need to be
+ * removed
+ *
+ * @method LayersToRemove
+ *
+ * @param {Array} coords - Array of coordinate values
+ *
+ * @param {Object} map - OpenLayers Map Object
+ *
+ * @return {Void}
+ *
+ */
self.newPoint = function(coords, map) {
self.activeLayers = [];
@@ -88,12 +175,39 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
}
self.oldLayers = self.activeLayers;
};
+
+ /*
+ * Remove wv-running class from palette case
+ * element
+ *
+ * @method remove
+ *
+ * @param {String} id - Pallete id
+ *
+ * @return {Void}
+ *
+ */
self.remove = function(id) {
var $palette = $('#' + id);
var $paletteCase = $palette.parent();
$paletteCase.removeClass('wv-running');
$palette.removeClass('wv-running');
};
+ /*
+ * Add running-data component to palette for
+ * category layers
+ *
+ * @method setCategoryValue
+ *
+ * @param {String} id - Pallete id
+ *
+ * @param {Object} data - Object that contains
+ * the index, length and label of running data
+ * value
+ *
+ * @return {Void}
+ *
+ */
self.setCategoryValue = function(id, data) {
var $categoryPaletteCase;
var $caseWidth;
@@ -124,6 +238,22 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
$categoryPaletteCase.find('.wv-active').removeClass('wv-active');
$colorSquare.addClass('wv-active');
};
+
+ /*
+ * Add running-data component to palette for
+ * non-category layers
+ *
+ * @method setLayerValue
+ *
+ * @param {String} id - Pallete id
+ *
+ * @param {Object} data - Object that contains
+ * the index, length and label of running data
+ * value
+ *
+ * @return {Void}
+ *
+ */
self.setLayerValue = function(id, data) {
var $palette;
var $paletteCase;
@@ -155,6 +285,17 @@ wv.map.runningdata = wv.map.runningdata || function(models) {
$paletteBar.attr('style', 'left:' + Math.round(location) + 'px;');
$paletteCase.addClass('wv-running');
};
+
+ /*
+ * Loops through and removes running data values from layers
+ *
+ * @method updateRunners
+ *
+ * @param {Object} layers - list of layers to remove
+ *
+ * @return {Void}
+ *
+ */
self.updateRunners = function(layers) {
if(layers.length) {
for(var i = 0, len = layers.length; i < len; i++) {