-
Notifications
You must be signed in to change notification settings - Fork 1
How to do it (locally) ?
Ayoub FATIHI edited this page Feb 28, 2022
·
1 revision
You can use the code from this repo, but ensure you have :
- Postgres and postgis with a populated database
- Nodejs with pg, express and body-parser packages installed
See below for details.
For the back end, we will be using nodejs
for the server language and postgresql
for our database because it supports PostGIS
extension.
- Install
Postgresql
from here - Activate PostGIS by running
CREATE EXTENSION postgis;
- Populate your databse
-
Install nodejs from here.
-
Init your project by running and complete setup:
npm init
- Install from
terminal
(PowerShell or cmd for Windows, bash,...) the needednpm
packages :
npm install pg
npm install express
npm install body-parser
- Setup connection by changing
connections.js
parameters to your personal ones. - Run to launch your app by running:
node index.js
-
Enjoy your app at :
http://localhost:3000/
. -
For these spatial queries please fetch the geometry as
GeoJSON
and alias geom as:ST_AsGeoJSON(geom) AS geom
-
Try like this query (maroc table needed to be in your db):
SELECT id, ST_AsGeoJSON(geom) AS geom FROM maroc