From d979aeb8e311ba3970c77a57b07ec1dea622b39f Mon Sep 17 00:00:00 2001 From: Andrew Harvey Date: Fri, 18 Jun 2021 15:37:45 +1000 Subject: Where one of the range endpoints is mapped with `addr:flats` and the range itself has no `addr:flats` then the range is removed (for example at _116 Anderson Street, South Yarra_) --- bin/reduceRangeDuplicates.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'bin/reduceRangeDuplicates.js') diff --git a/bin/reduceRangeDuplicates.js b/bin/reduceRangeDuplicates.js index 89f8a11..6fac0b5 100755 --- a/bin/reduceRangeDuplicates.js +++ b/bin/reduceRangeDuplicates.js @@ -134,6 +134,9 @@ const reduceRange = new Transform({ let foundStart = false let foundEnd = false + let matchedStart + let matchedEnd + let startNum let endNum let pre = '' @@ -142,6 +145,7 @@ const reduceRange = new Transform({ for (const matchCandidate of matchCandidates) { if (!foundStart && start === matchCandidate.properties['addr:housenumber']) { foundStart = true + matchedStart = matchCandidate const match = start.match(regexp) if (match && match.groups) { @@ -152,6 +156,7 @@ const reduceRange = new Transform({ } if (!foundEnd && end === matchCandidate.properties['addr:housenumber']) { foundEnd = true + matchedEnd = matchCandidate const match = end.match(regexp) if (match && match.groups) { @@ -203,8 +208,22 @@ const reduceRange = new Transform({ // keep track of removed features for filter B, so we don't double remove both range and midpoints rangesRemovedInFilterA[hash(feature)] = true } else { - // since not both start and end found, then still include the range - this.push(feature) + // not both start and end found, + // if one of start or end found and that start/end has addr:flats... + if (foundStart || foundEnd) { + // ...if the range has no flats AND the non-range has addr:flats + if (!feature.properties['addr:flats'] && ( + (matchedStart && matchedStart.properties['addr:flats']) || (matchedEnd && matchedEnd.properties['addr:flats']) + )) { + // drop the range, eg "112-116 Anderson Street, South Yarra" + } else { + // then still include the range + this.push(feature) + } + } else { + // then still include the range + this.push(feature) + } } } else { // there are no non-ranges on this street so still include the range -- cgit v1.2.3