Browse Source

add geojson bbox

pull/42/head
Peter Johnson 10 years ago
parent
commit
109758b25e
  1. 8
      helper/geojsonify.js
  2. 5
      package.json
  3. 1
      test/unit/helper/geojsonify.js

8
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;
}

5
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",

1
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",

Loading…
Cancel
Save