Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Switching to polar no longer breaks

Mike McGannaa6787323dee
diff --git a/src/js/Worldview/DataDownload/ExtentFilter.js b/src/js/Worldview/DataDownload/ExtentFilter.js
index 65c092c8a..f7813ea8d 100644
--- a/src/js/Worldview/DataDownload/ExtentFilter.js
+++ b/src/js/Worldview/DataDownload/ExtentFilter.js
@@ -18,11 +18,14 @@ Worldview.DataDownload.ExtentFilter = function(config, options, model) {
var self = {};
var extents = {};
+ var maxExtents = {};
var init = function() {
$.each(options, function(epsg, extentArray) {
- var extent = new OpenLayers.Bounds(extentArray);
- extents[epsg] = extent;
+ extents[epsg] = new OpenLayers.Bounds(extentArray);
+ });
+ $.each(config.projections, function(projectionName, projection) {
+ maxExtents[projectionName] = projection.maxExtent;
});
};
@@ -32,8 +35,7 @@ Worldview.DataDownload.ExtentFilter = function(config, options, model) {
return result;
}
- var extent =
- extents[model.epsg] || config.projections[model.projection];
+ var extent = extents[model.epsg] || maxExtents[model.projection];
var mbr = geom.getBounds();
if ( extent.intersectsBounds(mbr) ) {
result.geometry[model.epsg] = geom;
diff --git a/src/js/Worldview/DataDownload/MapView.js b/src/js/Worldview/DataDownload/MapView.js
index 375e77050..84f236800 100644
--- a/src/js/Worldview/DataDownload/MapView.js
+++ b/src/js/Worldview/DataDownload/MapView.js
@@ -68,19 +68,19 @@ Worldview.DataDownload.MapView = function(model, maps, config) {
if ( !result.centroid ) {
result.centroid = {};
}
+ var echoGeom = Worldview.DataDownload.ECHOGeometry(result);
if ( !result.geometry["4326"] ) {
- var geom = Worldview.DataDownload.ECHOGeometry(result)
- .toOpenLayers("EPSG:4326", "EPSG:" + model.epsg);
+ var geom = echoGeom.toOpenLayers();
var centroid = geom.getCentroid();
result.geometry["4326"] = geom;
result.centroid["4326"] = centroid;
- }
- if ( model.epsg !== "4326" && !result.geometry[model.epsg] ) {
- var geom = Worldview.DataDownload.ECHOGeometry(result)
- .toOpenLayers("EPSG:4326", "EPSG:" + model.epsg);
- var centroid = geom.getCentroid();
- result.geometry[model.epsg] = geom;
- result.geometry[model.epsg] = centroid;
+ }
+ if ( !result.geometry[model.epsg] ) {
+ var projGeom = echoGeom.toOpenLayers("EPSG:4326",
+ "EPSG:" + model.epsg);
+ var projCentroid = projGeom.getCentroid();
+ result.geometry[model.epsg] = projGeom;
+ result.geometry[model.epsg] = projCentroid;
}
$.each(filters, function(index, filter) {
if ( result ) {
diff --git a/src/js/Worldview/Map.js b/src/js/Worldview/Map.js
index 75ae4f971..db73c1f23 100644
--- a/src/js/Worldview/Map.js
+++ b/src/js/Worldview/Map.js
@@ -28,6 +28,9 @@ $(function(ns) {
// Used to reference the TileWorker
var BUILD_NONCE = "@BUILD_NONCE@";
+ ns.EPSG_GCS_WGS_84 = "4326";
+ ns.EPSG_GEOGRAPHIC = ns.EPSG_GCS_WGS_84;
+
/**
* An object that contains OpenLayers.Control.MousePosition objects
* that update the current latitude/longitude values on the map as the
@@ -184,9 +187,7 @@ $(function(ns) {
ns.adjustAntiMeridian = function(polygon, adjustSign) {
var outerRing = polygon.components[0];
var points = outerRing.components.slice();
- if ( adjustSign === 1 ) {
- console.log("adjust", polygon);
- }
+
for ( var i = 0 ; i < points.length; i++ ) {
if ( adjustSign > 0 && points[i].x < 0 ) {
points[i] = new OpenLayers.Geometry.Point(