diff --git a/helper/geojsonify.js b/helper/geojsonify.js index 630f12be..eadd61d1 100644 --- a/helper/geojsonify.js +++ b/helper/geojsonify.js @@ -1,5 +1,6 @@ var GeoJSON = require('geojson'), + extent = require('geojson-extent'), outputGenerator = require('./outputGenerator'); function search( docs ){ @@ -54,7 +55,12 @@ function search( docs ){ }); // convert to geojson - return GeoJSON.parse( geodata, { Point: ['lat', 'lng'] } ); + var geojson = GeoJSON.parse( geodata, { + Point: ['lat', 'lng'] + }); + + geojson.bbox = extent( geojson ) || undefined; + return geojson; } diff --git a/package.json b/package.json index aacccf89..6ef30cc1 100644 --- a/package.json +++ b/package.json @@ -32,12 +32,13 @@ "elasticsearch": ">=1.2.1" }, "dependencies": { + "async": "^0.9.0", "express": "^4.8.8", "geojson": "^0.2.0", + "geojson-extent": "^0.3.1", "geopipes-elasticsearch-backend": "0.0.8", "pelias-esclient": "0.0.25", - "toobusy": "^0.2.4", - "async": "^0.9.0" + "toobusy": "^0.2.4" }, "devDependencies": { "ciao": "^0.3.4", diff --git a/test/unit/helper/geojsonify.js b/test/unit/helper/geojsonify.js index 27bb8b31..f08490c7 100644 --- a/test/unit/helper/geojsonify.js +++ b/test/unit/helper/geojsonify.js @@ -83,6 +83,7 @@ module.exports.tests.search = function(test, common) { var expected = { "type": "FeatureCollection", + "bbox": [ -0.1069716, 51.517806, -0.101795, 51.5337144 ], "features": [ { "type": "Feature",