diff options
author | Andrew Harvey <andrew@alantgeo.com.au> | 2021-06-18 15:37:45 +1000 |
---|---|---|
committer | Andrew Harvey <andrew@alantgeo.com.au> | 2021-06-18 15:37:45 +1000 |
commit | d979aeb8e311ba3970c77a57b07ec1dea622b39f (patch) | |
tree | e0dea114966910d10875fe5a7bd66f2ee9e33c5b /bin/reduceRangeDuplicates.js | |
parent | dfc9041eb086e32b00f597bc1aebb284946d412f (diff) |
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_)
Diffstat (limited to 'bin/reduceRangeDuplicates.js')
-rwxr-xr-x | bin/reduceRangeDuplicates.js | 23 |
1 files changed, 21 insertions, 2 deletions
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 |