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/229/head
Julian Simioni 10 years ago
parent
commit
ad8db9b8e9
  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) { var getAddressParts = function(query) {
// address parsing // perform full address parsing
var address = parser( query ); // except on queries so short they obviously can't contain an address
// set target_layer if input suggests no address return parser( query );
if (address.text === address.regions.join(' ') && !hasNumber) {
address.target_layer = get_layers(['admin', 'poi']);
}
return address;
}; };
var addressWithAdminParts = getAdminPartsBySplittingOnDelim(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(typeof address.postalcode, 'number', 'valid zip (' + address.postalcode + ')');
t.equal(address.postalcode, query.zip, 'correct postal code (' + query.zip + ')'); 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(); t.end();
}); });
}; };
@ -165,4 +161,4 @@ module.exports.all = function (tape, common) {
for( var testCase in module.exports.tests ){ for( var testCase in module.exports.tests ){
module.exports.tests[testCase](test, common); module.exports.tests[testCase](test, common);
} }
}; };

Loading…
Cancel
Save