Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Fix vector wrapping wip #2511

Benjamin Kinge28cc8fc95bd
diff --git a/config/default/common/config/wv.json/layers/sedac/Nuclear_Power_Plant_Locations.json b/config/default/common/config/wv.json/layers/sedac/Nuclear_Power_Plant_Locations.json
index fe9c2d4fd..876632011 100644
--- a/config/default/common/config/wv.json/layers/sedac/Nuclear_Power_Plant_Locations.json
+++ b/config/default/common/config/wv.json/layers/sedac/Nuclear_Power_Plant_Locations.json
@@ -18,7 +18,8 @@
},
"vectorStyle": {
"id": "Nuclear_Power_Plant_Locations"
- }
+ },
+ "wrapX": true
}
}
}
\ No newline at end of file
diff --git a/web/js/map/layerbuilder.js b/web/js/map/layerbuilder.js
index dea03f3e7..b54cf50c5 100644
--- a/web/js/map/layerbuilder.js
+++ b/web/js/map/layerbuilder.js
@@ -31,7 +31,7 @@ import {
export function mapLayerBuilder(models, config, cache, ui, store) {
const self = {};
- self.init = function() {
+ self.init = function () {
self.extentLayers = [];
};
@@ -83,7 +83,7 @@ export function mapLayerBuilder(models, config, cache, ui, store) {
* @param {object} options - Layer options
* @returns {object} OpenLayers layer
*/
- self.createLayer = function(def, options) {
+ self.createLayer = function (def, options) {
const state = store.getState();
const activeDateStr = state.compare.isCompareA ? 'selected' : 'selectedB';
options = options || {};
@@ -143,7 +143,7 @@ export function mapLayerBuilder(models, config, cache, ui, store) {
* @param {object} options Layer options
* @return {object} Closest date
*/
- self.getRequestDates = function(def, options) {
+ self.getRequestDates = function (def, options) {
const state = store.getState();
const activeDateStr = state.compare.isCompareA ? 'selected' : 'selectedB';
const stateCurrentDate = new Date(state.date[activeDateStr]);
@@ -203,7 +203,7 @@ export function mapLayerBuilder(models, config, cache, ui, store) {
* @param {boolean} precache
* @returns {object} layer key Object
*/
- self.layerKey = function(def, options, state) {
+ self.layerKey = function (def, options, state) {
const { compare } = state;
var date;
var layerId = def.id;
@@ -291,7 +291,7 @@ export function mapLayerBuilder(models, config, cache, ui, store) {
* @param {object} options - Layer options
* @returns {object} OpenLayers WMTS layer
*/
- const createLayerWMTS = function(def, options, day, state) {
+ const createLayerWMTS = function (def, options, day, state) {
const activeDateStr = state.compare.isCompareA ? 'selected' : 'selectedB';
const proj = state.proj.selected;
const source = config.sources[def.source];
@@ -354,15 +354,16 @@ export function mapLayerBuilder(models, config, cache, ui, store) {
* @param {object} options - Layer options
* @returns {object} OpenLayers Vector layer
*/
- const createLayerVector = function(def, options, day, state) {
+ const createLayerVector = function (def, options, day, state) {
const { proj, compare } = state;
- var date, urlParameters, extent, source, matrixSet, matrixIds, start;
+ let date, urlParameters, gridExtent, source, matrixSet, matrixIds, start, layerExtent;
const selectedProj = proj.selected;
const activeDateStr = compare.isCompareA ? 'selected' : 'selectedB';
const activeGroupStr = options.group ? options.group : compare.activeString;
source = config.sources[def.source];
- extent = selectedProj.maxExtent;
+ gridExtent = selectedProj.maxExtent;
+ layerExtent = gridExtent;
start = [selectedProj.maxExtent[0], selectedProj.maxExtent[3]];
if (!source) {
@@ -374,7 +375,7 @@ export function mapLayerBuilder(models, config, cache, ui, store) {
}
if (typeof def.matrixIds === 'undefined') {
matrixIds = [];
- lodashEach(matrixSet.resolutions, function(resolution, index) {
+ lodashEach(matrixSet.resolutions, function (resolution, index) {
matrixIds.push(index);
});
} else {
@@ -383,11 +384,13 @@ export function mapLayerBuilder(models, config, cache, ui, store) {
if (day) {
if (day === 1) {
- extent = [-250, -90, -180, 90];
- start = [-540, 90];
+ layerExtent = [-250, -90, -180, 90];
+ start = [-180, 90];
+ gridExtent = [110, -90, 180, 90];
} else {
- extent = [180, -90, 250, 90];
- start = [180, 90];
+ gridExtent = [-180, -90, -110, 90];
+ layerExtent = [180, -90, 250, 90];
+ start = [-180, 90];
}
}
@@ -416,19 +419,22 @@ export function mapLayerBuilder(models, config, cache, ui, store) {
var sourceOptions = new SourceVectorTile({
url: source.url + urlParameters,
layer: layerName,
+ day: day,
format: new MVT(),
matrixSet: tms,
+ wrapX: true,
tileGrid: new OlTileGridTileGrid({
- extent: extent,
- origin: start,
+ extent: gridExtent,
resolutions: matrixSet.resolutions,
- tileSize: matrixSet.tileSize
+ tileSize: matrixSet.tileSize,
+ origin: start
})
});
var layer = new LayerVectorTile({
- extent: extent,
+ extent: layerExtent,
source: sourceOptions
+
});
if (config.vectorStyles && def.vectorStyle && def.vectorStyle.id) {
@@ -444,7 +450,8 @@ export function mapLayerBuilder(models, config, cache, ui, store) {
}
});
}
- setStyleFunction(def, vectorStyleId, vectorStyles, layer, state);
+ setStyleFunction(def, vectorStyleId, vectorStyles, layer, state, day);
+ if (day) { }
}
return layer;
@@ -459,7 +466,7 @@ export function mapLayerBuilder(models, config, cache, ui, store) {
* @param {object} options - Layer options
* @returns {object} OpenLayers WMS layer
*/
- const createLayerWMS = function(def, options, day, state) {
+ const createLayerWMS = function (def, options, day, state) {
const { proj, compare } = state;
const activeDateStr = compare.isCompareA ? 'selected' : 'selectedB';
const selectedProj = proj.selected;
diff --git a/web/js/modules/vector-styles/selectors.js b/web/js/modules/vector-styles/selectors.js
index f84e4ae18..1449e58df 100644
--- a/web/js/modules/vector-styles/selectors.js
+++ b/web/js/modules/vector-styles/selectors.js
@@ -9,6 +9,7 @@ import {
} from '../layers/selectors';
import { getMinValue, getMaxValue, selectedStyleFunction } from './util';
import update from 'immutability-helper';
+import { containsCoordinate } from 'ol/extent';
import stylefunction from 'ol-mapbox-style/stylefunction';
/**
* Gets a single colormap (entries / legend combo)
@@ -53,7 +54,7 @@ export function findIndex(layerId, type, value, index, groupStr, state) {
index = index || 0;
var values = getVectorStyle(layerId, index, groupStr, state).entries.values;
var result;
- lodashEach(values, function(check, index) {
+ lodashEach(values, function (check, index) {
var min = getMinValue(check);
var max = getMaxValue(check);
if (type === 'min' && value === min) {
@@ -73,7 +74,7 @@ export function setRange(layerId, props, index, palettes, state) {
return (layerId, props, index, palettes, state);
}
-export function setStyleFunction(def, vectorStyleId, vectorStyles, layer, state) {
+export function setStyleFunction(def, vectorStyleId, vectorStyles, layer, state, day) {
var styleFunction;
var layerId = def.id;
var glStyle = vectorStyles[layerId];
@@ -90,6 +91,7 @@ export function setStyleFunction(def, vectorStyleId, vectorStyles, layer, state)
var layerGroup;
if (olMap) {
layerGroups = olMap.getLayers().getArray();
+ console.log(layerGroups);
if (state.compare && state.compare.active) {
if (layerGroups.length === 2) {
layerGroup =
@@ -100,7 +102,7 @@ export function setStyleFunction(def, vectorStyleId, vectorStyles, layer, state)
: null;
}
}
- lodashEach(activeLayers, function(def) {
+ lodashEach(activeLayers, function (def) {
if (state.compare && state.compare.active) {
if (layerGroup && layerGroup.getLayers().getArray().length) {
lodashEach(layerGroup.getLayers().getArray(), subLayer => {
@@ -124,7 +126,7 @@ export function setStyleFunction(def, vectorStyleId, vectorStyles, layer, state)
// Filter Orbit Tracks
if (glStyle.name === 'Orbit Tracks') {
// Filter time by 5 mins
- layer.setStyle(function(feature, resolution) {
+ layer.setStyle(function (feature, resolution) {
var minute;
var minutes = feature.get('label');
if (minutes) {
@@ -138,7 +140,7 @@ export function setStyleFunction(def, vectorStyleId, vectorStyles, layer, state)
((selected[layerId] && selected[layerId].length))) {
const selectedFeatures = selected[layerId];
- layer.setStyle(function(feature, resolution) {
+ layer.setStyle(function (feature, resolution) {
const data = state.config.vectorData[def.vectorData.id];
const properties = data.mvt_properties;
const features = feature.getProperties();
@@ -150,6 +152,15 @@ export function setStyleFunction(def, vectorStyleId, vectorStyles, layer, state)
return styleFunction(feature, resolution);
}
});
+ } else if (day === -1) {
+ layer.setStyle(function (feature, resolution) {
+ console.log(feature)
+ const midpoint = feature.getFlatCoordinates();
+ const extent = layer.getExtent();
+ if (containsCoordinate([-180, -90, -110, 90], midpoint)) {
+ return styleFunction(feature, resolution);
+ }
+ });
}
return vectorStyleId;
}
@@ -194,7 +205,7 @@ export function clearStyleFunction(def, vectorStyleId, vectorStyles, layer, stat
styleFunction = stylefunction(layer, glStyle, vectorStyleId);
if (glStyle.name === 'Orbit Tracks') {
// Filter time by 5 mins
- layer.setStyle(function(feature, resolution) {
+ layer.setStyle(function (feature, resolution) {
var minute;
var minutes = feature.get('label');
if (minutes) {