Skip to content

Commit

Permalink
Merge pull request #420 from NASA-IMPACT/develop
Browse files Browse the repository at this point in the history
Deploy v1.6.0
  • Loading branch information
olafveerman authored Sep 29, 2020
2 parents 8ef47e8 + d21c6d9 commit 15e564c
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 18 deletions.
47 changes: 36 additions & 11 deletions app/assets/scripts/components/common/layers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import population from './layer-population';
import nightlightsViirs from './layer-nightlights-viirs';
import nightlightsHd from './layer-nightlights-hd';
import detectionShip from './layer-detection-ship';
import recovery from './layer-recovery';
import slowdown from './layer-slowdown';
import waterChlorophyll from './layer-water-chlorophyll';
import waterSpm from './layer-water-spm';
import agriculture from './layer-agriculture';
import detectionPlane from './layer-detection-plane';
import agTogo from './layer-togo-ag';

const layers = [
Expand All @@ -23,29 +25,36 @@ const layers = [
nightlightsViirs,
nightlightsHd,
detectionShip,
recovery,
slowdown,
waterChlorophyll,
waterSpm,
agriculture,
detectionPlane,
agTogo
];

export default layers;

const layersBySpotlight = {
be: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown'],
du: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown'],
gh: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown'],
la: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'agriculture', 'slowdown', 'detection-ship'],
sf: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'agriculture', 'slowdown', 'detection-ship', 'water-chlorophyll', 'water-spm'],
tk: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs'],
ny: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown', 'detection-ship', 'water-chlorophyll', 'water-spm'],
be: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown', 'recovery', 'detection-plane'],
du: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown', 'recovery'],
gh: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown', 'recovery'],
la: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'agriculture', 'slowdown', 'detection-ship', 'detection-plane', 'recovery'],
sf: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'agriculture', 'slowdown', 'recovery', 'detection-ship', 'detection-plane', 'water-chlorophyll', 'water-spm'],
tk: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'recovery', 'detection-plane'],
ny: ['no2', 'no2-diff', 'co2', 'co2-diff', 'nightlights-hd', 'nightlights-viirs', 'slowdown', 'detection-ship', 'detection-plane', 'water-chlorophyll', 'water-spm', 'recovery'],
togo: ['togo-ag']
};

const layerOverridesBySpotlight = {
be: {
'nightlights-viirs': handleNightlightsViirs
'nightlights-viirs': handleNightlightsViirs,
'detection-plane': (l, spotlightId) =>
handleInferenceTimeseries(l, spotlightId, {
domain: ['2020-01-09', '2020-01-12', '2020-01-14', '2020-02-10', '2020-02-18', '2020-03-12', '2020-03-13', '2020-03-19', '2020-04-11', '2020-05-05', '2020-05-14']
})

},
du: {
'nightlights-viirs': handleNightlightsViirs
Expand All @@ -62,6 +71,10 @@ const layerOverridesBySpotlight = {
'detection-ship': (l, spotlightId) =>
handleInferenceTimeseries(l, spotlightId, {
domain: ['2020-01-22', '2020-02-02', '2020-02-03', '2020-02-27', '2020-02-29', '2020-03-03', '2020-03-08', '2020-03-15', '2020-03-21', '2020-03-22', '2020-03-27', '2020-04-23', '2020-04-24']
}),
'detection-plane': (l, spotlightId) =>
handleInferenceTimeseries(l, spotlightId, {
domain: ['2020-01-10', '2020-01-14', '2020-02-01', '2020-02-03', '2020-03-22', '2020-04-15', '2020-04-21', '2020-05-04', '2020-05-05']
})
},
sf: {
Expand All @@ -81,7 +94,11 @@ const layerOverridesBySpotlight = {
...l,
domain: ['2020-03-02', '2020-04-03', '2020-04-19', '2020-05-04', '2020-05-05', '2020-05-21', '2020-05-24', '2020-05-28', '2020-06-01', '2020-06-03', '2020-06-06', '2020-06-13', '2020-06-21', '2020-06-22', '2020-06-23', '2020-06-25', '2020-06-28', '2020-07-01', '2020-07-03']
};
}
},
'detection-plane': (l, spotlightId) =>
handleInferenceTimeseries(l, spotlightId, {
domain: ['2020-01-11', '2020-01-12', '2020-01-13', '2020-02-06', '2020-02-07', '2020-02-10', '2020-02-15', '2020-02-18', '2020-02-20', '2020-03-09', '2020-03-10', '2020-03-12', '2020-03-19', '2020-04-02', '2020-04-03', '2020-04-07', '2020-04-15', '2020-04-22', '2020-05-04', '2020-05-05', '2020-05-07', '2020-05-19']
})
},
tk: {
'nightlights-viirs': handleNightlightsViirs,
Expand All @@ -94,7 +111,11 @@ const layerOverridesBySpotlight = {
tiles: l.source.tiles.map(t => t.replace('&rescale=-100%2C100', ''))
}
};
}
},
'detection-plane': (l, spotlightId) =>
handleInferenceTimeseries(l, spotlightId, {
domain: ['2020-01-19', '2020-02-01', '2020-02-05', '2020-03-18', '2020-03-19', '2020-04-09', '2020-04-10', '2020-05-02']
})
},
ny: {
'nightlights-viirs': handleNightlightsViirs,
Expand All @@ -120,7 +141,11 @@ const layerOverridesBySpotlight = {
// For NY, nightlights goes till June
domain: [l.domain[0], '2020-06-01']
};
}
},
'detection-plane': (l, spotlightId) =>
handleInferenceTimeseries(l, spotlightId, {
domain: ['2020-01-16', '2020-01-20', '2020-02-17', '2020-02-19', '2020-03-09', '2020-03-15', '2020-04-06', '2020-04-15', '2020-05-05', '2020-05-14']
})
}
};

