diff --git a/helper/geojsonify.js b/helper/geojsonify.js index 92b17b2f..107c19c2 100644 --- a/helper/geojsonify.js +++ b/helper/geojsonify.js @@ -105,8 +105,7 @@ function addBBoxPerFeature(geojson) { * @returns {Array} */ function extractExtentPoints(geodata) { - const extentPoints = []; - geodata.forEach(function (place) { + return geodata.reduce((extentPoints, place) => { if (place.bounding_box) { extentPoints.push({ lng: place.bounding_box.min_lon, @@ -116,16 +115,19 @@ function extractExtentPoints(geodata) { lng: place.bounding_box.max_lon, lat: place.bounding_box.max_lat }); + } else { extentPoints.push({ lng: place.lng, lat: place.lat }); + } - }); + return extentPoints; + + }, []); - return extentPoints; } /**