aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorAndrew Harvey <andrew@alantgeo.com.au>2021-07-01 00:28:56 +1000
committerAndrew Harvey <andrew@alantgeo.com.au>2021-07-01 00:28:56 +1000
commitfde743937c9af05bcaf8b959c54c89404f97bc22 (patch)
treee551fc19abec02e31b2ebdf8aa88c7f0478a0c65 /bin
parent4fab88019b9ff0324d9709dfff48615b5464729c (diff)
within range provide a drop reason and consider parity of number
Diffstat (limited to 'bin')
-rwxr-xr-xbin/reduceRangeDuplicates.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/bin/reduceRangeDuplicates.js b/bin/reduceRangeDuplicates.js
index 4ef57f9..d22d5f2 100755
--- a/bin/reduceRangeDuplicates.js
+++ b/bin/reduceRangeDuplicates.js
@@ -287,11 +287,12 @@ const reduceNonRange = new Transform({
].join('/')
let dropFeature = false
+ let dropReason
if (key in rangesByStreet) {
for (let i = 0; i < rangesByStreet[key].length; i++) {
const range = rangesByStreet[key][i]
// if the range wasn't just removed in filter A, and the feature is within the range
- if (!(hash(range) in rangesRemovedInFilterA) && withinRange(feature, range)) {
+ if (!(hash(range) in rangesRemovedInFilterA) && withinRange(feature, range, { matchParity: true })) {
// found within a range, drop feature unless would drop addr:unit or addr:flats information
if ('addr:unit' in feature.properties || 'addr:flats' in feature.properties) {
// safe to drop if the same addr:unit and addr:flats is also on the range
@@ -299,6 +300,7 @@ const reduceNonRange = new Transform({
'addr:unit' in feature.properties ? ('addr:unit' in range.properties && feature.properties['addr:unit'] === range.properties['addr:unit']) : true &&
'addr:flats' in feature.properties ? ('addr:flats' in range.properties && feature.properties['addr:flats'] === range.properties['addr:flats']) : true
) {
+ dropReason = `Dropped due to existing range ${range.properties['addr:housenumber']} ${range.properties['addr:street']} ${range.properties._pfi ? '(' + range.properties._pfi + ')' : ''} where flats and unit match`
dropFeature = true
} else {
// since the non-range feature has a unit that the range doesn't have, don't drop it
@@ -319,6 +321,7 @@ const reduceNonRange = new Transform({
}
} else {
// no addr:unit or addr:flats on the feature to safe to drop
+ dropReason = `Dropped due to existing range ${range.properties['addr:housenumber']} ${range.properties['addr:street']} ${range.properties._pfi ? '(' + range.properties._pfi + ')' : ''} without flats or unit to check`
dropFeature = true
}
break
@@ -333,6 +336,7 @@ const reduceNonRange = new Transform({
console.log(`Filter B: Dropping ${feature.properties['addr:housenumber']}`)
}
if (argv.debug) {
+ feature.properties._dropReason = dropReason
debugStreams['filterB'].write(feature)
}
}