diff options
Diffstat (limited to 'lib/withinRange.js')
-rw-r--r-- | lib/withinRange.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/withinRange.js b/lib/withinRange.js index f8b61ad..81bb6d4 100644 --- a/lib/withinRange.js +++ b/lib/withinRange.js @@ -6,7 +6,7 @@ * @param {boolean} [options.checkHigherOrderAddrKeys=true] - if true checks that addr:suburb, addr:state, addr:postcode also match * @param {boolean} [options.checkStreet=true] - if true checks that addr:street matches * - * @returns {boolean} True if addr:housenumber of feature is within the range of addr:housenumber rangeFeature and all other addr:* attributes match + * @returns {boolean} True if addr:housenumber of feature is within the range of addr:housenumber rangeFeature and all other addr:* attributes match, ignoring any unit from a "unit/number" style addr:housenumber of rangeFeature */ module.exports = (feature, rangeFeature, options) => { const regexp = /^(?<pre>\D*)(?<num>\d*)(?<suf>\D*)$/ @@ -37,13 +37,14 @@ module.exports = (feature, rangeFeature, options) => { ) : true ) ) { - const rangeParts = rangeFeature.properties['addr:housenumber'].split('-') + const rangeNumber = rangeFeature.properties["addr:housenumber"].split("/").length > 1 ? rangeFeature.properties["addr:housenumber"].split("/")[1] : rangeFeature.properties["addr:housenumber"]; + const rangeParts = rangeNumber.split('-') if (rangeParts.length === 2) { const fromMatch = rangeParts[0].match(regexp) const toMatch = rangeParts[1].match(regexp) if (!fromMatch || !toMatch) { - console.log(`range ${rangeFeature.properties['addr:housenumber']} didn't match regexp`, rangeFeature) + console.log(`range ${rangeNumber} didn't match regexp`, rangeFeature) return false } const from = rangeParts[0].match(regexp).groups |