Interactive interface for browsing global, full-resolution satellite imagery
Exported imagePanel & imageRubberband
ZachTRice50e87898a97c
diff --git a/web/js/image/wv.image.panel.js b/web/js/image/image.panel.jssimilarity index 91%rename from web/js/image/wv.image.panel.jsrename to web/js/image/image.panel.jsindex 2b52ddf95..e04aafb66 100644--- a/web/js/image/wv.image.panel.js+++ b/web/js/image/image.panel.js@@ -1,7 +1,12 @@-var wv = wv || {};-wv.image = wv.image || {};--wv.image.panel = wv.image.panel || function (models, ui, config) {+import $ from 'jquery';+import each from 'lodash/each';+import isUndefined from 'lodash/isUndefined';+import ol from 'openlayers';+import {GA as googleAnalytics} from 'worldview-components';+import util from '../util/util.js';+import wvui from '../ui/ui.js';++export function imagePanel(models, ui, config) {var self = {};var container;@@ -26,7 +31,7 @@ wv.image.panel = wv.image.panel || function (models, ui, config) {url = host + '/' + path + '?';if (config.parameters.imagegen) {- wv.util.warn('Redirecting image download to: ' + url);+ util.warn('Redirecting image download to: ' + url);}var init = function () {@@ -95,7 +100,7 @@ wv.image.panel = wv.image.panel || function (models, ui, config) {'</table>' +'</div>';- var $dialog = wv.ui.getDialog()+ var $dialog = wvui.getDialog().html(htmlElements);$dialog.dialog({dialogClass: 'wv-panel wv-image',@@ -137,7 +142,7 @@ wv.image.panel = wv.image.panel || function (models, ui, config) {// Auto-set default resolution to map's current zoom level; round it// for incremental zoom steps- var curZoom = Math.round(wvx.ui.map.selected.getView()+ var curZoom = Math.round(ui.map.selected.getView().getZoom());// Don't do anything if the user hasn't changed zoom levels; we want to@@ -218,7 +223,7 @@ wv.image.panel = wv.image.panel || function (models, ui, config) {$('#wv-image-worldfile option[value=\'' + worldfile + '\']').attr('selected', 'selected');- wv.ui.positionDialog($dialog, {+ wvui.positionDialog($dialog, {my: 'left top',at: 'left bottom+5',of: ('#wv-image-button')@@ -259,10 +264,9 @@ wv.image.panel = wv.image.panel || function (models, ui, config) {// get layer transparencies (opacities)var opacities = [];- _(products)- .each(function (product) {- opacities.push((_.isUndefined(product.opacity)) ? 1 : product.opacity);- });+ each(products, function (product) {+ opacities.push((isUndefined(product.opacity)) ? 1 : product.opacity);+ });// console.log("EPSG: " + epsg);@@ -284,8 +288,8 @@ wv.image.panel = wv.image.panel || function (models, ui, config) {var minLat = geolonlat2[1];var maxLat = geolonlat1[1];- var ll = wv.util.formatCoordinate([minLon, maxLat]);- var ur = wv.util.formatCoordinate([maxLon, minLat]);+ var ll = util.formatCoordinate([minLon, maxLat]);+ var ur = util.formatCoordinate([maxLon, minLat]);if (x2 - x1 < 150) {ll = '';@@ -315,7 +319,7 @@ wv.image.panel = wv.image.panel || function (models, ui, config) {var dTime = time;// Julian date, padded with two zeros (to ensure the julian date is always in DDD format).- var jStart = wv.util.parseDateUTC(dTime.getUTCFullYear() + '-01-01');+ var jStart = util.parseDateUTC(dTime.getUTCFullYear() + '-01-01');var jDate = '00' + (1 + Math.ceil((dTime.getTime() - jStart) / 86400000));dlURL += 'TIME=' + dTime.getUTCFullYear() + (jDate).substr((jDate.length) - 3);@@ -325,7 +329,7 @@ wv.image.panel = wv.image.panel || function (models, ui, config) {// dlURL += "&switch="+s;dlURL += '&epsg=' + epsg;var layers = [];- _.each(products, function (layer) {+ each(products, function (layer) {if (layer.projections[s].layer) {layers.push(layer.projections[s].layer);} else {@@ -380,12 +384,12 @@ wv.image.panel = wv.image.panel || function (models, ui, config) {$('#wv-image-download-button').unbind('click').click(function () {- WVC.GA.event('Image Download', 'Click', 'Download');- wv.util.metrics('lc=' + encodeURIComponent(dlURL + '&worldfile=' + imgWorldfile + '&format=' + imgFormat + '&width=' + imgWidth + '&height=' + imgHeight));+ googleAnalytics.event('Image Download', 'Click', 'Download');+ util.metrics('lc=' + encodeURIComponent(dlURL + '&worldfile=' + imgWorldfile + '&format=' + imgFormat + '&width=' + imgWidth + '&height=' + imgHeight));window.open(dlURL + '&worldfile=' + imgWorldfile + '&format=' + imgFormat + '&width=' + imgWidth + '&height=' + imgHeight, '_blank');});} catch (cause) {- wv.util.error(cause);+ util.error(cause);}};diff --git a/web/js/image/wv.image.rubberband.js b/web/js/image/image.rubberband.jssimilarity index 95%rename from web/js/image/wv.image.rubberband.jsrename to web/js/image/image.rubberband.jsindex f67737c33..10f6efba0 100644--- a/web/js/image/wv.image.rubberband.js+++ b/web/js/image/image.rubberband.js@@ -1,7 +1,9 @@-var wv = wv || {};-wv.image = wv.image || {};+import $ from 'jquery';+import find from 'lodash/find';+import util from '../util/util.js';+import wvui from '../ui/ui.js';-wv.image.rubberband = wv.image.rubberband || function (models, ui, config) {+export function imageRubberband(models, ui, config) {var self = {};var PALETTE_WARNING =@@ -29,7 +31,7 @@ wv.image.rubberband = wv.image.rubberband || function (models, ui, config) {var jcropAPI = null;var previousPalettes = null;var $button;- self.events = wv.util.events();+ self.events = util.events();/*** Initializes the RubberBand component.@@ -115,10 +117,10 @@ wv.image.rubberband = wv.image.rubberband || function (models, ui, config) {renderable: true});var on = true;- if (_.find(layers, {+ if (find(layers, {id: 'Graticule'}) && geographic) {- wv.ui.ask({+ wvui.ask({header: 'Notice',message: GRATICLE_WARNING,onOk: disableGraticle,@@ -133,7 +135,7 @@ wv.image.rubberband = wv.image.rubberband || function (models, ui, config) {// Confirm with the user they want to continue, and if so, disable// the palettes before bringing up the crop box.if (models.palettes.inUse()) {- wv.ui.ask({+ wvui.ask({header: 'Notice',message: PALETTE_WARNING,onOk: disablePalettes,@@ -147,7 +149,7 @@ wv.image.rubberband = wv.image.rubberband || function (models, ui, config) {// Don't toggle area select UI for downloading image if image rotatedif (ui.map.selected.getView().getRotation() === 0.0) { toggleOn(); } else {- wv.ui.ask({+ wvui.ask({header: 'Reset rotation?',message: ROTATE_WARNING,onOk: function () {@@ -169,7 +171,7 @@ wv.image.rubberband = wv.image.rubberband || function (models, ui, config) {previousPalettes = null;}toolbarButtons('enable');- wv.ui.closeDialog();+ wvui.closeDialog();$('.wv-image-coords').hide();}diff --git a/web/js/index.js b/web/js/index.jsindex 7c79cdb39..b468a1466 100644--- a/web/js/index.js+++ b/web/js/index.js@@ -1,6 +1,8 @@export { stub, stub2 } from './stub';export { polyfill } from './polyfill';export { util } from './util/util';+export { imagePanel } from './image/image.panel';+export { imageRubberband } from './image/image.rubberband';export { linkModel } from './link/link.model';export { linkUi } from './link/link.ui';export { parse as layerParser, validate as layerValidate } from './layers/layers';