+ geojson plugins
This commit is contained in:
parent
843fe2f8e0
commit
c9fa6709c2
1
app.js
1
app.js
|
@ -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 {
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue