SQL2GeoJSON API Server
NodeJS API server for serving GeoJSON from Postgres or MySQL spatial tables.
Example Deployment on Heroku
You must have NodeJS installed on your system.
You should ideally have PostgreSQL v9.4+ or MySQL v5.7+ as the queries used use certain functions such as
jsonb_agg() for Postgres and
JSON_ARRAYAGG() for MySQL.
Running the app
Clone this repository and execute
run.bat # you will be prompted for the connection details # add ?ssl=true to the DB Nameif your db server # requires SSL > npm start Server listening on port 5000 # port can be changed on line 7 or 334 of server.js
For a working example, import the inscluded ESRI shapefiles into your geodatabase.
Note: Postgres uses geom as the geometry column while MySQL seems to use shape column for the same. If you have your spatial data on geom in a MySQL database, do the following edit in
// line 269 and 278 of server.js ... // change shape to your spatial column (eg geom) 'geometry', ST_AsGeoJSON(shape), ...
This app is provided under the MIT License.