Browse Source

no need to hit address parser if the input has just one token or two and no numbers

Ex: new, new york, minneapolis etc dont need address parsing but 'starbucks 10010' might need it
pull/169/head
Harish Krishna 9 years ago
parent
commit
e1f3cfa0d3
  1. 9
      sanitiser/_input.js

9
sanitiser/_input.js

@ -38,14 +38,15 @@ function sanitize( req ){
parsedAddress0.admin_parts = params.input.substring(delimIndex + 1).trim();
}
var splitOnDelim = params.input.split(delim).join('');
var splitOnSpace = delim !== ' ' ? splitOnDelim.split(' ') : splitOnDelim;
var tokenized = params.input.split(/[ ,]+/);
var hasNumber = /\d$/.test(params.input);
// set target_layer if input length <= 3 characters
if (params.input.length <= 3 ) {
// no address parsing required
parsedAddress2.target_layer = get_layers(['admin']);
} else if (splitOnSpace.length < 3) {
// no need to hit address layers if there's only two tokens
} else if (tokenized.length === 1 || (tokenized.length < 3 && !hasNumber)) {
// no need to hit address layers if there's only one (or two) token(s)
parsedAddress2.target_layer = get_layers(['admin', 'poi']);
} else {
// address parsing

Loading…
Cancel
Save