Dashboard-IN3 / tecnico-energy-app

https://dashboard-ds-peach.vercel.app/
1 stars 0 forks source link

Técnico Application

Based off of the Vercel Postgres + Prisma Next.js Starter. This utilizes the following tools:

Data Submission

Data is modeled with the following concepts:

To provide data, three files must be provided:

  1. A XLSX spreadsheet file for a study, named {study_identifier}.xlsx
  2. A gzipped GeoJSON file containing geometries associated with the study, named {study_identifier}.geojson.gz
  3. A MDX (with a .md extension) file describing the content for the study details page

Study Spreadsheet

[!TIP] A template for a study spreadsheet can be downloaded here.

The study spreadsheet must contain the following worksheets. Column/key names are case insensitive and asterisks are removed prior to ingestion. Coumns/keys with that contain "ignore" are ignored.

Study Geometries

Study Details Markdown

Development

Install

pnpm install

Setup database

To do a quick and dirty setup of our dev db (not using migrations):

# Push our DB schema to database
pnpm prisma db push

See Schema prototyping with db push for more information.

Load data

Seeding

Seeding the database is the conventional entry to loading data into our application. Run it via:

pnpm prisma db seed

Data Model

terminology

entity relationsip diagram

Buildings

To turn our Shapefile of buildings (shapefile.shp) in EPSG:32729 into a GeoJSON in EPSG:4326:

ogr2ogr -f GeoJSON -s_srs EPSG:32729 -t_srs EPSG:4326 buildings.geojson shapefile.shp

To insert these records into our local database:

# Convert our geojson to a CSV of building name, geometry, & properties (without building name) and pipe to postgres database
cat data/buildings.geojson | jq -r '.features[] | .properties.Name + ";" + (.geometry | tojson) + ";" + (del(.properties.Name) | .properties | tojson)' | psql tecnico -c "copy buildings from stdin (delimiter ';');"

You should see something like COPY 5193 as output.

Exploring data

Prisma ships with a Prisma Studio. It can be run via:

pnpm prisma studio

Running the Application

Run Next.js in development mode:

pnpm dev

Deploy it to the cloud with Vercel (Documentation).

Previewing Compiled Markdown content