Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ lib/data/spatial/forest_types_tg
lib/data/spatial/forest_types_vd
lib/data/spatial/forest_types_zh
lib/data/spatial/forest_types_zh_2
lib/data/spatial/forest_types_union
lib/data/spatial/silver_fir_areas
lib/data/spatial/cantonal_boundaries.zip
lib/data/spatial/*.zip
Expand Down
6 changes: 3 additions & 3 deletions lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ This library provides tree recommendations for different climate change scenario

Data for tree type projections is provided as a [CSV file](./data/projections.csv) and needs to be converted into JSON to be usable by the library.

1. Install NodeJS, pnpm and Docker Compose.
1. Install NodeJS, pnpm, vercel CLI and Docker Compose.
2. Install dependencies: `pnpm install`
4. Stop postgres if it is already running: `sudo service postgresql stop`
5. Run transformation: `pnpm run data:transform`
3. Stop postgres if it is already running: `sudo service postgresql stop`
4. Run transformation: `pnpm run data:transform`

### NaiS

Expand Down
5 changes: 4 additions & 1 deletion lib/data/db/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ ENV POSTGIS_MAJOR 3

# Install JRE and PostGIS
RUN apt-get update && \
apt-get install -y openjdk-17-jre postgis postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR && \
apt-get install -y \
default-jre \
postgis \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR && \
rm -rf /var/lib/apt/lists/*

# Set up a default database with PostGIS enabled
Expand Down
34 changes: 17 additions & 17 deletions lib/data/docker-start.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
start=`date +%s`
set -e

docker-compose up -d --build
docker-compose exec -T db sh -c 'rm -rf /data/export/*'
docker compose up -d --build
docker compose exec -T db sh -c 'rm -rf /data/export/*'
sleep 10 # wait for database to be running
node ./ecogram/process.mjs
docker-compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/import_data.sql'
docker-compose exec -T db sh -c 'bash /data/spatial/1-import.sh'
docker compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/import_data.sql'
docker compose exec -T db sh -c 'bash /data/spatial/1-import.sh'
bash ./spatial/spatial-data-check.sh
docker-compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/export_projections.sql'
docker-compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/export_types.sql'
docker-compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/lu_export_types.sql'
docker-compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/bl_export_types.sql'
docker-compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/so_export_types.sql'
docker-compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/export_vegetation.sql'
docker-compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/export_recommendations.sql'
docker-compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/export_locations.sql'
docker-compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/export_ecograms.sql'
docker-compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/export_spatial.sql'
docker-compose exec -T db sh -c "pg_dump tree -n export -U postgres > /data/export/tree.dump"
docker-compose exec -T db sh -c "sed 's/export\.//' -i ./pg2sqlite/tree.dump" # Very hacky but unfortunately necessary https://github.com/caiiiycuk/postgresql-to-sqlite?tab=readme-ov-file#tips
docker-compose exec -T db sh -c 'java -jar pg2sqlite-1.1.1.jar -d ./pg2sqlite/tree.dump -o ./pg2sqlite/tree.sqlite -f true'
docker compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/export_projections.sql'
docker compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/export_types.sql'
docker compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/lu_export_types.sql'
docker compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/bl_export_types.sql'
docker compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/so_export_types.sql'
docker compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/export_vegetation.sql'
docker compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/export_recommendations.sql'
docker compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/export_locations.sql'
docker compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/export_ecograms.sql'
docker compose exec -T db sh -c 'psql -U postgres -d tree -a -f /data/sql/export_spatial.sql'
docker compose exec -T db sh -c "pg_dump tree -n export -U postgres > /data/export/tree.dump"
docker compose exec -T db sh -c "sed 's/export\.//' -i ./pg2sqlite/tree.dump" # Very hacky but unfortunately necessary https://github.com/caiiiycuk/postgresql-to-sqlite?tab=readme-ov-file#tips
docker compose exec -T db sh -c 'java -jar pg2sqlite-1.1.1.jar -d ./pg2sqlite/tree.dump -o ./pg2sqlite/tree.sqlite -f true'
cp export/tree.sqlite ../../public/data/tree.sqlite

end=`date +%s`
Expand Down
1 change: 0 additions & 1 deletion lib/data/nais/NAT_ARTEN_MSTR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3195,7 +3195,6 @@ SISF_NR; ART_NAM_LAT; ART_NAM_DEU; ART_NAM_FRZ; ART_NAM_ITA; ART_SCHICHT_BS_S; A
293300;Pastinaca pratensis;Gewöhnlicher Pastinak;Panais cultivé;;0;0;0;0;0;1;0;0;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;;;t4k4l4f2.5w2r4n3h3d1;2.2 2.5 6.3 7.5;;;;
293400;Pastinaca sylvestris;Wilder Pastinak;Panais sauvage;Pastinaca selvatica;0;0;0;0;0;1;0;0;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;;;t4.5k2l4f2.5w2r4n3h3d1;2.1 2.2 2.4 9.2;;;;
293500;Pastinaca urens;Brennender Pastinak;Panais brûlant;;0;0;0;0;0;1;0;0;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;;;t4.5k2l3f3w3r4n4h3d1;2.2 2.5 6.3 7.5;;;;
293550;Paulownia tomentosa;Blauglockenbaum;Paulownia;Paulownia;0;1;0;0;0;1;0;0;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;;;t5k2l3f3w1r3n3h3d3;2.2 2.9 3.2 3.5;;;;
293600;Pedicularis acaulis;Stengelloses Läusekraut;;;0;0;0;0;0;1;0;0;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;;;t2.5k3l3f3.5w1r4n2h3d3;2.6 6.2 6.3 7.4;;;;
293700;Pedicularis ascendens;Aufsteigendes Läusekraut;Pédiculaire ascendante;Pedicolare di Barrelier;0;0;0;0;0;1;0;0;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;;;t1.5k3l4f2.5w1r5n2h3d3;6,5;;;;
293800;Pedicularis aspleniifolia;Farnblättriges Läusekraut;Pédiculaire à feuilles de capillaire;Pedicolare dei ghiaioni;0;0;0;0;0;1;0;0;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;9;;;t1k2l5f3w1r4n2h1d5;3.3 6.5;;;;
Expand Down
Loading