Expand Down
4 changes: 2 additions & 2 deletions app/assets/scripts/components/common/layers/layer-co2-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export default {
timeUnit: 'day',
domain: [
'2020-01-01',
'2020-05-17'
'2020-07-16'
],
source: {
type: 'raster',
tiles: [
`${config.api}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/xco2/xco2_15day_diff.{date}.tif&resampling_method=bilinear&bidx=1&rescale=-0.000001%2C0.000001&color_map=rdbu_r`
`${config.api}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/xco2-diff/xco2_16day_diff.{date}.tif&resampling_method=bilinear&bidx=1&rescale=-0.000001%2C0.000001&color_map=rdbu_r`
]
},
exclusiveWith: ['agriculture', 'no2', 'no2-diff', 'co2', 'gibs-population', 'car-count', 'nightlights-viirs', 'nightlights-hd', 'detection-ship', 'detection-multi', 'water-chlorophyll', 'water-spm'],
Expand Down
6 changes: 3 additions & 3 deletions app/assets/scripts/components/common/layers/layer-co2.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export default {
timeUnit: 'day',
domain: [
'2020-01-01',
'2020-05-17'
'2020-07-16'
],
source: {
type: 'raster',
tiles: [
`${config.api}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/xco2/xco2_15day_mean.{date}.tif&resampling_method=bilinear&bidx=1&rescale=0.000408%2C0.000419&color_map=rdylbu_r&color_formula=gamma r {gamma}`
`${config.api}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/xco2-mean/xco2_16day_mean.{date}.tif&resampling_method=bilinear&bidx=1&rescale=0.000408%2C0.000419&color_map=rdylbu_r&color_formula=gamma r {gamma}`

]
},
Expand All @@ -30,7 +30,7 @@ export default {
source: {
type: 'raster',
tiles: [
`${config.api}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/xco2/xco2_15day_base.{date}.tif&resampling_method=bilinear&bidx=1&rescale=0.000408%2C0.000419&color_map=rdylbu_r&color_formula=gamma r {gamma}`
`${config.api}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/xco2-base/xco2_16day_base.{date}.tif&resampling_method=bilinear&bidx=1&rescale=0.000408%2C0.000419&color_map=rdylbu_r&color_formula=gamma r {gamma}`
]
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import config from '../../../config';
import { indicatorGroupColors } from '../../../styles/theme/theme';

export default {
id: 'detection-plane',
name: 'Planes',
type: 'inference-timeseries',
domain: [
'2020-01-01',
'2020-04-30'
],
source: {
vector: {
type: 'geojson',
data: `${config.api}/detections/plane/{spotlightId}/{date}.geojson`
},
raster: {
type: 'raster',
tiles: [
`${config.api}/planet/{z}/{x}/{y}?date={date}&site={spotlightId}`
]
}
},
exclusiveWith: ['agriculture', 'no2', 'no2-diff', 'co2-diff', 'co2', 'gibs-population', 'car-count', 'nightlights-viirs', 'nightlights-hd', 'detection-multi', 'water-chlorophyll', 'water-spm'],
enabled: false,
swatch: indicatorGroupColors.economic,
timeUnit: 'day',
info: 'Planes detected each day in PlanetScope imagery are shown in red.'
};
22 changes: 22 additions & 0 deletions app/assets/scripts/components/common/layers/layer-recovery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import config from '../../../config';

import { indicatorGroupColors } from '../../../styles/theme/theme.js';

export default {
id: 'recovery',
name: 'Recovery Proxy Map',
type: 'raster',
source: {
type: 'raster',
tiles: [
`${config.api}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/rpm/rpm-{spotlightId}.cog.tif&resampling_method=bilinear&bidx=1%2C2%2C3%24`
]
},
paint: {
'raster-opacity': 0.9
},
exclusiveWith: ['agriculture', 'co2', 'co2-diff', 'gibs-population', 'car-count', 'nightlights-viirs', 'nightlights-hd', 'detection-ship', 'detection-multi', 'water-chlorophyll', 'water-spm'],
enabled: true,
swatch: indicatorGroupColors.economic,
info: 'Recovery Proxy Maps show areas with the greatest increase in car activity shaded in orange. Darker orange indicates areas of greater change.'
};
12 changes: 11 additions & 1 deletion app/assets/scripts/components/common/layers/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ export const layerTypes = {
const vectorData = vector.data.replace('{date}', formatDate);
const rasterTiles = raster.tiles.map(tile => tile.replace('{date}', formatDate));

// inference data moves around, recenter on each update
fetch(vectorData)
.then(res => res.json())
.then(geo => {
mbMap.fitBounds(bbox(geo));
})
.catch(err => {
console.log(err); // eslint-disable-line no-console
});

replaceVectorData(mbMap, vecId, vectorData);
replaceRasterTiles(mbMap, rastId, rasterTiles);
},
Expand Down Expand Up @@ -262,7 +272,7 @@ export const layerTypes = {
mbMap.fitBounds(bbox(geo));
})
.catch(err => {
throw err;
console.log(err); // eslint-disable-line no-console
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "covid-dashboard",
"version": "1.5.0",
"version": "1.6.0",
"description": "Frontend application for the Covid Dashboard",
"repository": {
"type": "git",
Expand Down

0 comments on commit 15e564c

Please sign in to comment.