#PostGIS Preview A lightweight node api and frontend for quickly previewing PostGIS queries. Originally pulled from Postgis-Preview
###How it works
The express.js app has a single endpoint: /sql
that is passed a SQL query q
as a url parameter. That query is passed to PostGIS using the pg-promise module. The resulting data are transformed into topojson using a modified dbgeo module (modified to include parsing WKB using the WKX module), and the response is sent to the frontend.
The frontend is a simple Bootstrap layout with a Leaflet map, CartoDB basemaps, a table, and a SQL pane. The TopoJSON from the API is parsed using omnivore by Mapbox, and added to the map as an L.geoJson layer with generic styling.
- Clone this repo
- Have a PostGIS instance running somewhere that the node app can talk to
- Set you enviroment variables, these can be set up on you computer or by setting them in .env.sample and renmaing it .env Its looking for any of the following DATABASE_URL or PGDATABASE, PGPORT, PGUSER, PGHOST see here for more information
- Install dependencies
yarn install
- Run the express app
node server.js
- Load the frontend
http://localhost:4000
- Query like a boss
- You can save and recolour your queries once they have been loaded, this means they can be toggled on/off as needed
- The map tiles can be changed as needed.
- Use the arrows to see your last 25 queries
- Basic heatmapping can be used by clicking on a layer on the map and selecting the property to scale with (only works with numbers)
- PostGIS preview expects your geometry column to be called
geom
, and that it contains WGS84 geometries. See #17 for some discussion on how to allow for other geom column names and SRIDs.