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}`); 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, []) _.defaultTo(result.lineage, [])
// remove all lineages that don't match an explicit boundary.country // remove all lineages that don't match an explicit boundary.country
.filter(_.curry(matchesBoundaryCountry)(boundaryCountry)) .filter(_.curry(matchesBoundaryCountry)(boundaryCountry))

4
test/unit/controller/placeholder.js

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

Loading…
Cancel
Save