You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
|
|
var logger = require('../src/logger');
|
|
|
|
|
|
|
|
// Build pelias suggest query
|
|
|
|
function generate( params ){
|
|
|
|
|
|
|
|
var getPrecision = function(zoom) {
|
|
|
|
if (zoom>=15) {
|
|
|
|
return 9;
|
|
|
|
} else {
|
|
|
|
return parseInt(zoom/2) || 1;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var cmd = {
|
|
|
|
'pelias' : {
|
|
|
|
'text' : params.input,
|
|
|
|
'completion' : {
|
|
|
|
'size' : params.size,
|
|
|
|
'field' : 'suggest',
|
|
|
|
'context': {
|
|
|
|
'dataset': params.layers,
|
|
|
|
'location': {
|
|
|
|
'value': [ params.lon, params.lat ],
|
|
|
|
'precision': getPrecision(params.zoom)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// logger.log( 'cmd', JSON.stringify( cmd, null, 2 ) );
|
|
|
|
return cmd;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = generate;
|