Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

wrap the snapshot label #2551

Benjamin King03d9cca7893c
diff --git a/web/js/components/map/ol-coordinates.js b/web/js/components/map/ol-coordinates.js
index 541e93aae..e8b0c22e2 100644
--- a/web/js/components/map/ol-coordinates.js
+++ b/web/js/components/map/ol-coordinates.js
@@ -34,19 +34,19 @@ class OlCoordinates extends React.Component {
}
let pcoord = transform(coord, crs, 'EPSG:4326');
let [lon, lat] = pcoord;
- if (lon < -180 || lon > 180 || lat < -90 || lat > 90) {
- if (lon > 180 && lon < 250 && crs === 'EPSG:4326') {
- lon = lon - 360;
- pcoord = [lon, lat];
- } else if (lon < -180 && lon > -250 && crs === 'EPSG:4326') {
- lon = 360 + lon;
+ if (Math.abs(lat) > 90) {
+ this.clearCoord();
+ return;
+ }
+ if (Math.abs(lon) > 180) {
+ if (crs === 'EPSG:4326') {
+ lon = util.normalizeWrappedLongitude(lon);
pcoord = [lon, lat];
} else {
this.clearCoord();
return;
}
}
-
this.setState({
hasMouse: true,
format: util.getCoordinateFormat(),
diff --git a/web/js/containers/image-download.js b/web/js/containers/image-download.js
index f92142730..a08ca461c 100644
--- a/web/js/containers/image-download.js
+++ b/web/js/containers/image-download.js
@@ -98,6 +98,8 @@ class ImageDownloadContainer extends Component {
isGeoProjection,
proj.selected.resolutions
);
+ const boxTopLongitude = Math.abs(geolonlat1[0]) > 180 ? util.normalizeWrappedLongitude(geolonlat1[0]) : geolonlat1[0];
+ const boxBottomLongitude = Math.abs(geolonlat2[0]) > 180 ? util.normalizeWrappedLongitude(geolonlat2[0]) : geolonlat2[0];
return (
<ErrorBoundary>
<Panel
@@ -135,8 +137,8 @@ class ImageDownloadContainer extends Component {
width: x2 - x
}}
coordinates={{
- bottomLeft: util.formatCoordinate([geolonlat1[0], geolonlat1[1]]),
- topRight: util.formatCoordinate([geolonlat2[0], geolonlat2[1]])
+ bottomLeft: util.formatCoordinate([boxTopLongitude, geolonlat1[1]]),
+ topRight: util.formatCoordinate([boxBottomLongitude, geolonlat2[1]])
}}
showCoordinates={true}
/>
diff --git a/web/js/util/util.js b/web/js/util/util.js
index 70eb825a1..8e7ac6bb4 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -1035,7 +1035,17 @@ export default (function(self) {
coord[0].toFixed(4) + '°';
}
};
-
+ /**
+ * map openlayers provided longitude value to be between -180 && 180
+ *
+ * @param {longitude} number map longitude value
+ * @return normalized longitude value
+ */
+ self.normalizeWrappedLongitude = function(longitude) {
+ const negative = longitude < 0;
+ const value = longitude % 360;
+ return negative && value < -180 ? value + 360 : !negative && value > 180 ? value - 360 : value;
+ };
// Allows simple printf functionality with strings
// arguments array contains all args passed. String must be formatted
// so that first replacement starts with "{1}"