Skip to content

Commit

Permalink
feat: Merge pull request #409 from pelias/airport_codes
Browse files Browse the repository at this point in the history
Index airport codes
  • Loading branch information
orangejulius authored May 3, 2018
2 parents 0706c9f + 1ba3fc0 commit e33c63b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@ language: node_js
notifications:
email: false
node_js:
- 4
- 6
- 8
matrix:
fast_finish: true
env:
global:
- BUILD_LEADER_ID=2
script: npm run travis
before_install:
- npm i -g npm@^3.0.0
- npm i -g npm
before_script:
- npm prune
after_success:
- npm install -g npx
- npx -p node@8 npm run semantic-release
- npm run semantic-release
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"name": "pelias-openstreetmap",
"version": "0.0.0-semantic-release",
"engines": {
"node": ">=6.11.4",
"npm": ">=1.4.3",
"elasticsearch": ">=1.3.4"
},
"author": "mapzen",
"description": "Pelias openstreetmap utilities",
"homepage": "https://github.com/mapzen/pelias-openstreetmap",
Expand Down Expand Up @@ -33,11 +38,6 @@
"bugs": {
"url": "https://github.com/mapzen/pelias-openstreetmap/issues"
},
"engines": {
"node": ">=4.0.0",
"npm": ">=1.4.3",
"elasticsearch": ">=1.3.4"
},
"dependencies": {
"async": "^2.0.0",
"combined-stream": "^1.0.5",
Expand Down
12 changes: 12 additions & 0 deletions stream/tag_mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ module.exports = function(){
}
}
}

// Import airport codes as aliases
if( tags.hasOwnProperty('aerodrome') || tags.hasOwnProperty('aeroway') ){
if( tags.hasOwnProperty('iata') ){
var iata = trim( tags.iata );
if( iata ){
doc.setNameAlias( 'default', iata );
doc.setNameAlias( 'default', `${iata} Airport` );
doc.setPopularity(10000);
}
}
}
}

catch( e ){
Expand Down
16 changes: 16 additions & 0 deletions test/stream/tag_mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@ module.exports.tests.lowercase_keys = function(test, common) {
});
};

module.exports.tests.airport_codes = function(test, common) {
var doc = new Document('a','b',1);
doc.setMeta('tags', { 'name': 'test', 'aerodrome': '', 'iata': 'FOO' });
test('alias - airport codes', function(t) {
var stream = mapper();
stream.pipe( through.obj( function( doc, enc, next ){
t.equal(doc.getName('default'), 'test', 'correctly mapped');
t.deepEqual(doc.getNameAliases('default'), ['FOO', 'FOO Airport'], 'correctly mapped');
t.deepEqual(doc.getPopularity(), 10000);
t.end(); // test will fail if not called (or called twice).
next();
}));
stream.write(doc);
});
};

// ======================== addresses =========================

module.exports.tests.osm_schema = function(test, common) {
Expand Down

0 comments on commit e33c63b

Please sign in to comment.