Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions labelGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ function dedupeNameAndFirstLabelElement(labelParts) {
return labelParts;
}

function getLanguage(language) {
if (!_.isString(language)) { return; }

return language.toUpperCase();
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this block was unused

// this can go away once geonames is no longer supported
// https://github.com/pelias/wof-admin-lookup/issues/49
function isCountry(layer) {
Expand Down
22 changes: 15 additions & 7 deletions labelSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,22 @@ module.exports = {
}
},
'KOR': {
'valueFunctions': {
'country': getFirstProperty(['country']),
'province': getFirstProperty(['region']),
'city': getFirstProperty(['county'])
'languages': {
'KOR': {
'valueFunctions': {
'country': getFirstProperty(['country']),
'province': getFirstProperty(['region']),
'city': getFirstProperty(['county'])
},
'meta': {
'separator': ' ',
'builder': require('./builders/KOR')
}
}
},
'meta': {
'separator': ' ',
'builder': require('./builders/KOR')
'valueFunctions': {
'city': getFirstProperty(['locality', 'localadmin', 'region']),
'country': getFirstProperty(['country'])
}
},
'FRA': {
Expand Down
89 changes: 79 additions & 10 deletions test/labelGenerator_KOR.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports.tests.south_korea = function(test, common) {
'country_a': ['KOR'],
'country': ['South Korea']
};
t.equal(generator(doc),'South Korea region name county name venue name');
t.equal(generator(doc, 'kor'),'South Korea region name county name venue name');
t.end();
});

Expand All @@ -41,7 +41,7 @@ module.exports.tests.south_korea = function(test, common) {
'country_a': ['KOR'],
'country': ['South Korea']
};
t.equal(generator(doc),'South Korea region name county name street name 123');
t.equal(generator(doc, 'kor'),'South Korea region name county name street name 123');
t.end();
});

Expand All @@ -58,7 +58,7 @@ module.exports.tests.south_korea = function(test, common) {
'country_a': ['KOR'],
'country': ['South Korea']
};
t.equal(generator(doc),'South Korea region name county name street name 123');
t.equal(generator(doc, 'kor'),'South Korea region name county name street name 123');
t.end();
});

Expand All @@ -74,7 +74,7 @@ module.exports.tests.south_korea = function(test, common) {
'country_a': ['KOR'],
'country': ['South Korea']
};
t.equal(generator(doc),'South Korea region name county name neighbourhood name');
t.equal(generator(doc, 'kor'),'South Korea region name county name neighbourhood name');
t.end();
});

Expand All @@ -89,7 +89,7 @@ module.exports.tests.south_korea = function(test, common) {
'country_a': ['KOR'],
'country': ['South Korea']
};
t.equal(generator(doc),'South Korea region name county name locality name');
t.equal(generator(doc, 'kor'),'South Korea region name county name locality name');
t.end();
});

Expand All @@ -103,7 +103,7 @@ module.exports.tests.south_korea = function(test, common) {
'country_a': ['KOR'],
'country': ['South Korea']
};
t.equal(generator(doc),'South Korea region name county name localadmin name');
t.equal(generator(doc, 'kor'),'South Korea region name county name localadmin name');
t.end();
});

Expand All @@ -116,7 +116,7 @@ module.exports.tests.south_korea = function(test, common) {
'country_a': ['KOR'],
'country': ['South Korea']
};
t.equal(generator(doc),'South Korea region name county name');
t.equal(generator(doc, 'kor'),'South Korea region name county name');
t.end();
});

Expand All @@ -128,7 +128,7 @@ module.exports.tests.south_korea = function(test, common) {
'country_a': ['KOR'],
'country': ['South Korea']
};
t.equal(generator(doc),'South Korea region name');
t.equal(generator(doc, 'kor'),'South Korea region name');
t.end();
});

Expand All @@ -139,7 +139,7 @@ module.exports.tests.south_korea = function(test, common) {
'country_a': ['KOR'],
'country': ['South Korea']
};
t.equal(generator(doc),'South Korea');
t.equal(generator(doc, 'kor'),'South Korea');
t.end();
});

Expand All @@ -159,7 +159,76 @@ module.exports.tests.south_korea = function(test, common) {
'street': '모세로',
'country': ['한국']
};
t.equal(generator(doc),'한국 서울 용산구 모세로 27');
t.equal(generator(doc, 'kor'),'한국 서울 용산구 모세로 27');
t.end();
});
};

// when the requested language is english, fields are returned in the order
// specified by the default generator.
module.exports.tests.south_korea_lang_venue_eng = function(test, common) {
test('venue', function(t) {
var doc = {
'name': { 'default': 'venue name' },
'layer': 'venue',
'housenumber': 'house number',
'street': 'street name',
'neighbourhood': ['neighbourhood name'],
'localadmin': ['localadmin name'],
'county': ['county name'],
'macrocounty': ['macrocounty name'],
'region_a': ['region abbr'],
'region': ['region name'],
'macroregion': ['macroregion name'],
'country_a': ['KOR'],
'country': ['South Korea']
};
t.equal(generator(doc, 'eng'),'venue name, localadmin name, South Korea');
t.end();
});
};

// when the requested language is unspecified, fields are returned in the order
// specified by the default generator.
module.exports.tests.south_korea_venue_lang_default = function(test, common) {
test('venue', function(t) {
var doc = {
'name': { 'default': 'venue name' },
'layer': 'venue',
'housenumber': 'house number',
'street': 'street name',
'neighbourhood': ['neighbourhood name'],
'localadmin': ['localadmin name'],
'county': ['county name'],
'macrocounty': ['macrocounty name'],
'region_a': ['region abbr'],
'region': ['region name'],
'macroregion': ['macroregion name'],
'country_a': ['KOR'],
'country': ['South Korea']
};
t.equal(generator(doc),'venue name, localadmin name, South Korea');
t.end();
});
};

// when the requested language is unspecified, fields are returned in the order
// specified by the default generator.
module.exports.tests.south_korea_admin_lang_default = function(test, common) {
test('venue', function(t) {
var doc = {
'name': { 'default': 'locality name' },
'layer': 'locality',
'locality': ['locality name'],
'county': ['county name'],
'macrocounty': ['macrocounty name'],
'region_a': ['region abbr'],
'region': ['region name'],
'macroregion': ['macroregion name'],
'country_a': ['KOR'],
'country': ['South Korea']
};
t.equal(generator(doc), 'locality name, South Korea');
t.end();
});
};
Expand Down