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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
!/data/specialCases.json
/metadata/*
!/metadata/category_mapping.json
!/metadata/popularity_mapping.json
18 changes: 15 additions & 3 deletions lib/streams/peliasDocGenerator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var Document = require( 'pelias-model' ).Document;
var logger = require( 'pelias-logger' ).get( 'geonames' );
var categoryMapping = require( '../../metadata/category_mapping.json' );
var popularityMapping = require( '../../metadata/popularity_mapping.json' );
var through2 = require('through2');

// common name delimiters
Expand Down Expand Up @@ -45,16 +46,27 @@ module.exports.create = function() {
}
} catch( err ){}

if( typeof data.feature_code === 'string' ){
record.setMeta( 'fcode', data.feature_code );
if( typeof data.feature_code === 'string' && data.feature_code.length > 0 ){
const featureCode = data.feature_code.toUpperCase().trim();
record.setMeta( 'fcode', featureCode );

var featureCode = data.feature_code.toUpperCase();
// store the feature code in the addendum
record.setAddendum('geonames', {
feature_code: featureCode
});

// map feature code to pelias categories
if( categoryMapping.hasOwnProperty( featureCode ) ){
var peliasCategories = categoryMapping[ featureCode ];
peliasCategories.forEach( function ( category ){
record.addCategory( category );
});
}

// map feature code to pelias popularity score
if( popularityMapping.hasOwnProperty( featureCode ) ){
record.setPopularity( popularityMapping[ featureCode ] );
}
}

} catch( e ){
Expand Down
4 changes: 4 additions & 0 deletions metadata/popularity_mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"HSTS": 5000,
"RLG": 5000
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"pelias-config": "^4.12.0",
"pelias-dbclient": "^2.13.0",
"pelias-logger": "^1.4.1",
"pelias-model": "^7.1.0",
"pelias-model": "^9.0.0",
"pelias-wof-admin-lookup": "^7.3.0",
"request": "^2.34.0",
"through2": "^3.0.0",
Expand Down
Loading