From ee24214aae90c33d7bd234d5dd3015ac3b9e7b20 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 6 May 2015 19:00:09 +0200 Subject: [PATCH] refactor for clarity --- helper/geojsonify.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/helper/geojsonify.js b/helper/geojsonify.js index fc22b06d..ec1e20f6 100644 --- a/helper/geojsonify.js +++ b/helper/geojsonify.js @@ -61,9 +61,14 @@ function search( docs, params ){ // convert to geojson var geojson = GeoJSON.parse( geodata, { Point: ['lat', 'lng'] }); - // add bbox + // bounding box calculations + // @note: extent() sometimes throws Errors for unusual data + // eg: https://github.com/pelias/pelias/issues/84 try { - geojson.bbox = extent( geojson ) || undefined; + var bbox = extent( geojson ); + if( !!bbox ){ + geojson.bbox = bbox; + } } catch( e ){ console.error( 'bbox error', e.message, e.stack ); console.error( 'geojson', JSON.stringify( geojson, null, 2 ) );