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
11 changes: 3 additions & 8 deletions labelSchema.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
var _ = require('lodash');
const _ = require('lodash');
const removeAccents = require('remove-accents');

// lowercase characters and remove some punctuation
function normalizeString(str){
if (!str) {
return '';
}
if (!str) { return ''; }
return removeAccents(str.toLowerCase().split(/[ ,-]+/).join(' '));
}

Expand All @@ -21,11 +19,8 @@ function getFirstProperty(fields) {
if (!_.isEmpty(fieldValue)) {
return fieldValue[0];
}

}

};

}

// this function is exclusively used for figuring out which field to use for states/provinces
Expand Down Expand Up @@ -235,7 +230,7 @@ module.exports = {
},
'FRA': {
'valueFunctions': {
'local': getFirstProperty(['locality', 'localadmin']),
'local': getFirstProperty(['locality', 'localadmin', 'county', 'macrocounty']),
'country': getFRACountryValue()
}
},
Expand Down
33 changes: 32 additions & 1 deletion test/labelGenerator_FRA.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports.tests.interface = function(test, common) {
});
};

module.exports.tests.united_kingdom = function(test, common) {
module.exports.tests.france = function(test, common) {
test('venue', function(t) {
var doc = {
'name': { 'default': 'venue name' },
Expand Down Expand Up @@ -378,6 +378,37 @@ module.exports.tests.united_kingdom = function(test, common) {
t.end();
});

test('postalcode with locality', function(t) {
var doc = {
'name': { 'default': '69001' },
'layer': 'postalcode',
'locality': ['Lyon'],
'county': ['Metropolitan Lyon'],
'macrocounty': ['Lyon'],
'region': ['Rhône'],
'macroregion': ['Auvergne-Rhone-Alpes'],
'country_a': ['FRA'],
'country': ['France']
};
t.equal(generator(doc),'69001, Lyon, France');
t.end();
});

test('postalcode without locality or localadmin', function(t) {
var doc = {
'name': { 'default': '13080' },
'layer': 'postalcode',
'county': ['Aix-en-Provence Canton'],
'macrocounty': ['Aix-En-Provence'],
'region': ['Bouches-du-Rhône'],
'macroregion': ['Provence-Alpes-Cote d\'Azur'],
'country_a': ['FRA'],
'country': ['France']
};
t.equal(generator(doc),'13080, Aix-en-Provence Canton, France');
t.end();
});

};

module.exports.all = function (tape, common) {
Expand Down