+ geojson plugins

This commit is contained in:
tix 2017-02-06 17:10:14 +08:00
parent 843fe2f8e0
commit c9fa6709c2
3 changed files with 20 additions and 0 deletions

1
app.js
View File

@ -7,6 +7,7 @@ var bodyParser = require('body-parser');
var ejs = require('ejs');
var fs = require('fs');
if (process.env.NODE_ENV == '' || process.env.NODE_ENV == undefined) {
process.env.NODE_ENV = 'development'
} else {

View File

@ -14,6 +14,7 @@
"ejs": "~2.5.2",
"express": "~4.14.0",
"express-promise": "^0.4.0",
"geojson": "^0.4.1",
"jquery": "^2.2.4",
"morgan": "~1.7.0",
"pg": "^6.1.2",

View File

@ -1,3 +1,5 @@
var GeoJSON = require('geojson');
var express = require('express');
var router = express.Router();
@ -40,5 +42,21 @@ router.get('/gis/:tab_name', function (req, res, next) {
.catch(function (err) { res.status(500).send(err) });
});
router.get('/gis/geojson/:tab_name', function (req, res, next) {
var tab_name = req.params.tab_name;
models_gis.getAll(tab_name)
.then(function (data) {
GeoJSON.parse(data, {
Point: ['latitude', 'longitude'],
exclude: ['gid', 'id', 'the_geom']
}, function (geojson) {
res.json(geojson)
});
})
.catch(function (err) { res.status(500).send(err) });
});
module.exports = router;