Browse Source

pull population from placeholder repsonse

pull/850/head
Stephen Hess 8 years ago
parent
commit
d1b87235c4
  1. 4
      controller/placeholder.js
  2. 4
      test/unit/controller/placeholder.js

4
controller/placeholder.js

@ -63,6 +63,10 @@ function synthesizeDocs(boundaryCountry, result) {
logger.error(`could not parse bbox for id ${result.id}: ${result.geom.bbox}`);
}
if (_.conformsTo(result, { 'population': isFiniteNumber })) {
doc.setPopulation(result.population);
}
_.defaultTo(result.lineage, [])
// remove all lineages that don't match an explicit boundary.country
.filter(_.curry(matchesBoundaryCountry)(boundaryCountry))

4
test/unit/controller/placeholder.js

@ -79,6 +79,7 @@ module.exports.tests.success = (test, common) => {
id: 123,
name: 'name 1',
placetype: 'neighbourhood',
population: 123456,
lineage: [
{
country: {
@ -187,6 +188,7 @@ module.exports.tests.success = (test, common) => {
id: 456,
name: 'name 3',
placetype: 'locality',
population: 789,
lineage: [ {} ],
geom: {
area: 23.45,
@ -228,6 +230,7 @@ module.exports.tests.success = (test, common) => {
phrase: {
'default': 'name 1'
},
population: 123456,
parent: {
neighbourhood: ['neighbourhood name 1', 'neighbourhood name 2'],
neighbourhood_id: ['10', '20'],
@ -278,6 +281,7 @@ module.exports.tests.success = (test, common) => {
phrase: {
'default': 'name 3'
},
population: 789,
parent: { }
}
]

Loading…
Cancel
Save