Browse Source

try/catch extent()

pull/124/head
Peter Johnson 10 years ago
parent
commit
ce96e1274a
  1. 5
      helper/geojsonify.js
  2. 24
      test/unit/helper/geojsonify.js

5
helper/geojsonify.js

@ -62,7 +62,12 @@ function search( docs, params ){
var geojson = GeoJSON.parse( geodata, { Point: ['lat', 'lng'] });
// add bbox
try {
geojson.bbox = extent( geojson ) || undefined;
} catch( e ){
console.error( 'bbox error', e.message, e.stack );
console.error( 'geojson', JSON.stringify( geojson, null, 2 ) );
}
return geojson;
}

24
test/unit/helper/geojsonify.js

@ -11,6 +11,30 @@ module.exports.tests.interface = function(test, common) {
});
};
// ref: https://github.com/pelias/pelias/issues/84
module.exports.tests.earth = function(test, common) {
var earth = [{
'_type': 'geoname',
'_id': '6295630',
'name': {
'default': 'Earth'
},
'center_point': {
'lon': 0,
'lat': 0
}
}];
test('earth', function(t) {
t.doesNotThrow(function(){
geojsonify.search( earth, { details: true } );
});
t.end();
});
};
module.exports.tests.search = function(test, common) {
var input = [

Loading…
Cancel
Save