|
|
@ -120,7 +120,7 @@ function generateQuery( clean ){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getQuery(vs) { |
|
|
|
function getQuery(vs) { |
|
|
|
if (hasStreet(vs) || isCityStateOnlyWithOptionalCountry(vs)) { |
|
|
|
if (hasStreet(vs) || isCountyRegion(vs) || isCityStateOnlyWithOptionalCountry(vs)) { |
|
|
|
return { |
|
|
|
return { |
|
|
|
type: 'fallback', |
|
|
|
type: 'fallback', |
|
|
|
body: fallbackQuery.render(vs) |
|
|
|
body: fallbackQuery.render(vs) |
|
|
@ -130,13 +130,24 @@ function getQuery(vs) { |
|
|
|
// returning undefined is a signal to a later step that the addressit-parsed
|
|
|
|
// returning undefined is a signal to a later step that the addressit-parsed
|
|
|
|
// query should be queried for
|
|
|
|
// query should be queried for
|
|
|
|
return undefined; |
|
|
|
return undefined; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function hasStreet(vs) { |
|
|
|
function hasStreet(vs) { |
|
|
|
return vs.isset('input:street'); |
|
|
|
return vs.isset('input:street'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isCountyRegion(vs) { |
|
|
|
|
|
|
|
var isSet = function(layer) { |
|
|
|
|
|
|
|
return vs.isset('input:' + layer); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var allowedFields = ['county', 'region']; |
|
|
|
|
|
|
|
var disallowedFields = ['query', 'category', 'housenumber', 'street', |
|
|
|
|
|
|
|
'neighbourhood', 'borough', 'postcode', 'locality']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return allowedFields.every(isSet) && !disallowedFields.some(isSet); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function isCityStateOnlyWithOptionalCountry(vs) { |
|
|
|
function isCityStateOnlyWithOptionalCountry(vs) { |
|
|
|
var isSet = function(layer) { |
|
|
|
var isSet = function(layer) { |
|
|
|
return vs.isset('input:' + layer); |
|
|
|
return vs.isset('input:' + layer); |
|
|
|