|
|
@ -62,6 +62,7 @@ function synthesizeDoc(results) { |
|
|
|
const most_granular_layer = getMostGranularLayerOfResult(_.keys(results)); |
|
|
|
const most_granular_layer = getMostGranularLayerOfResult(_.keys(results)); |
|
|
|
const id = results[most_granular_layer][0].id; |
|
|
|
const id = results[most_granular_layer][0].id; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
const doc = new Document('whosonfirst', most_granular_layer, id.toString()); |
|
|
|
const doc = new Document('whosonfirst', most_granular_layer, id.toString()); |
|
|
|
doc.setName('default', results[most_granular_layer][0].name); |
|
|
|
doc.setName('default', results[most_granular_layer][0].name); |
|
|
|
|
|
|
|
|
|
|
@ -96,6 +97,15 @@ function synthesizeDoc(results) { |
|
|
|
esDoc.data._type = esDoc._type; |
|
|
|
esDoc.data._type = esDoc._type; |
|
|
|
return esDoc.data; |
|
|
|
return esDoc.data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch( e ) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// an error occurred when generating a new Document
|
|
|
|
|
|
|
|
logger.info(`[controller:coarse_reverse][error]`); |
|
|
|
|
|
|
|
logger.error(e); |
|
|
|
|
|
|
|
logger.error(results); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setup(service, should_execute) { |
|
|
|
function setup(service, should_execute) { |
|
|
@ -141,7 +151,10 @@ function setup(service, should_execute) { |
|
|
|
|
|
|
|
|
|
|
|
// if there's a result at the requested layer(s), synthesize a doc from results
|
|
|
|
// if there's a result at the requested layer(s), synthesize a doc from results
|
|
|
|
if (hasResultsAtRequestedLayers(applicable_results, effective_layers)) { |
|
|
|
if (hasResultsAtRequestedLayers(applicable_results, effective_layers)) { |
|
|
|
res.data.push(synthesizeDoc(applicable_results)); |
|
|
|
const doc = synthesizeDoc(applicable_results); |
|
|
|
|
|
|
|
if (doc){ |
|
|
|
|
|
|
|
res.data.push(doc); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
debugLog.stopTimer(req, initialTime); |
|
|
|
debugLog.stopTimer(req, initialTime); |
|
|
|
return next(); |
|
|
|
return next(); |
|
|
|