Skip to content

Commit

Permalink
feat(aliases): support for mapping tags to name.default aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
missinglink committed Jun 26, 2018
1 parent 32bd5d0 commit 82a6fb2
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"undef": true,
"unused": false,
"maxparams": 4,
"maxdepth": 4,
"maxdepth": 5,
"maxlen": 140
}
16 changes: 13 additions & 3 deletions schema/name_osm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,25 @@

var OSM_NAMING_SCHEMA = {
'name': 'default',
'loc_name': 'local',
'alt_name': 'alternative',
'loc_name': 'default',
'alt_name': 'default',
'int_name': 'international',
'nat_name': 'national',
'official_name': 'official',
'old_name': 'old',
'reg_name': 'regional',
'short_name': 'short',
'short_name': 'default',
'sorting_name': 'sorting'
};

// this property is considered the 'primary name'
// for label generation, the others are considered
// secondary or 'aliases'.
Object.defineProperty(OSM_NAMING_SCHEMA, '_primary', {
value: 'name',
enumerable: false,
configurable: false,
writable: false
});

module.exports = OSM_NAMING_SCHEMA;
8 changes: 7 additions & 1 deletion stream/tag_mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ module.exports = function(){
else if( tag in NAME_SCHEMA ){
var val2 = trim( tags[tag] );
if( val2 ){
doc.setName( NAME_SCHEMA[tag], val2 );
if( tag === NAME_SCHEMA._primary ){
doc.setName( NAME_SCHEMA[tag], val2 );
} else if ( 'default' === NAME_SCHEMA[tag] ) {
doc.setNameAlias( NAME_SCHEMA[tag], val2 );
} else {
doc.setName( NAME_SCHEMA[tag], val2 );
}
}
}

Expand Down
Loading

0 comments on commit 82a6fb2

Please sign in to comment.