Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add vector legends #2144

Benjamin King8be53e7fb609
diff --git a/config/default/common/config/wv.json/layers/vector/GRUMP_Settlements_v1.01_STD.json b/config/default/common/config/wv.json/layers/vector/GRUMP_Settlements_v1.01_STD.json
index 3432aa43b..ce95c4188 100644
--- a/config/default/common/config/wv.json/layers/vector/GRUMP_Settlements_v1.01_STD.json
+++ b/config/default/common/config/wv.json/layers/vector/GRUMP_Settlements_v1.01_STD.json
@@ -17,6 +17,10 @@
"vectorStyle": {
"id": "GRUMP_Settlements_v1.01_STD"
},
+ "palette": {
+ "id": "GRUMP_Settlements",
+ "immutable": true
+ },
"period": "daily"
}
}
diff --git a/config/default/common/config/wv.json/layers/vector/GRanD_Dams_v1.01_STD.json b/config/default/common/config/wv.json/layers/vector/GRanD_Dams_v1.01_STD.json
index b33553e66..17e709986 100644
--- a/config/default/common/config/wv.json/layers/vector/GRanD_Dams_v1.01_STD.json
+++ b/config/default/common/config/wv.json/layers/vector/GRanD_Dams_v1.01_STD.json
@@ -12,6 +12,12 @@
"layergroup": [
"vector"
],
+ "palette": {
+ "id": "GRanD_Dams",
+ "immutable": true,
+ "styleProperty": "MAIN_USE",
+ "unclassified": "Not Classified"
+ },
"uniqueIdenitifier": "GRAND_ID",
"inactive": true,
"vectorStyle": {
diff --git a/config/default/common/config/wv.json/layers/vector/GRanD_Reservoirs_v1.01_STD.json b/config/default/common/config/wv.json/layers/vector/GRanD_Reservoirs_v1.01_STD.json
index c72215713..adef3e484 100644
--- a/config/default/common/config/wv.json/layers/vector/GRanD_Reservoirs_v1.01_STD.json
+++ b/config/default/common/config/wv.json/layers/vector/GRanD_Reservoirs_v1.01_STD.json
@@ -17,6 +17,10 @@
"vectorStyle": {
"id": "GRanD_Reservoirs_v1.01_STD"
},
+ "palette": {
+ "id": "GRanD_Reservoirs",
+ "immutable": true
+ },
"period": "daily"
}
}
diff --git a/config/default/common/config/wv.json/layers/vector/Nuclear_Power_Plant_Locations_v1_STD.json b/config/default/common/config/wv.json/layers/vector/Nuclear_Power_Plant_Locations_v1_STD.json
index 46a2f6998..f31ad25fa 100644
--- a/config/default/common/config/wv.json/layers/vector/Nuclear_Power_Plant_Locations_v1_STD.json
+++ b/config/default/common/config/wv.json/layers/vector/Nuclear_Power_Plant_Locations_v1_STD.json
@@ -17,6 +17,10 @@
"vectorStyle": {
"id": "Nuclear_Power_Plant_Locations_v1_STD"
},
+ "palette": {
+ "id": "Nuclear_Power_Plant_Locations",
+ "immutable": true
+ },
"period": "daily"
}
}
diff --git a/web/js/components/layer/settings/settings.js b/web/js/components/layer/settings/settings.js
index a05c25561..519d2d405 100644
--- a/web/js/components/layer/settings/settings.js
+++ b/web/js/components/layer/settings/settings.js
@@ -256,7 +256,7 @@ class LayerSettings extends React.Component {
? this.renderCustomPalettes()
: '';
} else {
- renderCustomizations = this.renderVectorStyles();
+ renderCustomizations = '' // this.renderVectorStyles(); for future
}
if (!layer.id) return '';
diff --git a/web/js/components/map/ol-coordinates.js b/web/js/components/map/ol-coordinates.js
index 951a94fd5..c6e683f85 100644
--- a/web/js/components/map/ol-coordinates.js
+++ b/web/js/components/map/ol-coordinates.js
@@ -36,7 +36,7 @@ class OlCoordinates extends React.Component {
}
mouseClick(e, map) {
- const pixels = map.getEventPixel(e)
+ const pixels = e.pixel;
const { lastSelected, openVectorDiaglog, selectVectorFeatures, modalStateId, getDialogObject } = this.props;
const clickObj = getDialogObject(pixels, map);
const metaArray = clickObj.metaArray || [];
diff --git a/web/js/map/runningdata.js b/web/js/map/runningdata.js
index cee9a6f37..07f16170b 100644
--- a/web/js/map/runningdata.js
+++ b/web/js/map/runningdata.js
@@ -18,7 +18,7 @@ export function MapRunningData(models, compareUi, store) {
/**
* Clear running data value
*/
- self.clearAll = function() {
+ self.clearAll = function () {
if (!lodashIsEmpty(dataObj)) {
dataObj = {};
store.dispatch(clearRunningDataAction());
@@ -31,7 +31,7 @@ export function MapRunningData(models, compareUi, store) {
* @param {Array} coords | Coordinates of hover point
* @param {Object} layerAttributes | Layer Properties
*/
- var isFromActiveCompareRegion = function(map, coords, layerAttributes) {
+ var isFromActiveCompareRegion = function (map, coords, layerAttributes) {
var compareModel = store.getState().compare;
if (compareModel && compareModel.active) {
if (compareModel.mode !== 'swipe') {
@@ -65,22 +65,45 @@ export function MapRunningData(models, compareUi, store) {
* @return {Void}
*
*/
- self.newPoint = function(coords, map) {
+ self.newPoint = function (coords, map) {
const state = store.getState();
+ const vectorStyles = state.config.vectorStyles;
var activeLayerObj = {};
- map.forEachLayerAtPixel(coords, function(layer, data) {
+ map.forEachFeatureAtPixel(coords, (feature, layer) => {
+ if (!layer.wv || !layer.wv.def) return;
+ let color;
+ const def = layer.wv.def;
+ const identifier = def.palette.styleProperty;
+ const layerId = def.id;
+ const paletteLegends = getPalette(layerId, undefined, undefined, state);
+ const legend = paletteLegends.legend;
+
+ if (!identifier && legend.colors.length > 1) return
+ if (identifier) {
+ const properties = feature.getProperties();
+ const value = properties[identifier] || def.palette.unclassified;
+ if (!value) return;
+ const tooltips = legend.tooltips.map(function (c) { return c.toLowerCase().replace(/\s/g, ''); });
+ const colorIndex = tooltips.indexOf(value.toLowerCase().replace(/\s/g, ''));
+ color = legend.colors[colorIndex];
+ } else if (legend.colors.length === 1) {
+ color = legend.colors[0];
+ }
+ activeLayerObj[layerId] = { paletteLegends: paletteLegends, paletteHex: color };
+ })
+ map.forEachLayerAtPixel(coords, function (layer, data) {
+
+ if (!layer.wv) return;
var paletteHex;
var paletteLegends;
var layerId;
- if (!layer.wv) {
- return;
- }
+ const def = layer.wv.def;
if (!isFromActiveCompareRegion(map, coords, layer.wv)) return;
if (
- layer.wv.def.palette &&
+ (def.palette) &&
!lodashGet(layer, 'wv.def.disableHoverValue')
) {
- layerId = layer.wv.id;
+ layerId = def.id;
paletteLegends = getPalette(layerId, undefined, undefined, state);
paletteHex = util.rgbaToHex(data[0], data[1], data[2], data[3]);
activeLayerObj[layerId] = { paletteLegends: paletteLegends, paletteHex: paletteHex };