From d3bce8304bea5af61fbd59fd7508e393dfeded06 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Tue, 4 Mar 2025 17:02:32 +0100 Subject: [PATCH 1/2] Change order of region/macroregion layers when doing search --- src/pip/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pip/index.js b/src/pip/index.js index d218e29..49d56ef 100644 --- a/src/pip/index.js +++ b/src/pip/index.js @@ -20,6 +20,8 @@ const workers = {}; const responseQueue = {}; const wofData = {}; +// NB: order is important here +// consult with https://github.com/whosonfirst/whosonfirst-placetypes when making changes const defaultLayers = [ 'neighbourhood', 'borough', @@ -27,8 +29,8 @@ const defaultLayers = [ 'localadmin', 'county', 'macrocounty', - 'macroregion', 'region', + 'macroregion', 'dependency', 'country', 'empire', @@ -40,7 +42,10 @@ const defaultLayers = [ module.exports.create = function createPIPService(datapath, layers, localizedAdminNames, callback) { // take the intersection to keep order in decreasing granularity // ie - _.intersection([1, 2, 3], [3, 1]) === [1, 3] + + layers = _.intersection(defaultLayers, _.isEmpty(layers) ? defaultLayers : layers); + console.log('CREATE PP', layers); const folder = path.join(datapath, 'sqlite'); if (!fs.existsSync(folder)) { From c89b982a37e9888f4f7c018b5f567e97c59f35fd Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Tue, 4 Mar 2025 17:20:30 +0100 Subject: [PATCH 2/2] Remove log --- src/pip/index.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pip/index.js b/src/pip/index.js index 49d56ef..63929ed 100644 --- a/src/pip/index.js +++ b/src/pip/index.js @@ -42,10 +42,7 @@ const defaultLayers = [ module.exports.create = function createPIPService(datapath, layers, localizedAdminNames, callback) { // take the intersection to keep order in decreasing granularity // ie - _.intersection([1, 2, 3], [3, 1]) === [1, 3] - - layers = _.intersection(defaultLayers, _.isEmpty(layers) ? defaultLayers : layers); - console.log('CREATE PP', layers); const folder = path.join(datapath, 'sqlite'); if (!fs.existsSync(folder)) {