diff --git a/helper/geojsonify.js b/helper/geojsonify.js index 79356516..ad67296c 100644 --- a/helper/geojsonify.js +++ b/helper/geojsonify.js @@ -3,8 +3,9 @@ const GeoJSON = require('geojson'); const extent = require('@mapbox/geojson-extent'); const logger = require('pelias-logger').get('geojsonify'); const addDetails = require('./geojsonify_place_details'); -const addMetaData = require('./geojsonify_meta_data'); +// const addMetaData = require('./geojsonify_meta_data'); const _ = require('lodash'); +const Document = require('pelias-model').Document; function geojsonifyPlaces( params, docs ){ @@ -41,7 +42,16 @@ function geojsonifyPlaces( params, docs ){ function geojsonifyPlace(params, place) { const output = {}; - addMetaData(place, output); + output.id = place._id; + output.gid = new Document(place.source, place.layer, place._id).getGid(); + output.layer = place.layer; + output.source = place.source; + output.source_id = place.source_id; + if (place.hasOwnProperty('bounding_box')) { + output.bounding_box = place.bounding_box; + } + + // addMetaData(place, output); addName(place, output); addDetails(params, place, output); diff --git a/helper/geojsonify_meta_data.js b/helper/geojsonify_meta_data.js deleted file mode 100644 index 7fdf0394..00000000 --- a/helper/geojsonify_meta_data.js +++ /dev/null @@ -1,42 +0,0 @@ -var Document = require('pelias-model').Document; - -/** - * Determine and set place id, type, and source - * - * @param {object} src - * @param {object} dst - */ -function addMetaData(src, dst) { - dst.id = src._id; - dst.gid = makeGid(src); - dst.layer = lookupLayer(src); - dst.source = lookupSource(src); - dst.source_id = lookupSourceId(src); - if (src.hasOwnProperty('bounding_box')) { - dst.bounding_box = src.bounding_box; - } -} - -/** - * Create a gid from a document - * - * @param {object} src - */ -function makeGid(src) { - var doc = new Document(lookupSource(src), lookupLayer(src), src._id); - return doc.getGid(); -} - -function lookupSource(src) { - return src.source; -} - -function lookupSourceId(src) { - return src.source_id; -} - -function lookupLayer(src) { - return src.layer; -} - -module.exports = addMetaData; \ No newline at end of file