Based off of the Vercel Postgres + Prisma Next.js Starter. This utilizes the following tools:
Data is modeled with the following concepts:
To provide data, three files must be provided:
{study_identifier}.xlsx
{study_identifier}.geojson.gz
.md
extension) file describing the content for the study details page[!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
: metadata about the study. Formatted in key, value format.
Name
: Text, required;Description
: Text, required;Image Src
: URL, optional;Details
: Text, optional;Scale
: 'Municipality' or 'Building', required;Geom Key Field
: Text, required; must match a property key present in geometry GeoJSON fileMetrics Key Field
: Text, required; must match a column name present in metrics
tabHighlight
: boolean, optional;metrics
: raw data. The following conditions must be met:
Metrics Key Field
to the value of the geometery's property at the Geom Key Field
.metrics_metadata
:
field_name
: Text, required;description
: Text, required;units
: Text, required;theme
: Text, required;scenario
: Text, required; leave blank to indicate baseline scenariocategory
: Text, required; blank values are interpreted as "all"usage
: Text, required; blank values are interpreted as "all"source
: Text, required; blank values are interpreted as "all"scenarios_metadata
scenario
: Text, required; Identifier for scenariodescription
: Text, required; Description of scenarioFeatureCollection
of Polygon
or MultiPolygon
values.Feature
must contain a unique id
property of either a string or integer.<img src="https://github.com/Dashboard-IN3/tecnico-energy-app/raw/main/.." width="..." alt="..." />
)pnpm install
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.
Seeding the database is the conventional entry to loading data into our application. Run it via:
pnpm prisma db seed
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.
Prisma ships with a Prisma Studio. It can be run via:
pnpm prisma studio
Run Next.js in development mode:
pnpm dev
Deploy it to the cloud with Vercel (Documentation).
pnpm contentlayer build
will pull from the mdx files in the data
directory. The compiled files will overwrite the content in the .contentlayer
directory.