Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Replace reimplemented for arctic projection change

Mike McGannd3525f95fb82
diff --git a/src/js/date/wv.date.timeline.js b/src/js/date/wv.date.timeline.js
index c488fd98d..c7c93e99a 100644
--- a/src/js/date/wv.date.timeline.js
+++ b/src/js/date/wv.date.timeline.js
@@ -78,8 +78,8 @@ Element.prototype.toggleClass = function (className) {
"value": "6"
}
];
-
-
+
+
//margins for the timeline
margin = {
top: 0,
@@ -87,7 +87,7 @@ Element.prototype.toggleClass = function (className) {
bottom: 0,
left: 0
};
-
+
//subtract the datepicker from the width of the screen
width = window.innerWidth - $("#timeline header").outerWidth() - 30;
height = 60 - margin.top - margin.bottom;
@@ -95,21 +95,21 @@ Element.prototype.toggleClass = function (className) {
var monthNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
var self = {};
-
-
+
+
var x = d3.time.scale()
.domain([
d3.min(data, function(d) { return d.date; }),
d3.max(data, function(d) { return d.date; })
])
.range([0, width]);
-
+
var y = d3.scale.linear()
.domain(d3.extent(data2, function (d) {
return d.value;
}))
.range([height, 0]);
-
+
var line = d3.svg.line()
.x(function (d) {
return x(d.date);
@@ -117,7 +117,7 @@ Element.prototype.toggleClass = function (className) {
.y(function (d) {
return y(d.value);
});
-
+
var zoomed = function(){
var t = zoom.translate(),
s = zoom.scale();
@@ -127,7 +127,7 @@ Element.prototype.toggleClass = function (className) {
zoom.translate([tx, ty]);
-
+
//console.log(d3.event.translate);
//console.log(d3.event.scale);
svg.select(".x.axis").call(xAxis);
@@ -142,21 +142,21 @@ Element.prototype.toggleClass = function (className) {
svg.select(".line2")
.attr("class", "line2")
.attr("d", line);
-
+
var makeFill = d3.select('.line2').attr("d");
d3.select(".line2").attr("d", makeFill + "l3,0l0,60z");
var makeFillPos = $(".line2").offset();
$("svg#now-line").css("left", (makeFillPos.left-3) + "px");
-
+
d3.selectAll('.x.axis .tick text').attr('x',5).attr('style','text-anchor:left;');
-
+
};
-
+
var zoom = d3.behavior.zoom()
.x(x)
.scaleExtent([1, 1500])
.on("zoom", zoomed);
-
+
var make_x_axis = function (x) {
return d3.svg.axis()
.scale(x)
@@ -175,14 +175,14 @@ Element.prototype.toggleClass = function (className) {
.scale(x)
.orient("bottom")
.ticks(10);
-
+
var yAxis = d3.svg.axis()
.scale(y)
.orient("left")
.ticks(5);
var init = function() {
-
+
svg = d3.select('#timeline footer')
.append("svg:svg")
.attr('width', width + margin.left + margin.right)
@@ -196,14 +196,14 @@ Element.prototype.toggleClass = function (className) {
.attr("height", 60)
.attr("class", "plot");
-
+
svg.append("svg:g")
.attr("class", "x axis")
.attr("transform", "translate(0, " + 35 + ")")
.call(xAxis);
-
+
svg.append("g")
.attr("class", "x grid")
@@ -238,8 +238,8 @@ Element.prototype.toggleClass = function (className) {
$("svg#now-line").css("left", (makeFillPos.left-3) + "px");
d3.selectAll('.x.axis .tick text').attr('x',5).attr('style','text-anchor:left;');
-
- // Hover line.
+
+ // Hover line.
var hoverLineGroup = svg.append("g")
.attr("class", "hover-line");
var hoverLine = hoverLineGroup
@@ -250,21 +250,21 @@ Element.prototype.toggleClass = function (className) {
var hoverDate = hoverLineGroup.append('text')
.attr("class", "hover-text")
.attr('y', height-40);
-
+
// Hide hover line by default.
hoverLineGroup.style("opacity", 1e-6);
-
-
+
+
updateTime();
-
+
// Add mouseover events.
-
- d3.select("#timeline footer").on("mouseenter", function() {
+
+ d3.select("#timeline footer").on("mouseenter", function() {
$("#timeline-text").show();
hoverLineGroup.style("opacity", 1);
}).on("mousemove", function() {
-
+
var mouse_x = d3.mouse(this)[0];
var mouse_y = d3.mouse(this)[1];
var graph_y = y.invert(mouse_y);
@@ -300,8 +300,8 @@ Element.prototype.toggleClass = function (className) {
$("svg#now-line").css("left", (makeFillPos.left-3) + "px");
currentDate = new Date(data2[0].date);
updateTime();
-
-
+
+
});
$("svg#now-line").mousedown(function(e){
console.log("mousedown");
@@ -322,7 +322,7 @@ Element.prototype.toggleClass = function (className) {
}).mouseup(function(){
d3.select("#timeline footer").on("mousemove", null);
d3.select("#timeline footer").on("mousemove", function() {
-
+
var mouse_x = d3.mouse(this)[0];
var mouse_y = d3.mouse(this)[1];
var graph_y = y.invert(mouse_y);
@@ -343,7 +343,7 @@ Element.prototype.toggleClass = function (className) {
}
$("#timeline-text").css({"left": d3.event.pageX});
});
-
+
});
//bind click action to interval radio buttons
@@ -376,10 +376,10 @@ Element.prototype.toggleClass = function (className) {
};
var render = function() {
-
+
};
var updateTime = function() {
-
+
var changeMapDate = new Date(data2[0].date);
models.date.select(changeMapDate);
@@ -391,12 +391,12 @@ Element.prototype.toggleClass = function (className) {
else {
document.querySelector('#day-input-group').value = currentDate.getDate();
}
-
+
};
-
+
//increments the time depending on which interval is selected and updates in timeline/datepicker
var increment_time = function(){
-
+
//bind interval radio buttons, find currently selected, increment it by 1
var hoverDate = document.querySelectorAll(".button-input-group");
for (var i=0;i<hoverDate.length;i++){
@@ -422,22 +422,22 @@ Element.prototype.toggleClass = function (className) {
var newTimeBar = x(new Date(data2[0].date));
//update timeline line
svg.select(".line2").attr("d", line);
-
+
var makeFill = d3.select('.line2').attr("d");
d3.select(".line2").attr("d", makeFill + "l3,0l0,60z");
var makeFillPos = $(".line2").offset();
$("svg#now-line").css("left", (makeFillPos.left-3) + "px");
-
+
currentDate = new Date(data2[0].date);
updateTime();
}//if
}//for
-
+
};// end increment_time
var decrement_time = function(){
-
+
//bind interval radio buttons, find currently selected, increment it by 1
var hoverDate = document.querySelectorAll(".button-input-group");
for (var i=0;i<hoverDate.length;i++){
@@ -462,21 +462,21 @@ Element.prototype.toggleClass = function (className) {
var newTimeBar = x(new Date(data2[0].date));
//update timeline line
svg.select(".line2").attr("d", line);
-
+
var makeFill = d3.select('.line2').attr("d");
d3.select(".line2").attr("d", makeFill + "l3,0l0,60z");
var makeFillPos = $(".line2").offset();
$("svg#now-line").css("left", (makeFillPos.left-3) + "px");
-
+
currentDate = new Date(data2[0].date);
updateTime();
}//if
}//for
-
-
+
+
};//end decrement_time
-
-
+
+
init();
return self;
diff --git a/src/js/layers/wv.layers.model.js b/src/js/layers/wv.layers.model.js
index b36018505..07d52a540 100644
--- a/src/js/layers/wv.layers.model.js
+++ b/src/js/layers/wv.layers.model.js
@@ -154,7 +154,7 @@ wv.layers.model = wv.layers.model || function(models, config) {
};
self.remove = function(id) {
- var index = _.findIndex(self.active, {id: id});
+ var index = _.findIndex(self.active, { id: id });
var def = self.active[index];
if ( index >= 0 ) {
self.active.splice(index, 1);
@@ -167,7 +167,15 @@ wv.layers.model = wv.layers.model || function(models, config) {
};
self.replace = function(idOld, idNew) {
- throw new Error("Replace called");
+ var index = _.findIndex(self.active, { id: idOld });
+ if ( index < 0 ) {
+ return;
+ }
+ var oldDef = self.active[index];
+ var newDef = config.layers[idNew];
+ self.active[index] = newDef;
+ self.events.trigger("update");
+ self.events.trigger("change");
};
self.clear = function(projId) {