Browse Source

added `localadmin` for USA/GBR/default when `locality` isn't available

pull/497/head
Stephen Hess 9 years ago
parent
commit
c5626d6c5e
  1. 8
      helper/labelSchema.js
  2. 19
      test/unit/helper/labelGenerator_GBR.js
  3. 20
      test/unit/helper/labelGenerator_USA.js
  4. 19
      test/unit/helper/labelGenerator_default.js

8
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'])
}

19
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',

20
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',

19
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',

Loading…
Cancel
Save