-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Impact Layers & Refactor App Redux Structure (#55)
This PR adds Impact Layers. It also significantly refactors the layer configuration interface for much better type safety, decent (but not 100% perfect) parsing of the config file for ensuring proper config definitions. It removes Immutable.js state, since redux toolbox is already using Immer.js for state immutability under the hood, and they weren't playing well together. Refactors where state lives by adding concept of layer-specific data in Redux along with async loaders. Adds loading animation.
- Loading branch information
1 parent
c7dd094
commit 69deaec
Showing
42 changed files
with
2,191 additions
and
577 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,5 @@ yarn-error.log* | |
.firebase/ | ||
|
||
# Editors | ||
.vscode/ | ||
.vscode/ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
src/components/MapView/Layers/GroundstationLayer/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, { useEffect } from 'react'; | ||
import { get } from 'lodash'; | ||
import { GeoJSONLayer } from 'react-mapbox-gl'; | ||
import * as MapboxGL from 'mapbox-gl'; | ||
import { useSelector, useDispatch } from 'react-redux'; | ||
import { legendToStops } from '../layer-utils'; | ||
import { GroundstationLayerProps } from '../../../../config/types'; | ||
import { layerDataSelector } from '../../../../context/mapStateSlice'; | ||
import { | ||
LayerData, | ||
loadLayerData, | ||
} from '../../../../context/layers/layer-data'; | ||
|
||
function onClickCircle(evt: any) { | ||
// eslint-disable-next-line | ||
console.log( | ||
get(evt.features[0], 'properties.index'), | ||
get(evt.features[0], 'properties.aimagname'), | ||
get(evt.features[0], 'properties.sumname'), | ||
get(evt.features[0], 'properties.rasterheight'), | ||
); | ||
} | ||
|
||
function GroundstationLayers({ layer }: { layer: GroundstationLayerProps }) { | ||
const layerData = useSelector(layerDataSelector(layer.id)) as | ||
| LayerData<GroundstationLayerProps> | ||
| undefined; | ||
const dispatch = useDispatch(); | ||
|
||
const { data } = layerData || {}; | ||
|
||
useEffect(() => { | ||
if (!data) { | ||
dispatch(loadLayerData({ layer })); | ||
} | ||
}, [data, dispatch, layer]); | ||
|
||
if (!data) { | ||
return null; | ||
} | ||
|
||
const circleLayout: MapboxGL.CircleLayout = { visibility: 'visible' }; | ||
const circlePaint: MapboxGL.CirclePaint = { | ||
'circle-color': { | ||
property: 'rasterheight', | ||
stops: legendToStops(layer.legend), | ||
}, | ||
}; | ||
|
||
return ( | ||
<GeoJSONLayer | ||
data={data} | ||
circleLayout={circleLayout} | ||
circlePaint={circlePaint} | ||
circleOnClick={onClickCircle} | ||
/> | ||
); | ||
} | ||
|
||
export default GroundstationLayers; |
Oops, something went wrong.