Browse Source

play with precisions

msv2
Harish Krishna 10 years ago
parent
commit
a824d209aa
  1. 12
      controller/suggest.js
  2. 4
      query/suggest_poi.js

12
controller/suggest.js

@ -41,11 +41,19 @@ function setup( backend, query ){
poi: function(callback){ poi: function(callback){
cmd.body = query_poi( req.clean ); cmd.body = query_poi( req.clean );
query_backend(cmd, callback); query_backend(cmd, callback);
},
poi3: function(callback){
cmd.body = query_poi( req.clean, 3 );
query_backend(cmd, callback);
},
poi1: function(callback){
cmd.body = query_poi( req.clean, 1 );
query_backend(cmd, callback);
} }
}, },
function(err, results) { function(err, results) {
// results is now equals to: {admin: docs, poi: docs} // results is now equals to: {admin: docs, poi: docs, poi1: docs, poi3: docs}
var combined = results.poi.slice(0, 3).concat(results.admin); var combined = results.poi.concat(results.admin).concat(results.poi1).concat(results.poi3);
// convert docs to geojson // convert docs to geojson
var geojson = geojsonify( combined ); var geojson = geojsonify( combined );

4
query/suggest_poi.js

@ -2,7 +2,7 @@
var logger = require('../src/logger'); var logger = require('../src/logger');
// Build pelias suggest query // Build pelias suggest query
function generate( params ){ function generate( params, precision ){
var getPrecision = function(zoom) { var getPrecision = function(zoom) {
switch (true) { switch (true) {
@ -29,7 +29,7 @@ function generate( params ){
'dataset': params.layers, 'dataset': params.layers,
'location': { 'location': {
'value': [ params.lon, params.lat ], 'value': [ params.lon, params.lat ],
'precision': getPrecision(params.zoom) 'precision': precision || getPrecision(params.zoom)
} }
} }
} }

Loading…
Cancel
Save