Browse Source

Remove layer configuration based on address parsing

This code doesn't seem like it will be triggered very often (due to it
comapring space delimited words with comma delimited words from the text
field), and also has the potential to cause quite a bit of weird
behavior.
pull/221/head
Julian Simioni 9 years ago
parent
commit
1fae622c39
  1. 11
      helper/query_parser.js
  2. 8
      test/unit/helper/query_parser.js

11
helper/query_parser.js

@ -37,14 +37,9 @@ module.exports = function(query) {
};
var getAddressParts = function(query) {
// address parsing
var address = parser( query );
// set target_layer if input suggests no address
if (address.text === address.regions.join(' ') && !hasNumber) {
address.target_layer = get_layers(['admin', 'poi']);
}
return address;
// perform full address parsing
// except on queries so short they obviously can't contain an address
return parser( query );
};
var addressWithAdminParts = getAdminPartsBySplittingOnDelim(query);

8
test/unit/helper/query_parser.js

@ -136,11 +136,7 @@ module.exports.tests.parse_address = function(test, common) {
t.equal(typeof address.postalcode, 'number', 'valid zip (' + address.postalcode + ')');
t.equal(address.postalcode, query.zip, 'correct postal code (' + query.zip + ')');
}
if (address.text === address.regions.join(' ')) {
t.deepEqual(address.target_layer, query.target_layer, 'admin_parts set correctly to ' + query.target_layer.join(', '));
}
t.end();
});
};
@ -165,4 +161,4 @@ module.exports.all = function (tape, common) {
for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common);
}
};
};

Loading…
Cancel
Save