Skip to content
NodeJS API Server for serving GeoJSON from Postgres or MySQL spatial tables
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
.gitignore
LICENSE
README.md update doc Dec 30, 2018
index.html
install.bat
newrelic.js
node.msi
package-lock.json nr config Jan 4, 2019
package.json nr config Jan 4, 2019
run.bat
server.js
update.bat

README.md

SQL2GeoJSON API Server

NodeJS API server for serving GeoJSON from Postgres or MySQL spatial tables.

Example Deployment on Heroku

Quick Start

Configuration

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_build_object() and jsonb_agg() for Postgres and JSON_OBJECT() and JSON_ARRAYAGG() for MySQL.

Running the app

Clone this repository and execute run.bat.

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 server.js

// line 269 and 278 of server.js
    ...
    // change shape to your spatial column (eg geom)
    'geometry', ST_AsGeoJSON(shape),
    ...

Author

Sudipto Ghosh

Portfolio: sudipto.ghosh.pro

This app is provided under the MIT License.

You can’t perform that action at this time.