diff --git a/helper/labelSchema.js b/helper/labelSchema.js index e1f9921a..1bce7133 100644 --- a/helper/labelSchema.js +++ b/helper/labelSchema.js @@ -2,22 +2,22 @@ var _ = require('lodash'); module.exports = { 'default': { - 'local': getFirstProperty(['locality']), + 'local': getFirstProperty(['locality', 'localadmin']), 'country': getFirstProperty(['country']) }, 'GBR': { - 'local': getFirstProperty(['locality']), + 'local': getFirstProperty(['locality', 'localadmin']), 'regional': getFirstProperty(['macroregion']), 'country': getFirstProperty(['country']) }, 'USA': { 'borough': getFirstProperty(['borough']), - 'local': getFirstProperty(['locality']), + 'local': getFirstProperty(['locality', 'localadmin']), 'regional': getUsOrCaState, 'country': getFirstProperty(['country']) }, 'CAN': { - 'local': getFirstProperty(['locality']), + 'local': getFirstProperty(['locality']), // no localadmins in CAN 'regional': getUsOrCaState, 'country': getFirstProperty(['country']) } diff --git a/test/unit/helper/labelGenerator_GBR.js b/test/unit/helper/labelGenerator_GBR.js index 4b619464..9a774fc7 100644 --- a/test/unit/helper/labelGenerator_GBR.js +++ b/test/unit/helper/labelGenerator_GBR.js @@ -31,6 +31,25 @@ module.exports.tests.united_kingdom = function(test, common) { t.end(); }); + test('localadmin value should be used when locality is not available', function(t) { + var doc = { + 'name': 'venue name', + 'layer': 'venue', + 'housenumber': '1', + 'street': 'Main St', + 'neighbourhood': 'neighbourhood name', + 'localadmin': 'localadmin name', + 'county': 'county name', + 'macrocounty': 'macrocounty name', + 'region': 'region name', + 'macroregion': 'macroregion name', + 'country_a': 'GBR', + 'country': 'United Kingdom' + }; + t.equal(generator(doc),'venue name, localadmin name, macroregion name, United Kingdom'); + t.end(); + }); + test('street', function(t) { var doc = { 'name': 'street address', diff --git a/test/unit/helper/labelGenerator_USA.js b/test/unit/helper/labelGenerator_USA.js index 57e77f32..ecf4f925 100644 --- a/test/unit/helper/labelGenerator_USA.js +++ b/test/unit/helper/labelGenerator_USA.js @@ -31,6 +31,26 @@ module.exports.tests.united_states = function(test, common) { t.end(); }); + test('localadmin value should be used when there is no locality', function(t) { + var doc = { + 'name': 'venue name', + 'layer': 'venue', + 'housenumber': '1', + 'street': 'Main St', + 'neighbourhood': 'neighbourhood name', + 'localadmin': 'localadmin name', + 'county': 'county name', + 'macrocounty': 'macrocounty name', + 'region_a': 'region abbr', + 'region': 'region name', + 'macroregion': 'macroregion name', + 'country_a': 'USA', + 'country': 'United States' + }; + t.equal(generator(doc),'venue name, localadmin name, region abbr, United States'); + t.end(); + }); + test('street', function(t) { var doc = { 'name': '1 Main St', diff --git a/test/unit/helper/labelGenerator_default.js b/test/unit/helper/labelGenerator_default.js index 7645610f..bdde2ac6 100644 --- a/test/unit/helper/labelGenerator_default.js +++ b/test/unit/helper/labelGenerator_default.js @@ -31,6 +31,25 @@ module.exports.tests.default_country = function(test, common) { t.end(); }); + test('localadmin value should be used when locality is not available', function(t) { + var doc = { + 'name': 'venue name', + 'layer': 'venue', + 'housenumber': '1', + 'street': 'Main St', + 'neighbourhood': 'neighbourhood name', + 'localadmin': 'localadmin name', + 'county': 'county name', + 'macrocounty': 'macrocounty name', + 'region': 'region name', + 'macroregion': 'macroregion name', + 'country_a': 'country code', + 'country': 'country name' + }; + t.equal(generator(doc),'venue name, localadmin name, country name'); + t.end(); + }); + test('street', function(t) { var doc = { 'name': 'address',