-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Merge pull request #143 from pelias/refactor-for-layer-fallbacks
BREAKING CHANGE: Refactor for layer fallbacks, no longer calls every layer on lookup
- Loading branch information
Showing
19 changed files
with
1,516 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ node_modules | |
|
||
# Webstorm IDE files | ||
.idea | ||
|
||
wof-*-data.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const filter = require('through2-filter'); | ||
const _ = require('lodash'); | ||
const logger = require('pelias-logger').get('wof-pip-service:filterOutCitylessNeighbourhoods'); | ||
|
||
// This filter stream returns false when wof:placetype = neighbourhood AND | ||
// wof:hierarchy lacks both locality_id AND localadmin_id | ||
// returns true otherwise | ||
// | ||
// It's needed because there are some unfortunate important WOF neighbourhoods | ||
// that are currently incomplete | ||
module.exports.create = function create() { | ||
return filter.obj(wofData => { | ||
// in this case, conformsTo cleans up a somewhat messy if statement | ||
if (_.conformsTo(wofData.properties, { | ||
'wof:placetype': placetype => placetype === 'neighbourhood', | ||
'wof:hierarchy': hierarchy => !_.has(hierarchy[0], 'locality_id') && !_.has(hierarchy[0], 'localadmin_id') | ||
})) { | ||
logger.debug(`skipping ${wofData.properties['wof:id']}: neighbourhood without locality or localadmin`); | ||
return false; | ||
} | ||
|
||
return true; | ||
}); | ||
}; |
24 changes: 24 additions & 0 deletions
24
src/pip/components/filterOutHierarchylessNeighbourhoods.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const filter = require('through2-filter'); | ||
const _ = require('lodash'); | ||
const logger = require('pelias-logger').get('wof-pip-service:filterOutHierarchylessNeighbourhoods'); | ||
|
||
// This filter stream returns false when wof:placetype = neighbourhood AND | ||
// wof:hierarchy is empty | ||
// returns true otherwise | ||
// | ||
// It's needed because there are some unfortunate important WOF neighbourhoods | ||
// that are currently incomplete | ||
module.exports.create = function create() { | ||
return filter.obj(wofData => { | ||
// in this case, conformsTo cleans up a somewhat messy if statement | ||
if (_.conformsTo(wofData.properties, { | ||
'wof:placetype': placetype => placetype === 'neighbourhood', | ||
'wof:hierarchy': hierarchy => _.isEmpty(hierarchy) | ||
})) { | ||
logger.debug(`skipping ${wofData.properties['wof:id']}: neighbourhood with empty hierarchy`); | ||
return false; | ||
} | ||
|
||
return true; | ||
}); | ||
}; |
Oops, something went wrong.