Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Coordinates at corners for image download, latlon preferences saved in localStoraget

Mike McGann11aba2b74968
diff --git a/web/css/wv.image.css b/web/css/wv.image.css
index 596de7812..e5072f76c 100644
--- a/web/css/wv.image.css
+++ b/web/css/wv.image.css
@@ -44,3 +44,22 @@
font-size: 12px;
padding: 0.2em 1em;
}
+
+.wv-image-coords {
+ position: absolute;
+ z-index: 500;
+ color: white;
+ white-space: pre;
+ color: #fff;
+ text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
+ padding: 5px;
+}
+
+#wv-image-bottom {
+ text-align: left;
+}
+
+#wv-image-top {
+ text-align: right;
+}
+
diff --git a/web/index.html b/web/index.html
index 7d879db28..18563988e 100644
--- a/web/index.html
+++ b/web/index.html
@@ -299,5 +299,9 @@
</div>
</div>
<div id="wv-tour-content"></div>
+ <div id="wv-image-top" class="wv-image-coords">top</div>
+ <div id="wv-image-right" class="wv-image-coords">right</div>
+ <div id="wv-image-bottom" class="wv-image-coords">bottom</div>
+ <div id="wv-image-left" class="wv-image-coords">left</div>
</body>
</html>
diff --git a/web/js/image/wv.image.panel.js b/web/js/image/wv.image.panel.js
index ccc4daaa3..968b3d585 100644
--- a/web/js/image/wv.image.panel.js
+++ b/web/js/image/wv.image.panel.js
@@ -150,6 +150,8 @@ wv.image.panel = wv.image.panel || function(models, ui, config) {
of: ("#wv-image-button"),
});
$dialog.dialog("open");
+
+ $(".wv-image-coords").show();
};
var setPosition = function(){
@@ -193,6 +195,30 @@ wv.image.panel = wv.image.panel || function(models, ui, config) {
var lonlat1 = map.getCoordinateFromPixel([Math.floor(x1), Math.floor(y2)]);
var lonlat2 = map.getCoordinateFromPixel([Math.floor(x2), Math.floor(y1)]);
+ var minLon = lonlat1[0];
+ var maxLon = lonlat2[0];
+ var minLat = lonlat2[1];
+ var maxLat = lonlat1[1];
+
+ var ll = wv.util.formatCoordinate([maxLat, minLon]);
+ var ur = wv.util.formatCoordinate([minLat, maxLon]);
+
+ if ( x2 - x1 < 150 ) {
+ ll = "";
+ ur = "";
+ }
+
+ $("#wv-image-top").css({
+ left: x1 - 10,
+ top: y1 - 20,
+ width: x2 - x1
+ }).html(ur);
+ $("#wv-image-bottom").css({
+ left: x1,
+ top: y2,
+ width: x2 - x1
+ }).html(ll);
+
var dlURL = url;
var conversionFactor = 256;
if (s=="geographic") {
diff --git a/web/js/image/wv.image.rubberband.js b/web/js/image/wv.image.rubberband.js
index b7c137603..bc60ea465 100644
--- a/web/js/image/wv.image.rubberband.js
+++ b/web/js/image/wv.image.rubberband.js
@@ -149,6 +149,7 @@ wv.image.rubberband = wv.image.rubberband || function(models, ui, config) {
}
toolbarButtons("enable");
wv.ui.closeDialog();
+ $(".wv-image-coords").hide();
}
};
diff --git a/web/js/map/wv.map.ui.js b/web/js/map/wv.map.ui.js
index 7a1a41922..d0b1ab939 100644
--- a/web/js/map/wv.map.ui.js
+++ b/web/js/map/wv.map.ui.js
@@ -517,7 +517,7 @@ wv.map.ui = wv.map.ui || function(models, config) {
onZoomChange();
};
- var createMousePosSel = function(map, proj){
+ var createMousePosSel = function(map, proj) {
var $map = $("#" + map.getTarget());
map = map || self.selected;
var mapId = 'coords-' + proj.id;
@@ -529,59 +529,42 @@ wv.map.ui = wv.map.ui || function(models, config) {
var $mousePositionWrapper = $('<div></div>')
.addClass('.select-wrapper');
- var coordinateFormat = function(source, data) {
- var str;
+ var coordinateFormat = function(source, format) {
+ if ( !source ) {
+ return "";
+ }
var target = ol.proj.transform(source, proj.crs, "EPSG:4326");
var crs = ( models.proj.change ) ? models.proj.change.crs
: models.proj.selected.crs;
- switch(data){
- case 'latlon-deg':
- str = wv.util.formatDMS(target[1], "latitude") + ", " +
- wv.util.formatDMS(target[0], "longitude") + " " +
- crs;
- break;
- case 'latlon-decimal':
- str = target[1].toFixed(4) + ", " +
- target[0].toFixed(4) + " " +
- crs;
- break;
- case 'lonlat-decimal':
- str = target[0].toFixed(4) + ", " +
- target[1].toFixed(4) + " " +
- crs;
- break;
- case 'lonlat-deg':
- str = wv.util.formatDMS(target[0], "longitude") + ", " +
- wv.util.formatDMS(target[1], "latitude") + " " +
- crs;
- break;
- }
- return str;
+
+ return wv.util.formatCoordinate(target, format) + " " + crs;
};
$mousePositionWrapper.append($mousePosition);
$map.append($mousePositionWrapper);
- var $latlonDec = $("<option></option>")
- .attr('id', mapId + '-latlon-decimal')
- .attr('data-coord', 'latlon-decimal')
+ var $latlonDD = $("<option></option>")
+ .attr('id', mapId + '-latlon-dd')
+ .attr('data-format', 'latlon-dd')
.addClass('map-coord');
- var $latlonDeg = $("<option></option>")
- .attr('id', mapId + '-latlon-deg')
- .attr('data-coord', 'latlon-deg')
- .addClass('map-coord')
- .prop("selected",true);
- var $lonlatDec = $("<option></option>")
- .attr('id', mapId + '-lonlat-decimal')
- .attr('data-coord', 'lonlat-decimal')
- .addClass('map-coord');
- var $lonlatDeg = $("<option></option>")
- .attr('id', mapId + '-lonlat-deg')
- .attr('data-coord', 'lonlat-deg')
+ var $latlonDMS = $("<option></option>")
+ .attr('id', mapId + '-latlon-dms')
+ .attr('data-format', 'latlon-dms')
.addClass('map-coord');
- $mousePosition.append($latlonDec).append($latlonDeg)
- .append($lonlatDec).append($lonlatDeg);
+ if ( wv.util.getCoordinateFormat() === "latlon-dd" ) {
+ $latlonDD.prop("selected", true);
+ } else {
+ $latlonDMS.prop("selected", true);
+ }
+
+ $mousePosition
+ .append($latlonDD)
+ .append($latlonDMS)
+ .change(function() {
+ wv.util.setCoordinateFormat($(this).find(":selected").attr("data-format"));
+ });
+
$("#" + map.getTarget() + '>div')
.mouseover(function(){
$('#' + mapId).show();
@@ -592,8 +575,8 @@ wv.map.ui = wv.map.ui || function(models, config) {
.mousemove(function(e){
var coords = map.getCoordinateFromPixel([e.pageX,e.pageY]);
$('#' + mapId + ' option.map-coord').each(function(){
- var data = $(this).attr('data-coord');
- $(this).html(coordinateFormat(coords, data));
+ var format = $(this).attr('data-format');
+ $(this).html(coordinateFormat(coords, format));
});
});
};
diff --git a/web/js/util/wv.util.js b/web/js/util/wv.util.js
index 67e7f3aaa..3db4b8475 100644
--- a/web/js/util/wv.util.js
+++ b/web/js/util/wv.util.js
@@ -587,6 +587,27 @@ wv.util = (function(self) {
return sdegrees + "&deg;" + sminutes + "'" + sseconds + '"' + sign;
};
+ self.setCoordinateFormat = function(type) {
+ if ( type !== "latlon-dd" && type !== "latlon-dms" ) {
+ throw new Error("Invalid coordinate format: " + type);
+ }
+ self.localStorage("coordinateFormat", type);
+ };
+
+ self.getCoordinateFormat = function() {
+ return self.localStorage("coordinateFormat") || "latlon-dd";
+ };
+
+ self.formatCoordinate = function(coord, format) {
+ var type = format || self.getCoordinateFormat();
+ if ( type === "latlon-dms" ) {
+ return self.formatDMS(coord[1], "latitude") + ", " +
+ self.formatDMS(coord[0], "longitude");
+ } else {
+ return coord[1].toFixed(4) + ", " + coord[0].toFixed(4);
+ }
+ };
+
return self;
})(wv.util || {});