Browse Source

inlined geojsonify_meta_data since it's pretty simple

pull/1002/head
Stephen Hess 7 years ago
parent
commit
20bf53ef0a
  1. 14
      helper/geojsonify.js
  2. 42
      helper/geojsonify_meta_data.js

14
helper/geojsonify.js

@ -3,8 +3,9 @@ const GeoJSON = require('geojson');
const extent = require('@mapbox/geojson-extent'); const extent = require('@mapbox/geojson-extent');
const logger = require('pelias-logger').get('geojsonify'); const logger = require('pelias-logger').get('geojsonify');
const addDetails = require('./geojsonify_place_details'); const addDetails = require('./geojsonify_place_details');
const addMetaData = require('./geojsonify_meta_data'); // const addMetaData = require('./geojsonify_meta_data');
const _ = require('lodash'); const _ = require('lodash');
const Document = require('pelias-model').Document;
function geojsonifyPlaces( params, docs ){ function geojsonifyPlaces( params, docs ){
@ -41,7 +42,16 @@ function geojsonifyPlaces( params, docs ){
function geojsonifyPlace(params, place) { function geojsonifyPlace(params, place) {
const output = {}; 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); addName(place, output);
addDetails(params, place, output); addDetails(params, place, output);

42
helper/geojsonify_meta_data.js

@ -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;
Loading…
Cancel
Save