Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

retrieved data from hover

Benjamin8f34ee229db2
diff --git a/web/index.html b/web/index.html
index ca73ae239..22f6764f1 100644
--- a/web/index.html
+++ b/web/index.html
@@ -211,6 +211,7 @@
<!-- link.dev --> <script type="text/javascript" src="js/map/wv.map.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/map/wv.map.model.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/map/wv.map.rotate.js"></script>
+ <!-- link.dev --> <script type="text/javascript" src="js/map/wv.map.runningdata.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/map/wv.map.ui.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/link/wv.link.model.js"></script>
diff --git a/web/js/map/wv.map.runningdata.js b/web/js/map/wv.map.runningdata.js
new file mode 100644
index 000000000..bf4f838a0
--- /dev/null
+++ b/web/js/map/wv.map.runningdata.js
@@ -0,0 +1,80 @@
+var wv = wv || {};
+
+wv.map = wv.map || {};
+/*
+ * @Class
+ */
+wv.map.runningdata = wv.map.runningdata || function(activeLayers) {
+ var self = this;
+ self.layers = [];
+ self.prePixelData = [];
+ self.pixel = null;
+ self.activeLayers = activeLayers;
+
+ self.resetActiveLayers = function(activeLayers) {
+ self.activeLayers = activeLayers;
+ }
+ self.preRender = function(evt) {
+ var context, x, y, data, pixelRatio, blank;
+ if(self.pixel) {
+ context = evt.context
+ pixelRatio = evt.frameState.pixelRatio;
+ self.x = self.pixel[0];
+ self.y = self.pixel[1];
+ x = self.x * pixelRatio;
+ y = self.y * pixelRatio;
+ self.prePixelData = evt.context.getImageData(x, y, 1, 1).data;
+ blank = context.createImageData(1,1)
+ context.putImageData(blank, x, y);
+ }
+ }
+ self.postRender = function(evt) {
+ var layer, pixelRatio, context, data, x, y, d;
+ if(self.pixel) {
+ d = self.prePixelData;
+ layer = evt.target;
+ pixelRatio = evt.frameState.pixelRatio;
+ context = evt.context;
+
+ x = self.x * pixelRatio;
+ y = self.y * pixelRatio;
+ data = context.getImageData(x, y, 1, 1).data;
+ context.fillStyle = "rgba("+d[0]+","+d[1]+","+d[2]+","+d[3]+")";
+ }
+ }
+ self.addLayerToSideBar = function() {
+
+ }
+
+ self.arraysAreEqual = function(arr1, arr2) {
+ if(arr1.length !== arr2.length)
+ return false;
+ for(var i = arr1.length; i--;) {
+ if(arr1[i] !== arr2[i])
+ return false;
+ }
+ return true;
+ }
+
+
+ self.updateLayers = function(layers) {
+
+ // this.layers= [];
+ // for(var i = 0, len = layers.length; i < len; i++ ) {
+ // // var def = layers[i].wv.def;
+ // // if(def.visible && def.pallete) {
+ // // this.layers.push
+ // // }
+ // console.log('layer-obj' + layers[i].wv.def.visible + 'group' +layers[i].wv.def.palette);
+
+ // }
+ }
+
+ self.newPoint = function(pixel) {
+ self.pixel = pixel;
+ }
+
+ self.retrieveValues = function() {
+
+ }
+}
\ No newline at end of file
diff --git a/web/js/map/wv.map.ui.js b/web/js/map/wv.map.ui.js
index e710519c7..e1128927b 100644
--- a/web/js/map/wv.map.ui.js
+++ b/web/js/map/wv.map.ui.js
@@ -12,13 +12,14 @@
var wv = wv || {};
wv.map = wv.map || {};
-wv.map.ui = wv.map.ui || function(models, config, Rotation) {
+wv.map.ui = wv.map.ui || function(models, config, Rotation, DataRunner) {
var id = "wv-map";
var selector = "#" + id;
var cache = new Cache(100); // Save layers from days visited
var animationDuration = 250;
var self = {};
var rotation = new Rotation(self, models);
+ var dataRunner = new DataRunner();
self.proj = {}; // One map for each projection
self.selected = null; // The map for the selected projection
self.events = wv.util.events();
@@ -125,6 +126,7 @@ wv.map.ui = wv.map.ui || function(models, config, Rotation) {
map.removeLayer(mapLayer);
}
});
+ dataRunner.resetActiveLayers(activeLayers)
removeGraticule();
//cache.clear();
};
@@ -146,7 +148,8 @@ wv.map.ui = wv.map.ui || function(models, config, Rotation) {
};
var updateLayerVisibilities = function() {
- self.selected.getLayers().forEach(function(layer) {
+ var layers = self.selected.getLayers();
+ layers.forEach(function(layer) {
if ( layer.wv ) {
var renderable = models.layers.isRenderable(layer.wv.id);
layer.setVisible(renderable);
@@ -163,6 +166,7 @@ wv.map.ui = wv.map.ui || function(models, config, Rotation) {
}
}
});
+ dataRunner.updateLayers(layers.getArray());
};
var updateOpacity = function(def, value) {
@@ -179,6 +183,12 @@ wv.map.ui = wv.map.ui || function(models, config, Rotation) {
addGraticule();
} else {
var layer = createLayer(def);
+ layer.on('precompose', function(evt) {
+ dataRunner.preRender(evt);
+ })
+ layer.on('postcompose', function(evt) {
+ dataRunner.postRender(evt);
+ })
self.selected.getLayers().insertAt(mapIndex, layer);
}
updateLayerVisibilities();
@@ -305,6 +315,7 @@ wv.map.ui = wv.map.ui || function(models, config, Rotation) {
var sourceOptions = {
url: source.url + extra,
layer: def.layer || def.id,
+ crossOrigin: "anonymous",
format: def.format,
matrixSet: matrixSet.id,
tileGrid: new ol.tilegrid.WMTS({
@@ -320,7 +331,7 @@ wv.map.ui = wv.map.ui || function(models, config, Rotation) {
sourceOptions.tileClass = ol.wv.LookupImageTile.factory(lookup);
}
var layer = new ol.layer.Tile({
- source: new ol.source.WMTS(sourceOptions)
+ source: new ol.source.WMTS(sourceOptions),
});
return layer;
};
@@ -349,6 +360,7 @@ wv.map.ui = wv.map.ui || function(models, config, Rotation) {
var layer = new ol.layer.Tile({
source: new ol.source.TileWMS({
url: source.url + extra,
+ crossOrigin: "anonymous",
params: parameters,
tileGrid: new ol.tilegrid.TileGrid({
origin: [proj.maxExtent[0], proj.maxExtent[3]],
@@ -582,6 +594,7 @@ wv.map.ui = wv.map.ui || function(models, config, Rotation) {
.addClass('coord-btn');
$coordWrapper.append($coordBtn);
+
$mousePosition
.append($latlonDD)
.append($latlonDMS)
@@ -612,10 +625,15 @@ wv.map.ui = wv.map.ui || function(models, config, Rotation) {
.mousemove(function(e){
$('#' + mapId).show();
var coords = map.getCoordinateFromPixel([e.pageX,e.pageY]);
+
+ dataRunner.newPoint(map.getPixelFromCoordinate(coords), map);
+
$('#' + mapId + ' span.map-coord').each(function(){
var format = $(this).attr('data-format');
$(this).html(coordinateFormat(coords, format));
});
+ map.render();
+ e.preventDefault();
});
};