Browse Source

fixing layers related bug - adding a default_layers_set flag to clean obj.

pull/169/head
Harish Krishna 10 years ago
parent
commit
96a21570be
  1. 4
      controller/search.js
  2. 4
      sanitiser/_input.js
  3. 1
      sanitiser/_layers.js
  4. 1
      test/unit/sanitiser/reverse.js

4
controller/search.js

@ -22,8 +22,8 @@ function setup( backend, query ){
}
// set type if input suggests targeting a layer(s)
if (req.clean.parsed_input) {
cmd.type = req.clean.parsed_input.target_layer;
if (req.clean.default_layers_set && req.clean.parsed_input) {
cmd.type = req.clean.parsed_input.target_layer || cmd.type;
}
// query backend

4
sanitiser/_input.js

@ -48,6 +48,10 @@ function sanitize( req ){
// set target_layer if input suggests no address
if (parsedAddress1.text === parsedAddress1.regions.join(' ')) {
parsedAddress2.target_layer = get_layers(['admin', 'poi']);
} else {
// this might be an overkill - you'd want to search for poi and admin
// even if an address is being queried. TBD
parsedAddress2.target_layer = get_layers(['address']);
}
}

1
sanitiser/_layers.js

@ -17,6 +17,7 @@ function sanitize( req ){
// default case (no layers specified in GET params)
if('string' !== typeof params.layers || !params.layers.length){
params.layers = 'poi,admin,address'; // default layers
clean.default_layers_set = true;
}
// decide which layers can be queried

1
test/unit/sanitiser/reverse.js

@ -10,6 +10,7 @@ var suggest = require('../../../sanitiser/reverse'),
lon: 0,
size: 10,
details: true,
default_layers_set: true,
categories: []
},
sanitize = function(query, cb) { _sanitize({'query':query}, cb); };

Loading…
Cancel
Save