Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

change track maxzoom and radius for polar projections

Ed Platod55a6252c274
diff --git a/web/js/natural-events/cluster.js b/web/js/natural-events/cluster.js
index 1ce57af14..73339e786 100644
--- a/web/js/natural-events/cluster.js
+++ b/web/js/natural-events/cluster.js
@@ -1,6 +1,11 @@
import superCluster from 'supercluster';
import lodashRound from 'lodash/round';
+export function setMaxZoomCluster(maxZoom) {
+
+}
+
+
/**
* Create superCLuster Object - Uses map and reduce
* operations to create a timespan on each clustered
@@ -10,8 +15,8 @@ import lodashRound from 'lodash/round';
*/
export function naturalEventsClusterCreateObject() {
return superCluster({
- radius: 40, // pixel radius where points are clustered
- maxZoom: 16,
+ radius: 60, // pixel radius where points are clustered
+ maxZoom: 12,
initial: function() {
return {
startDate: null,
@@ -35,8 +40,15 @@ export function naturalEventsClusterCreateObject() {
accumulated.startDate = Date.parse(new Date(pastStartDate)) > Date.parse(new Date(newDate)) ? newDate : pastStartDate;
accumulated.endDate = Date.parse(new Date(pastEndDate)) < Date.parse(new Date(newDate)) ? newDate : pastEndDate;
}
+ },
+ setPolar: function() {
+ this.radius = 30;
+ this.maxZoom = 7;
+ },
+ setGeo: function() {
+ this.radius = 60;
+ this.maxZoom = 12
}
-
});
};
/**
diff --git a/web/js/natural-events/track.js b/web/js/natural-events/track.js
index f3924c1b9..a48da7eb7 100644
--- a/web/js/natural-events/track.js
+++ b/web/js/natural-events/track.js
@@ -258,6 +258,16 @@ var createTrack = function (models, eventObj, map, selectedDate, callback) {
geoJSONPointsAfterSelected.push(naturalEventsClusterPointToGeoJSON(eventObj.id, coordinates, date));
}
});
+
+ // set radius and maxZoom of superCluster object for polar vs geographic projections
+ if (models.proj.selected.id !== 'geographic') {
+ firstClusterObj.options.setPolar();
+ secondClusterObj.options.setPolar();
+ } else {
+ firstClusterObj.options.setGeo();
+ secondClusterObj.options.setGeo();
+ }
+
clustersBeforeSelected = naturalEventsClusterGetPoints(firstClusterObj, geoJSONPointsBeforeSelected, zoom);
clustersAfterSelected = naturalEventsClusterGetPoints(secondClusterObj, geoJSONPointsAfterSelected, zoom);
clusters = clustersBeforeSelected.concat([selectedPoint], clustersAfterSelected);
@@ -376,6 +386,7 @@ var addPoints = function(models, clusters, map, selectedDate, callback) {
let prevCoordinates = clusters[index - 1].geometry.coordinates;
let nextCoordinates = clusterPoint.geometry.coordinates;
+ // polar projections require transform of coordinates to crs
if (models.proj.selected.id !== 'geographic') {
prevCoordinates = olProj.transform(prevCoordinates, 'EPSG:4326', models.proj.selected.crs);
nextCoordinates = olProj.transform(nextCoordinates, 'EPSG:4326', models.proj.selected.crs);
diff --git a/web/js/natural-events/ui.js b/web/js/natural-events/ui.js
index 9ab44f875..d3e2d482c 100644
--- a/web/js/natural-events/ui.js
+++ b/web/js/natural-events/ui.js
@@ -249,6 +249,11 @@ export default function naturalEventsUI (models, ui, config, request) {
return date;
};
+ /**
+ * Filter event list in sidebar based on projection/view extents
+ *
+ * @param {Boolean} showAll - show all available points in projection
+ */
self.filterEventList = function (showAll) {
if (!model.data.events) return;
var hiddenEventsCounter = self.markers.length;
@@ -288,7 +293,7 @@ export default function naturalEventsUI (models, ui, config, request) {
// limit to maxExtent while allowing zoom and filter 'out of extent' events
var isVisible = olExtent.containsCoordinate(extent, coordinates) &&
olExtent.containsCoordinate(maxExtent, coordinates);
- // boolean argument to showAll limited to maxExtent of current projection - for polar
+ // boolean showAll events limited to maxExtent of current projection
if (showAll) {
isVisible = olExtent.containsCoordinate(maxExtent, coordinates);
}