How to use the pelias-model.codec.decode function in pelias-model

To help you get started, we’ve selected a few pelias-model examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pelias / api / helper / geojsonify.js View on Github external
if (_.has(place, 'name.default')) {
    doc.name = field.getStringValue(place.name.default);
  } else {
    logger.warn(`doc ${doc.gid} does not contain name.default`);
  }

  // assign all the details info into the doc
  Object.assign(doc, collectDetails(params, place));

  // add addendum data if available
  // note: this should be the last assigned property, for aesthetic reasons.
  if (_.has(place, 'addendum')) {
    let addendum = {};
    for(let namespace in place.addendum){
      try {
        addendum[namespace] = codec.decode(place.addendum[namespace]);
      } catch( e ){
        logger.warn(`doc ${doc.gid} failed to decode addendum namespace ${namespace}`);
      }
    }
    if( Object.keys(addendum).length ){
      doc.addendum = addendum;
    }
  }

  return doc;
}