diff --git a/content/study/posts/kenya.yml b/content/study/posts/kenya.yml
index e8a6560..bd67534 100644
--- a/content/study/posts/kenya.yml
+++ b/content/study/posts/kenya.yml
@@ -14,7 +14,7 @@ platform:
layers:
- id: 11kv
name: Existing grid 11kv
- category: contextual
+ category: input
mbLayer: 11kv
info: This dataset contains electricity transmission lines with different voltage levels as well as unidentified voltage in Kenya. The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
@@ -22,7 +22,7 @@ layers:
url: https://energydata.info/dataset/kenya-kenya-electricity-network
- id: 33kv
name: Existing grid 33kv
- category: contextual
+ category: input
mbLayer: 33kv
info: This dataset contains electricity transmission lines with different voltage levels as well as unidentified voltage in Kenya. The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
@@ -30,7 +30,7 @@ layers:
url: https://energydata.info/dataset/kenya-kenya-electricity-network
- id: 66kv
name: Existing grid 66kv
- category: contextual
+ category: input
mbLayer: 66kv
info: This dataset contains electricity transmission lines with different voltage levels as well as unidentified voltage in Kenya. The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
@@ -38,7 +38,7 @@ layers:
url: https://energydata.info/dataset/kenya-kenya-electricity-network
- id: 132kv
name: Existing grid 132kv
- category: contextual
+ category: input
mbLayer: 132kv
info: This dataset contains electricity transmission lines with different voltage levels as well as unidentified voltage in Kenya. The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
@@ -46,7 +46,7 @@ layers:
url: https://energydata.info/dataset/kenya-kenya-electricity-network
- id: 220kv
name: Existing grid 220kv
- category: contextual
+ category: input
mbLayer: 220kv
info: This dataset contains electricity transmission lines with different voltage levels as well as unidentified voltage in Kenya. The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
@@ -54,7 +54,7 @@ layers:
url: https://energydata.info/dataset/kenya-kenya-electricity-network
- id: transformers
name: Distribution Transformers
- category: contextual
+ category: input
mbLayer: transformers
info: The dataset contains Distribution Transformers in Kenya.The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
@@ -62,7 +62,7 @@ layers:
url: https://energydata.info/dataset/kenya-distribution-transformers
- id: substations
name: Primary Substations
- category: contextual
+ category: input
mbLayer: substation
info: The dataset contains primary substations in Kenya. The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
@@ -70,7 +70,7 @@ layers:
url: https://energydata.info/dataset/kenya-primary-substations
- id: transmission
name: Transmission Stations
- category: contextual
+ category: input
mbLayer: transmission-stations
info: The data contains transmission station locations in Kenya. The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
@@ -78,7 +78,7 @@ layers:
url: https://energydata.info/dataset/kenya-transmission-stations
- id: power
name: Power Stations
- category: contextual
+ category: input
disabled: true
mbLayer: 11kv
info: The dataset contains location of Power Stations in Kenya. It was provided by Kenya Power and Lighting Company (KPLC).
@@ -87,7 +87,7 @@ layers:
url: https://energydata.info/dataset/kenya-power-stations
- id: population
name: Population and Household Dataset (2009 & 2016)
- category: contextual
+ category: input
disabled: true
mbLayer: 11kv
info: Population and Household statistics for the years 2009 and 2016 as well as the enumeration areas.The dataset was provided by Kenya National Bureau of Statistics (KNBS).
@@ -96,7 +96,7 @@ layers:
url: https://energydata.info/dataset/kenya-population-and-household-dataset
- id: roads
name: Roads
- category: contextual
+ category: input
mbLayer: roads
info: Road network in Kenya. The dataset was provided by Kenya Roads Board (KRB).
source:
@@ -104,7 +104,7 @@ layers:
url: https://energydata.info/dataset/kenya-roads-1
- id: health
name: Healthcare Facilities
- category: contextual
+ category: input
disabled: true
mbLayer: 11kv
info: Data on healthcare facility locations in Kenya. The dataset was provided by the Government of Kenya.
@@ -113,7 +113,7 @@ layers:
url: https://energydata.info/dataset/kenya-healthcare-facilities
- id: education
name: Schools
- category: contextual
+ category: input
mbLayer: education
info: School locations in Kenya. It comprises Primary and Secondary Schools. The dataset was provided by Kenya Ministry of Education.
source:
@@ -121,7 +121,7 @@ layers:
url: https://energydata.info/dataset/kenya-schools
- id: minigrid
name: Overview of Off-Grid Electricity Service Areas
- category: result
+ category: outcome
mbLayer: minigrid
visible: true
info: This dataset represents the locations of existing mini-grids, mini-grids under development, proposed KOSAP mini-grids, and potential SHS markets in Kenya. This is the output of preliminary GIS analysis funded by the World Bank and undertaken in 2017.
@@ -130,7 +130,7 @@ layers:
url: https://energydata.info/dataset/kenya-overview-of-off-grid-electricity-service-areas
- id: grid-expansion
name: Grid Expansion Projects
- category: result
+ category: outcome
disabled: true
mbLayer: 11kv
info: This dataset represents potential grid expansion projects identified through a least-cost geospatial analysis undertaken over the period 2017-2018.
@@ -139,7 +139,7 @@ layers:
url: https://energydata.info/dataset/kenya-grid-expansion
- id: minigrid-expansion
name: Existing Mini-Grid Expansion Projects
- category: result
+ category: outcome
mbLayer: minigrid-existing
visible: true
info: Potential expansion projects for existing mini-grids; the expansion projects were identified through a least-cost geospatial analysis undertaken over the period 2017-2018.
@@ -148,7 +148,7 @@ layers:
url: https://energydata.info/dataset/kenya-potential-expansion-of-existing-mini-grids
- id: minigrid-new
name: New Mini-Grid Projects
- category: result
+ category: outcome
mbLayer: minigrid-proposed
visible: true
info: Potential mini-grid projects; these projects were identified through a least-cost geospatial analysis undertaken over the period 2017-2018.
@@ -157,9 +157,22 @@ layers:
url: https://energydata.info/dataset/kenya-potential-new-mini-grid-sites
- id: wind
name: Mean wind speed
- category: contextual
+ category: input
mbLayer: wind
info: The mean wind speed is a measure of the wind resource. Higher mean wind speeds normally indicate better wind resources, but mean wind power density gives a more accurate indication of the available wind resource.
source:
name: Global Wind Atlas
- url: https://globalwindatlas.info/
\ No newline at end of file
+ url: https://globalwindatlas.info/
+ legendData:
+ type: gradient
+ min: '< 2.5'
+ max: '> 9.75 m/s'
+ stops:
+ - '#BEE6FA'
+ - '#488FC6'
+ - '#7BC34C'
+ - '#F9E65B'
+ - '#F56E2B'
+ - '#C82333'
+ - '#A3305C'
+
\ No newline at end of file
diff --git a/docs/README.md b/docs/README.md
index 84ce341..b0d9491 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -50,6 +50,14 @@ The main information and metadata of each study is managed through a `yml` file,
| layers[].source | `object` | Link to the data source |
| layers[].source.name | `string` | Name of the source link |
| layers[].source.url | `string` | URL of the data source |
+| layers[].legendData | `object` | Custom legend |
+| layers[].legendData.type | `enum` one of [`gradient`, `line`, `circle`, `symbol`] | Type of legend |
+| layers[].legendData.color | `string` | The color of the feature. Applies to `circle` and `line` |
+| layers[].legendData.dashed | `boolean` | Use a dashed line. Applies to `line` |
+| layers[].legendData.icon | `string` | The basename of the icon, without file extension. Applies to `symbol` |
+| layers[].legendData.min | `string` | Minimum value printed on the x-axis. Applies to `gradient` |
+| layers[].legendData.max | `string` | Maximum value printed on the x-axis. Applies to `gradient`
+| layers[].legendData.stops | `array` | An array with RGB colors that indicate the stops. Applies to `gradient`
## Map configuration
The map of each study is configured using a `json` file that follows the Mapbox Style specification. For a full example, please see [`kenya-mb.json`](/content/study/posts/kenya-mb.json).
@@ -166,6 +174,55 @@ New icons can be added to [`/content/icons`](/content/icons). They should be in
[To top](#managing-studies)
+
+# Legends
+Broadly speaking, AEP supports two types of legends: symbology for features on the map like circles and lines and gradient legends for raster data like the Global Wind Atlas.
+
+## Customizing vector legends
+The platform will automatically determine the legend for vector layers. It's possible to override these defaults by specifying a `legendData` object on the layer configuration. For example:
+
+### Line
+![](media/line-legend.png)
+
+``` yml
+legendData:
+ type: line
+ color: '#00FF00'
+ dashed: true
+```
+
+### Symbol
+![](media/symbol-legend.png)
+
+``` yml
+legendData:
+ type: symbol
+ color: 'electricity'
+```
+
+## Defining raster legends
+The legend for external data layers can't be automatically determined by AEP and always have to be defined through configuration. The platform currently supports linear gradients, below is an example with 7 color stops.
+
+![](media/wind-legend.png)
+
+
+``` yml
+legendData:
+ type: gradient
+ min: '< 2.5'
+ max: '> 9.75 m/s'
+ stops:
+ - '#BEE6FA'
+ - '#488FC6'
+ - '#7BC34C'
+ - '#F9E65B'
+ - '#F56E2B'
+ - '#C82333'
+ - '#A3305C'
+```
+
+[To top](#managing-studies)
+
# Troubleshooting
## Map shows an unexpected layer
If the map loads with a layer that can't be managed through the layer switcher, it's likely that you added a layer in the Mapbox Style that isn't referenced in the layer configuration of the `yml`. This is by design. It allows you to overlay a contextual layer on the map that the user don't have control over. A use case could be a layer that adds a disputed border.
diff --git a/docs/media/line-legend.png b/docs/media/line-legend.png
new file mode 100644
index 0000000..581d9d2
Binary files /dev/null and b/docs/media/line-legend.png differ
diff --git a/docs/media/symbol-legend.png b/docs/media/symbol-legend.png
new file mode 100644
index 0000000..89dc601
Binary files /dev/null and b/docs/media/symbol-legend.png differ
diff --git a/docs/media/wind-legend.png b/docs/media/wind-legend.png
new file mode 100644
index 0000000..eee576c
Binary files /dev/null and b/docs/media/wind-legend.png differ
diff --git a/gatsby-node.js b/gatsby-node.js
index 03ce810..1ef52da 100644
--- a/gatsby-node.js
+++ b/gatsby-node.js
@@ -6,6 +6,16 @@ exports.createSchemaCustomization = ({ actions, schema }) => {
const typeDefs = [
`
+ type LayerLegend {
+ type: String
+ min: String
+ max: String
+ stops: [String]
+ color: String
+ icon: String
+ dashed: Boolean
+ }
+
type PanelLayerSource {
name: String
url: String
@@ -19,6 +29,7 @@ exports.createSchemaCustomization = ({ actions, schema }) => {
mbLayer: String
info: String
source: PanelLayerSource
+ legendData: LayerLegend
}
type Platform {
diff --git a/schema/validate.js b/schema/validate.js
index 5bda386..9e9b0e4 100644
--- a/schema/validate.js
+++ b/schema/validate.js
@@ -7,9 +7,8 @@ const mbValidator = require('@mapbox/mapbox-gl-style-spec');
const Schema = require('validate');
const yml = require('js-yaml');
-const fileExists = (val) => {
- return fs.existsSync(path.join(__dirname, '../content/study/posts/', val));
-};
+const studyFileExists = (val) =>
+ fs.existsSync(path.join(__dirname, '../content/study/posts/', val));
const studySchema = new Schema({
title: { type: String, required: true },
@@ -24,7 +23,7 @@ const studySchema = new Schema({
]
],
zoomExtent: [{ type: Number }, { type: Number }],
- mapConfig: { type: String, use: { fileExists }, required: true },
+ mapConfig: { type: String, use: { studyFileExists }, required: true },
study: {
consultant: { type: String, required: true },
period: { required: true },
@@ -41,7 +40,7 @@ const studySchema = new Schema({
name: { type: String, required: true },
category: {
type: String,
- enum: ['contextual', 'result'],
+ enum: ['input', 'outcome'],
required: true
},
visible: { type: Boolean },
@@ -51,6 +50,18 @@ const studySchema = new Schema({
source: {
name: { type: String, required: true },
url: { type: String, required: true }
+ },
+ legendData: {
+ type: {
+ type: String,
+ enum: ['gradient', 'line', 'circle', 'symbol']
+ },
+ color: { type: String, match: /^#[0-9a-fA-F]{6}$/ },
+ dashed: { type: Boolean },
+ icon: { type: String },
+ min: { type: String },
+ max: { type: String },
+ stops: [{ type: String, match: /^#[0-9a-fA-F]{6}$/ }]
}
}
]
diff --git a/src/components/burger-options.js b/src/components/burger-options.js
new file mode 100644
index 0000000..30fc07e
--- /dev/null
+++ b/src/components/burger-options.js
@@ -0,0 +1,78 @@
+import React from 'react';
+import T from 'prop-types';
+import styled from 'styled-components';
+import { Button } from '@devseed-ui/button';
+import Dropdown, {
+ DropTitle,
+ DropMenu,
+ DropMenuItem
+} from '@devseed-ui/dropdown';
+import { themeVal, glsp } from '@devseed-ui/theme-provider';
+import collecticon from '@devseed-ui/collecticons';
+
+import { Link } from '../styles/clean/link';
+
+// TODO: Remove once ui library is updated.
+const DropMenuItemLink = styled(DropMenuItem)`
+ &.active {
+ color: ${themeVal('color.primary')};
+
+ &::after {
+ ${collecticon('tick--small')}
+ position: absolute;
+ z-index: 1;
+ top: ${glsp(1 / 4)};
+ right: ${glsp(1 / 2)};
+ font-size: 1rem;
+ line-height: 1.5rem;
+ width: 1.5rem;
+ text-align: center;
+ }
+ }
+`;
+
+function BurgerOptions(props) {
+ const { items } = props;
+
+ return (
+ (
+
+ )}
+ >
+ Browse
+
+ {items.map((l) => (
+