Skip to content

Commit 16650e4

Browse files
authored
Merge pull request #28 from OpenSourceFellows/upstream_merge
Upstream merge
2 parents c4ded60 + c357184 commit 16650e4

21 files changed

Lines changed: 1810 additions & 861 deletions

.docker/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Step 1: Base Image
2-
FROM node:20-alpine
2+
FROM node:24-alpine
33

44
# Step 2: Set Working Directory & Tooling
55
# Allow the workdir to be overridden at build time, default is /app
@@ -14,8 +14,7 @@ COPY package.json pnpm-lock.yaml ${WORKDIR}/
1414

1515
# Step 4: Install Dependencies
1616
RUN corepack enable \
17-
&& corepack prepare pnpm@* --activate \
18-
&& pnpm install --frozen-lockfile
17+
&& pnpm install
1918

2019
# Step 5: Copy Source Code
2120
COPY . ${WORKDIR}/

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
"preview": "vite preview"
2121
},
2222
"dependencies": {
23+
"@emotion/react": "^11.14.0",
24+
"@emotion/styled": "^11.14.1",
25+
"@mui/material": "^7.3.7",
2326
"@turf/turf": "^7.2.0",
2427
"@types/geojson": "^7946.0.16",
2528
"geojson": "^0.5.0",

pnpm-lock.yaml

Lines changed: 540 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
"type": "FeatureCollection",
3+
"name": "Land Project Sites",
4+
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
5+
"features": [
6+
{
7+
"type": "Feature",
8+
"geometry": {
9+
"type": "Point",
10+
"coordinates": [-122.3546373, 47.5609785]
11+
},
12+
"properties": {
13+
"partners": ["Duwamish", "Snohomish"],
14+
"identifier": "Duwamish Longhouse",
15+
"watershedRegion": "17 Pacific Northwest",
16+
"measurement": 11,
17+
"unitOfMeasure": "acre",
18+
"restorationServices": ["Agroforestry", "BioChar Application", "Reforestation"]
19+
}
20+
},
21+
{
22+
"type": "Feature",
23+
"geometry": {
24+
"type": "Point",
25+
"coordinates": [-121.4825272, 36.7127724]
26+
},
27+
"properties": {
28+
"partners": ["Ramaytush", "Ohlone"],
29+
"identifier": "Pescadero Creek",
30+
"watershedRegion": "18 California",
31+
"measurement": 100,
32+
"unitOfMeasure": "acre",
33+
"restorationServices": ["Meadow Rewilding", "BioChar Application", "Stream Restoration"]
34+
}
35+
},
36+
{
37+
"type": "Feature",
38+
"geometry": {
39+
"type": "Point",
40+
"coordinates": [-113.6140818, 34.698916]
41+
},
42+
"properties": {
43+
"partners": ["Hualapai"],
44+
"identifier": "Ha'Kamwe'",
45+
"watershedRegion": "15 Lower Colorado",
46+
"measurement": 360,
47+
"unitOfMeasure": "acre",
48+
"restorationServices": []
49+
}
50+
},
51+
{
52+
"type": "Feature",
53+
"geometry": {
54+
"type": "Point",
55+
"coordinates": [-120.459190, 37.665729]
56+
},
57+
"properties": {
58+
"partners": ["Karuk", "Yosemite Rivers Alliance"],
59+
"identifier": "Tuolomne River",
60+
"watershedRegion": "18 California",
61+
"measurement": 23915,
62+
"unitOfMeasure": "acre",
63+
"restorationServices": ["Tule Restoration", "Wetland Regeneration"]
64+
}
65+
},
66+
{
67+
"type": "Feature",
68+
"geometry": {
69+
"type": "Point",
70+
"coordinates": [-122.9048793, 38.1236419]
71+
},
72+
"properties": {
73+
"partners": ["Coastal Miwok"],
74+
"identifier": "Tomales Bay",
75+
"watershedRegion": "18 California",
76+
"measurement": 71000,
77+
"unitOfMeasure": "acre",
78+
"restorationServices": []
79+
}
80+
},
81+
{
82+
"type": "Feature",
83+
"geometry": {
84+
"type": "Point",
85+
"coordinates": [-109.7174679, 37.1973456]
86+
},
87+
"properties": {
88+
"partners": ["Ute Mountain Ute"],
89+
"identifier": "Tez Naz Iah",
90+
"watershedRegion": "14 Upper Colorado",
91+
"measurement": 597000,
92+
"unitOfMeasure": "acre",
93+
"restorationServices": []
94+
}
95+
},
96+
{
97+
"type": "Feature",
98+
"geometry": {
99+
"type": "Point",
100+
"coordinates": [-95.624954, 34.283149]
101+
},
102+
"properties": {
103+
"partners": ["Chickasaw", "Choctaw"],
104+
"identifier": "Kiamichi River",
105+
"watershedRegion": "11 Arkansas-White-Red",
106+
"measurement": 1163670,
107+
"unitOfMeasure": "acre",
108+
"restorationServices": []
109+
}
110+
},
111+
{
112+
"type": "Feature",
113+
"geometry": {
114+
"type": "Point",
115+
"coordinates": [-109.9049502, 37.2181153]
116+
},
117+
"properties": {
118+
"partners": ["Chickasaw", "Choctaw"],
119+
"identifier": "Bears Ears National Monument",
120+
"watershedRegion": "14 Upper Colorado",
121+
"measurement": 1360000,
122+
"unitOfMeasure": "acre",
123+
"restorationServices": ["Agroforestry", "BioChar Application", "Invasive Plants Removal"]
124+
}
125+
}
126+
]
127+
}
File renamed without changes.
File renamed without changes.

