Skip to content

Commit d4dfb48

Browse files
committed
feat(address_search_using_ids): add macrocounty as synonym for locality
1 parent 68163b1 commit d4dfb48

File tree

2 files changed

+96
-9
lines changed

2 files changed

+96
-9
lines changed

query/address_search_using_ids.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ function generateQuery( clean, res ){
131131
// find the first granularity band for which there are results
132132
const granularity_band = granularity_bands.find(band => anyResultsAtGranularityBand(results, band));
133133

134+
// special case: if locality is present in the band, also include macrocounty
135+
// this is used to cover the Greater Syndey Area
136+
if (granularity_band && granularity_band.includes('locality')) {
137+
granularity_band.push('macrocounty');
138+
}
139+
134140
// if there's a granularity band, accumulate the ids from each layer in the band
135141
// into an object mapping layer->ids of those layers
136142
if (granularity_band) {

test/unit/query/address_search_using_ids.js

Lines changed: 90 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,15 @@ module.exports.tests.granularity_bands = (test, common) => {
287287
const generatedQuery = generateQuery(clean, res);
288288

289289
t.deepEquals(generatedQuery.body.vs.var('input:layers').$, {
290-
neighbourhood: [1, 11],
291-
borough: [2, 12],
292-
locality: [3, 13],
293-
localadmin: [4, 14],
294-
region: [7, 17],
295-
macroregion: [8, 18],
296-
dependency: [9, 19],
297-
country: [10, 20]
290+
neighbourhood: [ 1, 11 ],
291+
borough: [ 2, 12 ],
292+
locality: [ 3, 13 ],
293+
localadmin: [ 4, 14 ],
294+
region: [ 7, 17 ],
295+
macroregion: [ 8, 18 ],
296+
dependency: [ 9, 19 ],
297+
country: [ 10, 20 ],
298+
macrocounty: [ 6, 16 ]
298299
});
299300

300301
t.end();
@@ -339,7 +340,8 @@ module.exports.tests.granularity_bands = (test, common) => {
339340
region: [],
340341
macroregion: [],
341342
dependency: [],
342-
country: []
343+
country: [],
344+
macrocounty: []
343345
});
344346

345347
t.end();
@@ -609,6 +611,85 @@ module.exports.tests.boundary_filters = (test, common) => {
609611

610612
};
611613

614+
module.exports.tests.sydney_macrocounty = (test, common) => {
615+
test('Refering to Greater Sydney area (macrocounty) rather than Sydney Metro Area (locality)', (t) => {
616+
const logger = mock_logger();
617+
618+
const clean = {
619+
text: '300 Burns Bay Road, Sydney, AU',
620+
parsed_text: {
621+
housenumber: '300',
622+
street: 'burns bay road',
623+
city: 'sydney',
624+
country: 'AUS'
625+
}
626+
};
627+
const res = {
628+
data: [
629+
{
630+
layer: 'continent',
631+
source_id: '102191583'
632+
},
633+
{
634+
layer: 'country',
635+
source_id: '85632793'
636+
},
637+
{
638+
layer: 'county',
639+
source_id: '102049151'
640+
},
641+
{
642+
layer: 'empire',
643+
source_id: '136253039'
644+
},
645+
{
646+
layer: 'localadmin',
647+
source_id: '404226357'
648+
},
649+
{
650+
layer: 'locality',
651+
source_id: '101932003'
652+
},
653+
{
654+
layer: 'macrocounty',
655+
source_id: '1376953385'
656+
},
657+
{
658+
layer: 'region',
659+
source_id: '85681545'
660+
}
661+
]
662+
};
663+
664+
const generateQuery = proxyquire('../../../query/address_search_using_ids', {
665+
'pelias-logger': logger,
666+
'pelias-query': {
667+
layout: {
668+
AddressesUsingIdsQuery: MockQuery
669+
},
670+
view: views,
671+
Vars: require('pelias-query').Vars
672+
}
673+
});
674+
675+
const generatedQuery = generateQuery(clean, res);
676+
677+
t.deepEquals(generatedQuery.body.vs.var('input:layers').$, {
678+
neighbourhood: [],
679+
borough: [],
680+
locality: [ '101932003' ],
681+
localadmin: [ '404226357' ],
682+
region: [ '85681545' ],
683+
macroregion: [],
684+
dependency: [],
685+
country: [ '85632793' ],
686+
macrocounty: [ '1376953385' ]
687+
});
688+
689+
t.end();
690+
});
691+
};
692+
612693
module.exports.all = (tape, common) => {
613694
function test(name, testFunction) {
614695
return tape(`address_search_using_ids query ${name}`, testFunction);

0 commit comments

Comments
 (0)