Browse Source

updated labelGeneration special case so that region-specific logic only applies to US/CA

pull/461/head
Stephen Hess 9 years ago
parent
commit
fd0718a699
  1. 21
      helper/labelGenerator.js

21
helper/labelGenerator.js

@ -4,6 +4,8 @@ var _ = require('lodash'),
module.exports = function( record ){ module.exports = function( record ){
var schema = getSchema(record.country_a); var schema = getSchema(record.country_a);
console.log(schema);
var labelParts = getInitialLabel(record); var labelParts = getInitialLabel(record);
for (var key in schema) { for (var key in schema) {
@ -47,11 +49,28 @@ function getSchema(country_a) {
} }
// helper function that sets a default label for non-US/CA regions
// this is a very special case
function getInitialLabel(record) { function getInitialLabel(record) {
if ('region' === record.layer && ('geonames' === record.source || 'whosonfirst' === record.source)) { if (isRegion(record.layer) &&
isGeonamesOrWhosOnFirst(record.source) &&
isUSAOrCAN(record.country_a)) {
return []; return [];
} }
return [record.name]; return [record.name];
} }
function isRegion(layer) {
return 'region' === layer;
}
function isUSAOrCAN(country_a) {
return 'USA' === country_a || 'CAN' === country_a;
}
function isGeonamesOrWhosOnFirst(source) {
return 'geonames' === source || 'whosonfirst' === source;
}

Loading…
Cancel
Save