public/fixtures/amazonia_river_networks.geojson renamed to public/fixtures_old/fixtures/amazonia_river_networks.geojson

File renamed without changes.
File renamed without changes.

public/fixtures/manaus_neighborhood_boundaries.geojson renamed to public/fixtures_old/fixtures/manaus_neighborhood_boundaries.geojson

File renamed without changes.

src/App.tsx

Lines changed: 96 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,117 @@
1-
import { useEffect, useState } from 'react';
1+
import { useEffect, useState, type JSX } from 'react';
22
import { Header } from '@/components/Layout/Header';
33
import { MapContainer } from '@/components/Map/MapContainer';
4-
import { MapLegend } from '@/components/Map/MapLegend';
54
import { LayerControls } from '@/components/Map/LayerControls';
6-
import '@/styles/globals.css';
7-
import '@/styles/map.css';
5+
import { Box } from '@mui/material';
6+
import { GlobalStyles, useTheme } from '@mui/material';
7+
import '@/styles/reset.css';
8+
import '@/styles/palette-layouts.css';
9+
import '@/styles/components.css';
810
import { FixtureReader } from './data/fixture-reader';
911
import type { LayerVisibilityMap } from './types/map';
1012
import type { FeatureCollection } from './types/geometry';
1113

14+
1215
/**
13-
* Main application component that composes the entire UI
14-
* Manages the map state and renders the map with its controls
16+
* Main application component that composes the entire UI.
17+
* Manages the map state and renders the map with its controls.
18+
* Map uses GeoJSON (docs) => https://geojson.readthedocs.io/en/latest/
1519
* @component
16-
* @returns {JSX.Element} The complete application layout with header and map interface
20+
* @returns {JSX.Element} The complete application layout with header and map interface.
1721
*/
18-
function App() {
22+
function App(): JSX.Element {
23+
24+
/*
25+
* layers: an array of map feature collections (initially empty)
26+
* - FeatureCollection items contain geo-spatial types (points, lines, polygons) with coordinates
27+
* setLayers: function to update the layers array, based on previous state
28+
*/
1929
const [layers, setLayers] = useState<FeatureCollection[]>([])
30+
31+
32+
/*
33+
* layerVisibility: an object mapping each layer name to a boolean indicating whether it is visible on the map
34+
* - Keys are layer names (strings)
35+
* - Values are booleans (true = visible, false = hidden)
36+
* setLayerVisibility: function to update the visibility map, based on previous state
37+
*/
2038
const [layerVisibility, setLayerVisibility] = useState<LayerVisibilityMap>({})
2139

40+
41+
/* Access the current MUI theme (light/dark mode) */
42+
const theme = useTheme();
43+
44+
45+
/* Load map feature collections once on component mount */
2246
useEffect(() => {
23-
FixtureReader.collections()
24-
.then(collections => {
25-
setLayers([...collections])
47+
48+
async function loadCollections() {
49+
50+
/* Fetch feature collections and save layers to state */
51+
const collections: FeatureCollection[] = await FixtureReader.collections();
52+
const allLayers = [... collections];
53+
setLayers(allLayers);
54+
55+
/* Extract layer names */
56+
const layerNames = allLayers.map((layer) => layer.name);
57+
58+
/* Build initial visibility map */
59+
const initialVisibility: LayerVisibilityMap = layerNames.reduce(
60+
(map, name) => {
61+
map[name] = true;
62+
return map;
63+
},
64+
{} as LayerVisibilityMap
65+
);
2666

27-
// Take the name property of each collection and set it's initial visibility to true
28-
const layerNames = collections.map((fc) => fc.name )
29-
const visibilityMap = layerNames.reduce((map, name) => { map[name] = true; return map }, {} as LayerVisibilityMap)
30-
setLayerVisibility({...visibilityMap})
31-
},)
32-
}, [])
67+
/* Save visibility map to state */
68+
setLayerVisibility(initialVisibility);
69+
}
3370

34-
const layersToRender = layers.filter((fc) => layerVisibility[fc.name])
71+
loadCollections();
72+
},
73+
[] // dependency array
74+
)
75+
76+
/* Logic to only render layers with visibility of `true` */
77+
const layersToRender = layers.filter((layer) => layerVisibility[layer.name])
3578

3679
return (
37-
<div className="app-container">
38-
<Header />
39-
<main className="main-content">
40-
<MapContainer layers={layersToRender} />
41-
{/*<MapLegend />*/}
42-
<LayerControls
43-
visibilityMap={layerVisibility}
44-
onLayerChange={setLayerVisibility}
45-
/>
46-
</main>
47-
</div>
80+
<>
81+
<GlobalStyles
82+
styles={{
83+
'.app-wrapper': {
84+
background: theme.palette.background.paper,
85+
boxShadow: 'var(--box-shadow)',
86+
},
87+
}}
88+
/>
89+
90+
<Box
91+
className="app-wrapper flex-column"
92+
sx={{
93+
height: '100vh',
94+
}}
95+
>
96+
<Header />
97+
<Box
98+
component="main"
99+
className="main-wrapper"
100+
sx={{
101+
flex: 1,
102+
position: 'relative',
103+
overflow: 'hidden',
104+
}}
105+
>
106+
<MapContainer layers={layersToRender} />
107+
{/*<MapLegend />*/}
108+
<LayerControls
109+
visibilityMap={layerVisibility}
110+
onLayerChange={setLayerVisibility}
111+
/>
112+
</Box>
113+
</Box>
114+
</>
48115
);
49116
}
50117

0 commit comments

Comments
 (0)